mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 13:06:53 +00:00
eliminate --bug-report double-parse quirk with store_true
This commit is contained in:
parent
03b33b9573
commit
52fb518104
5 changed files with 12 additions and 88 deletions
|
|
@ -7,11 +7,6 @@ from flake8.main import debug
|
|||
from flake8.options import manager
|
||||
|
||||
|
||||
def test_dependencies():
|
||||
"""Verify that we format our dependencies appropriately."""
|
||||
assert [] == debug.dependencies()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"plugins, expected",
|
||||
[
|
||||
|
|
@ -75,7 +70,6 @@ def test_information(system, pyversion, pyimpl):
|
|||
{"plugin": "mccabe", "version": "0.5.9", "is_local": False},
|
||||
{"plugin": "pycodestyle", "version": "2.0.0", "is_local": False},
|
||||
],
|
||||
"dependencies": [],
|
||||
"platform": {
|
||||
"python_implementation": "CPython",
|
||||
"python_version": "3.5.3",
|
||||
|
|
@ -93,42 +87,3 @@ def test_information(system, pyversion, pyimpl):
|
|||
pyimpl.assert_called_once_with()
|
||||
pyversion.assert_called_once_with()
|
||||
system.assert_called_once_with()
|
||||
|
||||
|
||||
@mock.patch("flake8.main.debug.print")
|
||||
@mock.patch("flake8.main.debug.information", return_value={})
|
||||
@mock.patch("json.dumps", return_value="{}")
|
||||
def test_print_information_no_plugins(dumps, information, print_mock):
|
||||
"""Verify we print and exit only when we have plugins."""
|
||||
option_manager = mock.Mock(registered_plugins=set())
|
||||
action = debug.DebugAction(
|
||||
"--bug-report",
|
||||
dest="bug_report",
|
||||
option_manager=option_manager,
|
||||
)
|
||||
assert action(None, None, None, None) is None
|
||||
assert dumps.called is False
|
||||
assert information.called is False
|
||||
assert print_mock.called is False
|
||||
|
||||
|
||||
@mock.patch("flake8.main.debug.print")
|
||||
@mock.patch("flake8.main.debug.information", return_value={})
|
||||
@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 = [
|
||||
manager.PluginVersion("pycodestyle", "2.0.0", False),
|
||||
manager.PluginVersion("mccabe", "0.5.9", False),
|
||||
]
|
||||
option_manager = mock.Mock(registered_plugins=set(plugins))
|
||||
action = debug.DebugAction(
|
||||
"--bug-report",
|
||||
dest="bug_report",
|
||||
option_manager=option_manager,
|
||||
)
|
||||
with pytest.raises(SystemExit):
|
||||
action(None, None, None, None)
|
||||
print_mock.assert_called_once_with("{}")
|
||||
dumps.assert_called_once_with({}, indent=2, sort_keys=True)
|
||||
information.assert_called_once_with(option_manager)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue