extend black formatting to tests as well

This commit is contained in:
Anthony Sottile 2021-04-18 09:17:48 -07:00
parent a7174759e9
commit af1668bf04
45 changed files with 1644 additions and 1307 deletions

View file

@ -21,12 +21,14 @@ def test_get_style_guide():
)
mockedapp = mock.Mock()
mockedapp.parse_preliminary_options.return_value = (prelim_opts, [])
mockedapp.program = 'flake8'
with mock.patch('flake8.api.legacy.config.ConfigFileFinder') as mock_config_finder: # noqa: E501
mockedapp.program = "flake8"
with mock.patch(
"flake8.api.legacy.config.ConfigFileFinder"
) as mock_config_finder: # noqa: E501
config_finder = ConfigFileFinder(mockedapp.program)
mock_config_finder.return_value = config_finder
with mock.patch('flake8.main.application.Application') as application:
with mock.patch("flake8.main.application.Application") as application:
application.return_value = mockedapp
style_guide = api.get_style_guide()
@ -35,7 +37,8 @@ def test_get_style_guide():
mockedapp.find_plugins.assert_called_once_with(config_finder)
mockedapp.register_plugin_options.assert_called_once_with()
mockedapp.parse_configuration_and_cli.assert_called_once_with(
config_finder, [])
config_finder, []
)
mockedapp.make_formatter.assert_called_once_with()
mockedapp.make_guide.assert_called_once_with()
mockedapp.make_file_checker_manager.assert_called_once_with()
@ -45,22 +48,22 @@ def test_get_style_guide():
def test_styleguide_options():
"""Show that we proxy the StyleGuide.options attribute."""
app = mock.Mock()
app.options = 'options'
app.options = "options"
style_guide = api.StyleGuide(app)
assert style_guide.options == 'options'
assert style_guide.options == "options"
def test_styleguide_paths():
"""Show that we proxy the StyleGuide.paths attribute."""
app = mock.Mock()
app.paths = 'paths'
app.paths = "paths"
style_guide = api.StyleGuide(app)
assert style_guide.paths == 'paths'
assert style_guide.paths == "paths"
def test_styleguide_check_files():
"""Verify we call the right application methods."""
paths = ['foo', 'bar']
paths = ["foo", "bar"]
app = mock.Mock()
style_guide = api.StyleGuide(app)
report = style_guide.check_files(paths)
@ -80,8 +83,8 @@ def test_styleguide_excluded():
file_checker_manager = app.file_checker_manager = mock.Mock()
style_guide = api.StyleGuide(app)
style_guide.excluded('file.py')
file_checker_manager.is_path_excluded.assert_called_once_with('file.py')
style_guide.excluded("file.py")
file_checker_manager.is_path_excluded.assert_called_once_with("file.py")
def test_styleguide_excluded_with_parent():
@ -95,10 +98,10 @@ def test_styleguide_excluded_with_parent():
file_checker_manager.is_path_excluded.return_value = False
style_guide = api.StyleGuide(app)
style_guide.excluded('file.py', 'parent')
style_guide.excluded("file.py", "parent")
assert file_checker_manager.is_path_excluded.call_args_list == [
mock.call('file.py'),
mock.call(os.path.join('parent', 'file.py')),
mock.call("file.py"),
mock.call(os.path.join("parent", "file.py")),
]
@ -123,7 +126,7 @@ def test_styleguide_init_report_with_non_subclass():
def test_styleguide_init_report():
"""Verify we do the right incantation for the Application."""
app = mock.Mock(guide='fake')
app = mock.Mock(guide="fake")
style_guide = api.StyleGuide(app)
class FakeFormatter(formatter.BaseFormatter):
@ -140,16 +143,16 @@ def test_styleguide_input_file():
"""Verify we call StyleGuide.check_files with the filename."""
app = mock.Mock()
style_guide = api.StyleGuide(app)
with mock.patch.object(style_guide, 'check_files') as check_files:
style_guide.input_file('file.py')
check_files.assert_called_once_with(['file.py'])
with mock.patch.object(style_guide, "check_files") as check_files:
style_guide.input_file("file.py")
check_files.assert_called_once_with(["file.py"])
def test_report_total_errors():
"""Verify total errors is just a proxy attribute."""
app = mock.Mock(result_count='Fake count')
app = mock.Mock(result_count="Fake count")
report = api.Report(app)
assert report.total_errors == 'Fake count'
assert report.total_errors == "Fake count"
def test_report_get_statistics():
@ -160,5 +163,5 @@ def test_report_get_statistics():
app = mock.Mock(guide=style_guide)
report = api.Report(app)
assert report.get_statistics('E') == []
stats.statistics_for.assert_called_once_with('E')
assert report.get_statistics("E") == []
stats.statistics_for.assert_called_once_with("E")