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

@ -7,8 +7,8 @@ from flake8.formatting import default
def options(**kwargs):
"""Create an argparse.Namespace instance."""
kwargs.setdefault('output_file', None)
kwargs.setdefault('tee', False)
kwargs.setdefault("output_file", None)
kwargs.setdefault("tee", False)
return argparse.Namespace(**kwargs)
@ -18,22 +18,23 @@ def test_caches_filenames_already_printed():
assert formatter.filenames_already_printed == set()
formatter.format(
style_guide.Violation('code', 'file.py', 1, 1, 'text', 'l'))
assert formatter.filenames_already_printed == {'file.py'}
style_guide.Violation("code", "file.py", 1, 1, "text", "l")
)
assert formatter.filenames_already_printed == {"file.py"}
def test_only_returns_a_string_once_from_format():
"""Verify format ignores the second error with the same filename."""
formatter = default.FilenameOnly(options())
error = style_guide.Violation('code', 'file.py', 1, 1, 'text', '1')
error = style_guide.Violation("code", "file.py", 1, 1, "text", "1")
assert formatter.format(error) == 'file.py'
assert formatter.format(error) == "file.py"
assert formatter.format(error) is None
def test_show_source_returns_nothing():
"""Verify show_source returns nothing."""
formatter = default.FilenameOnly(options())
error = style_guide.Violation('code', 'file.py', 1, 1, 'text', '1')
error = style_guide.Violation("code", "file.py", 1, 1, "text", "1")
assert formatter.show_source(error) is None