mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-04 20:26:53 +00:00
Add test for the make_checkers method
This commit is contained in:
parent
102037788d
commit
e32476b671
2 changed files with 24 additions and 1 deletions
|
|
@ -349,7 +349,13 @@ class FileChecker(object):
|
|||
"""Report an error by storing it in the results list."""
|
||||
if error_code is None:
|
||||
error_code, text = text.split(' ', 1)
|
||||
physical_line = self.processor.line_for(line_number)
|
||||
|
||||
physical_line = ''
|
||||
# If we're recovering from a problem in _make_processor, we will not
|
||||
# have this attribute.
|
||||
if getattr(self, 'processor', None):
|
||||
physical_line = self.processor.line_for(line_number)
|
||||
|
||||
error = (error_code, line_number, column, text, physical_line)
|
||||
self.results.append(error)
|
||||
return error_code
|
||||
|
|
|
|||
|
|
@ -41,3 +41,20 @@ def test_multiprocessing_is_disabled():
|
|||
with mock.patch('flake8.checker.multiprocessing', None):
|
||||
manager = checker.Manager(style_guide, [], [])
|
||||
assert manager.jobs == 0
|
||||
|
||||
|
||||
def test_make_checkers():
|
||||
"""Verify that we create a list of FileChecker instances."""
|
||||
style_guide = style_guide_mock()
|
||||
files = ['file1', 'file2']
|
||||
with mock.patch('flake8.checker.multiprocessing', None):
|
||||
manager = checker.Manager(style_guide, files, [])
|
||||
|
||||
with mock.patch('flake8.utils.filenames_from') as filenames_from:
|
||||
filenames_from.side_effect = [['file1'], ['file2']]
|
||||
with mock.patch('flake8.utils.fnmatch', return_value=True):
|
||||
with mock.patch('flake8.processor.FileProcessor'):
|
||||
manager.make_checkers()
|
||||
|
||||
for file_checker in manager.checkers:
|
||||
assert file_checker.filename in files
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue