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:
Ian Stapleton Cordasco 2018-04-15 23:33:40 +00:00
commit 5221014947
3 changed files with 17 additions and 3 deletions

View file

@ -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"

View file

@ -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())