summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-01-30 09:50:48 -0800
committerAnthony Sottile <asottile@umich.edu>2019-01-30 09:54:13 -0800
commit915184a1e93cb2c9de2c651c8e44a02a6cc956dc (patch)
treedd64e857612b1f128869f2957bc07425e23ba6ee /tests/integration
parent763f68b6233380105cc2ae6565ce955ba7de6b8e (diff)
downloadflake8-915184a1e93cb2c9de2c651c8e44a02a6cc956dc.tar.gz
Add integration test for `flake8 --diff`
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/test_main.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py
new file mode 100644
index 0000000..d67cf86
--- /dev/null
+++ b/tests/integration/test_main.py
@@ -0,0 +1,43 @@
+"""Integration tests for the main entrypoint of flake8."""
+import mock
+
+from flake8 import utils
+from flake8.main import application
+
+
+def test_diff_option(tmpdir, capsys):
+ """Ensure that FileChecker can handle --diff."""
+ t_py_contents = '''\
+import os
+import sys # unused but not part of diff
+
+print('(to avoid trailing whitespace in test)')
+print('(to avoid trailing whitespace in test)')
+print(os.path.join('foo', 'bar'))
+
+y # part of the diff and an error
+'''
+
+ diff = '''\
+diff --git a/t.py b/t.py
+index d64ac39..7d943de 100644
+--- a/t.py
++++ b/t.py
+@@ -4,3 +4,5 @@ import sys # unused but not part of diff
+ print('(to avoid trailing whitespace in test)')
+ print('(to avoid trailing whitespace in test)')
+ print(os.path.join('foo', 'bar'))
++
++y # part of the diff and an error
+'''
+
+ with mock.patch.object(utils, 'stdin_get_value', return_value=diff):
+ with tmpdir.as_cwd():
+ tmpdir.join('t.py').write(t_py_contents)
+
+ app = application.Application()
+ app.run(['--diff'])
+
+ out, err = capsys.readouterr()
+ assert out == "t.py:8:1: F821 undefined name 'y'\n"
+ assert err == ''