summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/flake8/checker.py4
-rw-r--r--tests/unit/test_file_checker.py9
2 files changed, 13 insertions, 0 deletions
diff --git a/src/flake8/checker.py b/src/flake8/checker.py
index 863024b..569eafa 100644
--- a/src/flake8/checker.py
+++ b/src/flake8/checker.py
@@ -381,6 +381,10 @@ class FileChecker(object):
self.should_process = not self.processor.should_ignore_file()
self.statistics['physical lines'] = len(self.processor.lines)
+ def __repr__(self):
+ """Provide helpful debugging representation."""
+ return 'FileChecker for {}'.format(self.filename)
+
def _make_processor(self):
try:
return processor.FileProcessor(self.filename, self.options)
diff --git a/tests/unit/test_file_checker.py b/tests/unit/test_file_checker.py
index a2d33fc..28264d5 100644
--- a/tests/unit/test_file_checker.py
+++ b/tests/unit/test_file_checker.py
@@ -23,3 +23,12 @@ def test_run_ast_checks_handles_SyntaxErrors(FileProcessor):
'E999', 1, 3,
'SyntaxError: Failed to build ast',
)
+
+
+@mock.patch('flake8.checker.FileChecker._make_processor', return_value=None)
+def test_repr(*args):
+ """Verify we generate a correct repr."""
+ file_checker = checker.FileChecker(
+ 'example.py', checks={}, options=object(),
+ )
+ assert repr(file_checker) == 'FileChecker for example.py'