summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2021-04-07 08:28:05 -0700
committerAnthony Sottile <asottile@umich.edu>2021-04-07 08:28:11 -0700
commit3f10c04fd029cf520b9769e574ada7df87083db6 (patch)
tree148541f950701bf41df5fa7c31eb2aba792c76f9 /tests
parentfcf56ac93eafc4d4c3da718423d323ce67fd3fd6 (diff)
downloadflake8-3f10c04fd029cf520b9769e574ada7df87083db6.tar.gz
fix mypy errors
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/test_plugins.py4
-rw-r--r--tests/unit/test_exceptions.py70
-rw-r--r--tests/unit/test_plugin_manager.py8
3 files changed, 36 insertions, 46 deletions
diff --git a/tests/integration/test_plugins.py b/tests/integration/test_plugins.py
index 1b6203e..867a94e 100644
--- a/tests/integration/test_plugins.py
+++ b/tests/integration/test_plugins.py
@@ -41,7 +41,9 @@ def test_enable_local_plugin_from_config():
app = application.Application()
app.initialize(['flake8', '--config', LOCAL_PLUGIN_CONFIG])
+ assert app.check_plugins is not None
assert app.check_plugins['XE'].plugin is ExtensionTestPlugin
+ assert app.formatting_plugins is not None
assert app.formatting_plugins['XR'].plugin is ReportTestPlugin
@@ -51,6 +53,7 @@ def test_local_plugin_can_add_option():
app.initialize(
['flake8', '--config', LOCAL_PLUGIN_CONFIG, '--anopt', 'foo'])
+ assert app.options is not None
assert app.options.anopt == 'foo'
@@ -59,4 +62,5 @@ def test_enable_local_plugin_at_non_installed_path():
app = application.Application()
app.initialize(['flake8', '--config', LOCAL_PLUGIN_PATH_CONFIG])
+ assert app.check_plugins is not None
assert app.check_plugins['XE'].plugin.name == 'ExtensionTestPlugin2'
diff --git a/tests/unit/test_exceptions.py b/tests/unit/test_exceptions.py
index 0254cb2..89490fa 100644
--- a/tests/unit/test_exceptions.py
+++ b/tests/unit/test_exceptions.py
@@ -1,48 +1,34 @@
"""Tests for the flake8.exceptions module."""
import pickle
-from flake8 import exceptions
-
-
-class _ExceptionTest:
- def test_pickleable(self):
- """Test that the exception is round-trip pickleable."""
- for proto in range(pickle.HIGHEST_PROTOCOL + 1):
- new_err = pickle.loads(pickle.dumps(self.err, protocol=proto))
- assert str(self.err) == str(new_err)
- orig_e = self.err.original_exception
- new_e = new_err.original_exception
- assert (type(orig_e), orig_e.args) == (type(new_e), new_e.args)
-
-
-class TestFailedToLoadPlugin(_ExceptionTest):
- """Tests for the FailedToLoadPlugin exception."""
-
- err = exceptions.FailedToLoadPlugin(
- plugin_name='plugin_name',
- exception=ValueError('boom!'),
- )
-
-
-class TestInvalidSyntax(_ExceptionTest):
- """Tests for the InvalidSyntax exception."""
-
- err = exceptions.InvalidSyntax(exception=ValueError('Unexpected token: $'))
-
-
-class TestPluginRequestedUnknownParameters(_ExceptionTest):
- """Tests for the PluginRequestedUnknownParameters exception."""
-
- err = exceptions.PluginRequestedUnknownParameters(
- plugin={'plugin_name': 'plugin_name'},
- exception=ValueError('boom!'),
- )
+import pytest
+from flake8 import exceptions
-class TestPluginExecutionFailed(_ExceptionTest):
- """Tests for the PluginExecutionFailed exception."""
- err = exceptions.PluginExecutionFailed(
- plugin={'plugin_name': 'plugin_name'},
- exception=ValueError('boom!'),
- )
+@pytest.mark.parametrize(
+ 'err',
+ (
+ exceptions.FailedToLoadPlugin(
+ plugin_name='plugin_name',
+ exception=ValueError('boom!'),
+ ),
+ exceptions.InvalidSyntax(exception=ValueError('Unexpected token: $')),
+ exceptions.PluginRequestedUnknownParameters(
+ plugin={'plugin_name': 'plugin_name'},
+ exception=ValueError('boom!'),
+ ),
+ exceptions.PluginExecutionFailed(
+ plugin={'plugin_name': 'plugin_name'},
+ exception=ValueError('boom!'),
+ )
+ ),
+)
+def test_pickleable(err):
+ """Ensure that our exceptions can cross pickle boundaries."""
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ new_err = pickle.loads(pickle.dumps(err, protocol=proto))
+ assert str(err) == str(new_err)
+ orig_e = err.original_exception
+ new_e = new_err.original_exception
+ assert (type(orig_e), orig_e.args) == (type(new_e), new_e.args)
diff --git a/tests/unit/test_plugin_manager.py b/tests/unit/test_plugin_manager.py
index 55c3e24..6f95a72 100644
--- a/tests/unit/test_plugin_manager.py
+++ b/tests/unit/test_plugin_manager.py
@@ -18,8 +18,8 @@ def test_calls_entrypoints_creates_plugins_automaticaly(entry_points_mck):
"""Verify that we create Plugins on instantiation."""
entry_points_mck.return_value = {
'testing.entrypoints': [
- importlib_metadata.EntryPoint('T100', '', None),
- importlib_metadata.EntryPoint('T200', '', None),
+ importlib_metadata.EntryPoint('T100', '', 'testing.entrypoints'),
+ importlib_metadata.EntryPoint('T200', '', 'testing.entrypoints'),
],
}
plugin_mgr = manager.PluginManager(namespace='testing.entrypoints')
@@ -36,8 +36,8 @@ def test_handles_mapping_functions_across_plugins(entry_points_mck):
"""Verify we can use the PluginManager call functions on all plugins."""
entry_points_mck.return_value = {
'testing.entrypoints': [
- importlib_metadata.EntryPoint('T100', '', None),
- importlib_metadata.EntryPoint('T200', '', None),
+ importlib_metadata.EntryPoint('T100', '', 'testing.entrypoints'),
+ importlib_metadata.EntryPoint('T200', '', 'testing.entrypoints'),
],
}
plugin_mgr = manager.PluginManager(namespace='testing.entrypoints')