mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-01 03:26:52 +00:00
Merge branch '405-nonexisting-files' into 'master'
Resolve "flake8 does not generate error when given a non-existent file on the command line" Closes #405 See merge request pycqa/flake8!227
This commit is contained in:
commit
5221014947
3 changed files with 17 additions and 3 deletions
|
|
@ -210,7 +210,6 @@ class Manager(object):
|
|||
filename, filename_patterns
|
||||
)
|
||||
is_stdin = filename == '-'
|
||||
file_exists = os.path.exists(filename)
|
||||
# NOTE(sigmavirus24): If a user explicitly specifies something,
|
||||
# e.g, ``flake8 bin/script`` then we should run Flake8 against
|
||||
# that. Since should_create_file_checker looks to see if the
|
||||
|
|
@ -221,8 +220,7 @@ class Manager(object):
|
|||
explicitly_provided = (not running_from_vcs and
|
||||
not running_from_diff and
|
||||
(argument == filename))
|
||||
return ((file_exists and
|
||||
(explicitly_provided or matches_filename_patterns)) or
|
||||
return ((explicitly_provided or matches_filename_patterns) or
|
||||
is_stdin)
|
||||
|
||||
checks = self.checks.to_dictionary()
|
||||
|
|
|
|||
|
|
@ -32,3 +32,14 @@ def test_repr(*args):
|
|||
'example.py', checks={}, options=object(),
|
||||
)
|
||||
assert repr(file_checker) == 'FileChecker for example.py'
|
||||
|
||||
|
||||
def test_nonexistent_file():
|
||||
"""Verify that checking non-existent file results in an error."""
|
||||
c = checker.FileChecker("foobar.py", checks={}, options=object())
|
||||
|
||||
assert c.processor is None
|
||||
assert not c.should_process
|
||||
assert len(c.results) == 1
|
||||
error = c.results[0]
|
||||
assert error[0] == "E902"
|
||||
|
|
|
|||
|
|
@ -321,3 +321,8 @@ def test_log_token(token, log_string):
|
|||
def test_count_parentheses(current_count, token_text, expected):
|
||||
"""Verify our arithmetic is correct."""
|
||||
assert processor.count_parentheses(current_count, token_text) == expected
|
||||
|
||||
|
||||
def test_nonexistent_file():
|
||||
with pytest.raises(IOError):
|
||||
processor.FileProcessor("foobar.py", options_from())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue