mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-07 05:26:53 +00:00
Update to new entry_points selection protocol.
This commit is contained in:
parent
6de8252c03
commit
f4238018c0
5 changed files with 17 additions and 21 deletions
|
|
@ -106,7 +106,7 @@ def mock_file_checker_with_plugin(plugin_target):
|
|||
with mock.patch.object(
|
||||
importlib_metadata,
|
||||
'entry_points',
|
||||
return_value={'flake8.extension': [entry_point]},
|
||||
return_value=[entry_point],
|
||||
):
|
||||
checks = manager.Checkers()
|
||||
|
||||
|
|
|
|||
|
|
@ -8,23 +8,21 @@ from flake8.plugins import manager
|
|||
@mock.patch.object(importlib_metadata, 'entry_points')
|
||||
def test_calls_entrypoints_on_instantiation(entry_points_mck):
|
||||
"""Verify that we call entry_points() when we create a manager."""
|
||||
entry_points_mck.return_value = {}
|
||||
entry_points_mck.return_value = []
|
||||
manager.PluginManager(namespace='testing.entrypoints')
|
||||
entry_points_mck.assert_called_once_with()
|
||||
entry_points_mck.assert_called_once_with(group='testing.entrypoints')
|
||||
|
||||
|
||||
@mock.patch.object(importlib_metadata, 'entry_points')
|
||||
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),
|
||||
],
|
||||
}
|
||||
entry_points_mck.return_value = [
|
||||
importlib_metadata.EntryPoint('T100', '', None),
|
||||
importlib_metadata.EntryPoint('T200', '', None),
|
||||
]
|
||||
plugin_mgr = manager.PluginManager(namespace='testing.entrypoints')
|
||||
|
||||
entry_points_mck.assert_called_once_with()
|
||||
entry_points_mck.assert_called_once_with(group='testing.entrypoints')
|
||||
assert 'T100' in plugin_mgr.plugins
|
||||
assert 'T200' in plugin_mgr.plugins
|
||||
assert isinstance(plugin_mgr.plugins['T100'], manager.Plugin)
|
||||
|
|
@ -34,12 +32,10 @@ def test_calls_entrypoints_creates_plugins_automaticaly(entry_points_mck):
|
|||
@mock.patch.object(importlib_metadata, 'entry_points')
|
||||
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),
|
||||
],
|
||||
}
|
||||
entry_points_mck.return_value = [
|
||||
importlib_metadata.EntryPoint('T100', '', None),
|
||||
importlib_metadata.EntryPoint('T200', '', None),
|
||||
]
|
||||
plugin_mgr = manager.PluginManager(namespace='testing.entrypoints')
|
||||
plugins = [plugin_mgr.plugins[name] for name in plugin_mgr.names]
|
||||
|
||||
|
|
@ -49,7 +45,7 @@ def test_handles_mapping_functions_across_plugins(entry_points_mck):
|
|||
@mock.patch.object(importlib_metadata, 'entry_points')
|
||||
def test_local_plugins(entry_points_mck):
|
||||
"""Verify PluginManager can load given local plugins."""
|
||||
entry_points_mck.return_value = {}
|
||||
entry_points_mck.return_value = []
|
||||
plugin_mgr = manager.PluginManager(
|
||||
namespace='testing.entrypoints',
|
||||
local_plugins=['X = path.to:Plugin']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue