mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 21:16:54 +00:00
Merge branch 'file_not_found_error' into 'master'
Ensure that a not-found file produces an error Closes #600 See merge request pycqa/flake8!404
This commit is contained in:
commit
abfe59eb3a
3 changed files with 14 additions and 6 deletions
|
|
@ -86,6 +86,7 @@ class Manager(object):
|
||||||
self.options = style_guide.options
|
self.options = style_guide.options
|
||||||
self.checks = checker_plugins
|
self.checks = checker_plugins
|
||||||
self.jobs = self._job_count()
|
self.jobs = self._job_count()
|
||||||
|
self._all_checkers = [] # type: List[FileChecker]
|
||||||
self.checkers = [] # type: List[FileChecker]
|
self.checkers = [] # type: List[FileChecker]
|
||||||
self.statistics = {
|
self.statistics = {
|
||||||
"files": 0,
|
"files": 0,
|
||||||
|
|
@ -234,17 +235,15 @@ class Manager(object):
|
||||||
) or is_stdin
|
) or is_stdin
|
||||||
|
|
||||||
checks = self.checks.to_dictionary()
|
checks = self.checks.to_dictionary()
|
||||||
checkers = (
|
self._all_checkers = [
|
||||||
FileChecker(filename, checks, self.options)
|
FileChecker(filename, checks, self.options)
|
||||||
for argument in paths
|
for argument in paths
|
||||||
for filename in utils.filenames_from(
|
for filename in utils.filenames_from(
|
||||||
argument, self.is_path_excluded
|
argument, self.is_path_excluded
|
||||||
)
|
)
|
||||||
if should_create_file_checker(filename, argument)
|
if should_create_file_checker(filename, argument)
|
||||||
)
|
|
||||||
self.checkers = [
|
|
||||||
checker for checker in checkers if checker.should_process
|
|
||||||
]
|
]
|
||||||
|
self.checkers = [c for c in self._all_checkers if c.should_process]
|
||||||
LOG.info("Checking %d files", len(self.checkers))
|
LOG.info("Checking %d files", len(self.checkers))
|
||||||
|
|
||||||
def report(self):
|
def report(self):
|
||||||
|
|
@ -260,7 +259,7 @@ class Manager(object):
|
||||||
tuple(int, int)
|
tuple(int, int)
|
||||||
"""
|
"""
|
||||||
results_reported = results_found = 0
|
results_reported = results_found = 0
|
||||||
for checker in self.checkers:
|
for checker in self._all_checkers:
|
||||||
results = sorted(
|
results = sorted(
|
||||||
checker.results, key=lambda tup: (tup[1], tup[2])
|
checker.results, key=lambda tup: (tup[1], tup[2])
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ def test_report_order(results, expected_order):
|
||||||
# Create a placeholder manager without arguments or plugins
|
# Create a placeholder manager without arguments or plugins
|
||||||
# Just add one custom file checker which just provides the results
|
# Just add one custom file checker which just provides the results
|
||||||
manager = checker.Manager(style_guide, [], [])
|
manager = checker.Manager(style_guide, [], [])
|
||||||
manager.checkers = [file_checker]
|
manager.checkers = manager._all_checkers = [file_checker]
|
||||||
|
|
||||||
# _handle_results is the first place which gets the sorted result
|
# _handle_results is the first place which gets the sorted result
|
||||||
# Should something non-private be mocked instead?
|
# Should something non-private be mocked instead?
|
||||||
|
|
|
||||||
|
|
@ -218,3 +218,12 @@ ignore = F401
|
||||||
py_file.write_text(u"import os\n")
|
py_file.write_text(u"import os\n")
|
||||||
|
|
||||||
_call_main(["--isolated", "--config", str(config), str(py_file)], retv=1)
|
_call_main(["--isolated", "--config", str(config), str(py_file)], retv=1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_file_not_found(tmpdir, capsys):
|
||||||
|
"""Ensure that a not-found file / directory is an error."""
|
||||||
|
with tmpdir.as_cwd():
|
||||||
|
_call_main(["i-do-not-exist"], retv=1)
|
||||||
|
out, err = capsys.readouterr()
|
||||||
|
assert out.startswith("i-do-not-exist:0:1: E902")
|
||||||
|
assert err == ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue