summaryrefslogtreecommitdiff
path: root/tests/unit
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/unit
parentfcf56ac93eafc4d4c3da718423d323ce67fd3fd6 (diff)
downloadflake8-3f10c04fd029cf520b9769e574ada7df87083db6.tar.gz
fix mypy errors
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_exceptions.py70
-rw-r--r--tests/unit/test_plugin_manager.py8
2 files changed, 32 insertions, 46 deletions
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')