break type checking cycles

This commit is contained in:
Anthony Sottile 2022-01-05 13:36:22 -05:00
parent f6267dd4d7
commit fa4c31fb97
10 changed files with 142 additions and 150 deletions

View file

@ -1,8 +1,8 @@
"""Tests for the FilenameOnly formatter object."""
import argparse
from flake8 import style_guide
from flake8.formatting import default
from flake8.violation import Violation
def options(**kwargs):
@ -18,16 +18,14 @@ def test_caches_filenames_already_printed():
formatter = default.FilenameOnly(options())
assert formatter.filenames_already_printed == set()
formatter.format(
style_guide.Violation("code", "file.py", 1, 1, "text", "l")
)
formatter.format(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 = Violation("code", "file.py", 1, 1, "text", "1")
assert formatter.format(error) == "file.py"
assert formatter.format(error) is None
@ -36,6 +34,6 @@ def test_only_returns_a_string_once_from_format():
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 = Violation("code", "file.py", 1, 1, "text", "1")
assert formatter.show_source(error) is None