summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Grainger <tagrain@gmail.com>2019-07-08 20:12:47 +0000
committerAnthony Sottile <asottile@umich.edu>2019-07-08 20:12:47 +0000
commit9ba6677c4ae4248b0f31d861a608db2efcc2679a (patch)
treedb73dbc99c0341846aad71fc47a5a59a633ca34b /tests
parent0d7247082efbe6e8189abd4eeb49a4ee3a128253 (diff)
downloadflake8-9ba6677c4ae4248b0f31d861a608db2efcc2679a.tar.gz
support extend-exclude Fixes #535
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/test_checker.py3
-rw-r--r--tests/integration/test_main.py16
-rw-r--r--tests/unit/test_checker_manager.py11
3 files changed, 22 insertions, 8 deletions
diff --git a/tests/integration/test_checker.py b/tests/integration/test_checker.py
index a17e5cd..ca3ed4f 100644
--- a/tests/integration/test_checker.py
+++ b/tests/integration/test_checker.py
@@ -206,8 +206,7 @@ def test_report_order(results, expected_order):
file_checker.results = results
file_checker.display_name = 'placeholder'
- style_guide = mock.Mock(spec=['options'])
- style_guide.processing_file = mock.MagicMock()
+ style_guide = mock.MagicMock(spec=['options', 'processing_file'])
# Create a placeholder manager without arguments or plugins
# Just add one custom file checker which just provides the results
diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py
index 43cc168..21fd9e0 100644
--- a/tests/integration/test_main.py
+++ b/tests/integration/test_main.py
@@ -60,6 +60,22 @@ t.py:2:1: F401 'sys' imported but unused
assert err == ''
+def test_extend_exclude(tmpdir, capsys):
+ """Ensure that `flake8 --extend-exclude` works."""
+ for d in ['project', 'vendor', 'legacy', '.git', '.tox', '.hg']:
+ tmpdir.mkdir(d).join('t.py').write('import os\nimport sys\n')
+
+ with tmpdir.as_cwd():
+ application.Application().run(['--extend-exclude=vendor,legacy'])
+
+ out, err = capsys.readouterr()
+ assert out == '''\
+./project/t.py:1:1: F401 'os' imported but unused
+./project/t.py:2:1: F401 'sys' imported but unused
+'''
+ assert err == ''
+
+
def test_malformed_per_file_ignores_error(tmpdir, capsys):
"""Test the error message for malformed `per-file-ignores`."""
setup_cfg = '''\
diff --git a/tests/unit/test_checker_manager.py b/tests/unit/test_checker_manager.py
index 50f4084..2a6998e 100644
--- a/tests/unit/test_checker_manager.py
+++ b/tests/unit/test_checker_manager.py
@@ -7,13 +7,12 @@ import pytest
from flake8 import checker
-def style_guide_mock(**kwargs):
+def style_guide_mock():
"""Create a mock StyleGuide object."""
- kwargs.setdefault('diff', False)
- kwargs.setdefault('jobs', '4')
- style_guide = mock.Mock()
- style_guide.options = mock.Mock(**kwargs)
- return style_guide
+ return mock.MagicMock(**{
+ 'options.diff': False,
+ 'options.jobs': '4',
+ })
def _parallel_checker_manager():