summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIan Stapleton Cordasco <graffatcolmingov@gmail.com>2018-04-15 23:33:40 +0000
committerIan Stapleton Cordasco <graffatcolmingov@gmail.com>2018-04-15 23:33:40 +0000
commit52210149474a876c06922ae2c296445af5bdb108 (patch)
tree525b9a96434c238975bbda01a545c70e066b8e54 /tests
parentf05c01b3ff79728a7f7a76105f08cf853c8546c3 (diff)
parent59218ca3232fe7e9c9fe9a949b8edb6f02b8ec10 (diff)
downloadflake8-52210149474a876c06922ae2c296445af5bdb108.tar.gz
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
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_file_checker.py11
-rw-r--r--tests/unit/test_file_processor.py5
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit/test_file_checker.py b/tests/unit/test_file_checker.py
index a0918b4..4ca6154 100644
--- a/tests/unit/test_file_checker.py
+++ b/tests/unit/test_file_checker.py
@@ -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"
diff --git a/tests/unit/test_file_processor.py b/tests/unit/test_file_processor.py
index 736d21e..a628cfd 100644
--- a/tests/unit/test_file_processor.py
+++ b/tests/unit/test_file_processor.py
@@ -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())