mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-08 22:04:17 +00:00
Update our plugin registration for debugging
This allows us to report whether or not a plugin is local when users provide `flake8 --bug-report` output.
This commit is contained in:
parent
d5dfd1180d
commit
156f90369f
6 changed files with 65 additions and 48 deletions
|
|
@ -4,6 +4,7 @@ import pytest
|
|||
import setuptools
|
||||
|
||||
from flake8.main import debug
|
||||
from flake8.options import manager
|
||||
|
||||
|
||||
def test_dependencies():
|
||||
|
|
@ -15,11 +16,18 @@ def test_dependencies():
|
|||
|
||||
@pytest.mark.parametrize('plugins, expected', [
|
||||
([], []),
|
||||
([('pycodestyle', '2.0.0')], [{'plugin': 'pycodestyle',
|
||||
'version': '2.0.0'}]),
|
||||
([('pycodestyle', '2.0.0'), ('mccabe', '0.5.9')],
|
||||
[{'plugin': 'mccabe', 'version': '0.5.9'},
|
||||
{'plugin': 'pycodestyle', 'version': '2.0.0'}]),
|
||||
([manager.PluginVersion('pycodestyle', '2.0.0', False)],
|
||||
[{'plugin': 'pycodestyle', 'version': '2.0.0', 'is_local': False}]),
|
||||
([manager.PluginVersion('pycodestyle', '2.0.0', False),
|
||||
manager.PluginVersion('mccabe', '0.5.9', False)],
|
||||
[{'plugin': 'mccabe', 'version': '0.5.9', 'is_local': False},
|
||||
{'plugin': 'pycodestyle', 'version': '2.0.0', 'is_local': False}]),
|
||||
([manager.PluginVersion('pycodestyle', '2.0.0', False),
|
||||
manager.PluginVersion('my-local', '0.0.1', True),
|
||||
manager.PluginVersion('mccabe', '0.5.9', False)],
|
||||
[{'plugin': 'mccabe', 'version': '0.5.9', 'is_local': False},
|
||||
{'plugin': 'my-local', 'version': '0.0.1', 'is_local': True},
|
||||
{'plugin': 'pycodestyle', 'version': '2.0.0', 'is_local': False}]),
|
||||
])
|
||||
def test_plugins_from(plugins, expected):
|
||||
"""Test that we format plugins appropriately."""
|
||||
|
|
@ -34,8 +42,10 @@ def test_information(system, pyversion, pyimpl):
|
|||
"""Verify that we return all the information we care about."""
|
||||
expected = {
|
||||
'version': '3.1.0',
|
||||
'plugins': [{'plugin': 'mccabe', 'version': '0.5.9'},
|
||||
{'plugin': 'pycodestyle', 'version': '2.0.0'}],
|
||||
'plugins': [{'plugin': 'mccabe', 'version': '0.5.9',
|
||||
'is_local': False},
|
||||
{'plugin': 'pycodestyle', 'version': '2.0.0',
|
||||
'is_local': False}],
|
||||
'dependencies': [{'dependency': 'setuptools',
|
||||
'version': setuptools.__version__}],
|
||||
'platform': {
|
||||
|
|
@ -45,8 +55,10 @@ def test_information(system, pyversion, pyimpl):
|
|||
},
|
||||
}
|
||||
option_manager = mock.Mock(
|
||||
registered_plugins={('pycodestyle', '2.0.0'),
|
||||
('mccabe', '0.5.9')},
|
||||
registered_plugins={
|
||||
manager.PluginVersion('pycodestyle', '2.0.0', False),
|
||||
manager.PluginVersion('mccabe', '0.5.9', False),
|
||||
},
|
||||
version='3.1.0',
|
||||
)
|
||||
assert expected == debug.information(option_manager)
|
||||
|
|
@ -75,7 +87,10 @@ def test_print_information_no_plugins(dumps, information, print_mock):
|
|||
@mock.patch('json.dumps', return_value='{}')
|
||||
def test_print_information(dumps, information, print_mock):
|
||||
"""Verify we print and exit only when we have plugins."""
|
||||
plugins = [('pycodestyle', '2.0.0'), ('mccabe', '0.5.9')]
|
||||
plugins = [
|
||||
manager.PluginVersion('pycodestyle', '2.0.0', False),
|
||||
manager.PluginVersion('mccabe', '0.5.9', False),
|
||||
]
|
||||
option_manager = mock.Mock(registered_plugins=set(plugins))
|
||||
with pytest.raises(SystemExit):
|
||||
debug.print_information(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue