mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 04:36:52 +00:00
fix mypy errors
This commit is contained in:
parent
fcf56ac93e
commit
3f10c04fd0
8 changed files with 92 additions and 76 deletions
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -1,48 +1,34 @@
|
|||
"""Tests for the flake8.exceptions module."""
|
||||
import pickle
|
||||
|
||||
import pytest
|
||||
|
||||
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!'),
|
||||
)
|
||||
|
||||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue