summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2020-09-12 11:56:37 -0700
committerAnthony Sottile <asottile@umich.edu>2020-09-12 12:03:23 -0700
commitee9c2874a9a5cb886060635c9b1aeec16bbc9e55 (patch)
treea92a14a652773680b2a2c45741e47a8b57bf92ab /tests
parent2c64d3ec5ab3ad40dc3e7c10ee0d7fa22f94560d (diff)
downloadflake8-ee9c2874a9a5cb886060635c9b1aeec16bbc9e55.tar.gz
fix skipping of physical checks when file does not end in newline
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/test_main.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py
index ce8ad13..69cb12b 100644
--- a/tests/integration/test_main.py
+++ b/tests/integration/test_main.py
@@ -212,6 +212,37 @@ x = """
assert out == err == ''
+def test_physical_line_file_not_ending_in_newline(tmpdir, capsys):
+ """See https://github.com/PyCQA/pycodestyle/issues/960."""
+ t_py_src = 'def f():\n\tpass'
+
+ with tmpdir.as_cwd():
+ tmpdir.join('t.py').write(t_py_src)
+ _call_main(['t.py'], retv=1)
+
+ out, err = capsys.readouterr()
+ assert out == '''\
+t.py:2:1: W191 indentation contains tabs
+t.py:2:6: W292 no newline at end of file
+'''
+
+
+@pytest.mark.xfail(strict=True) # currently awaiting fix in pycodestyle
+def test_physical_line_file_not_ending_in_newline_trailing_ws(tmpdir, capsys):
+ """See https://github.com/PyCQA/pycodestyle/issues/960."""
+ t_py_src = 'x = 1 '
+
+ with tmpdir.as_cwd():
+ tmpdir.join('t.py').write(t_py_src)
+ _call_main(['t.py'], retv=1)
+
+ out, err = capsys.readouterr()
+ assert out == '''\
+t.py:1:6: W291 trailing whitespace
+t.py:1:10: W292 no newline at end of file
+'''
+
+
def test_obtaining_args_from_sys_argv_when_not_explicity_provided(capsys):
"""Test that arguments are obtained from 'sys.argv'."""
with mock.patch('sys.argv', ['flake8', '--help']):