summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-07-16 10:07:19 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2016-07-16 10:07:19 -0500
commit73be9b0e90b187dd7e9533cdd0c287a3d40cb1ec (patch)
tree7fa7023da26d3f1fdf7763678bcde970a46c9629 /tests/unit
parent43df3ecf745f2d1a00cdfdf98df5399efb440e9a (diff)
downloadflake8-73be9b0e90b187dd7e9533cdd0c287a3d40cb1ec.tar.gz
Add OptionManager#parse_known_args
If a user specified `--max-complexity` on the command-line, they would be told that it did not exist. The same would be true of any option provided by a plugin. This is because we parse the command-line arguments twice in Flake8 -- the first time to specify the verbosity and destination for logging, the second time to actually execute Flake8. Since plugin options are not registered to start with the first time, they are not valid options. So when we first parse the options, we should only attempt to parse the ones which we know about. Closes #168
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_option_manager.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/unit/test_option_manager.py b/tests/unit/test_option_manager.py
index 6f6cb17..661b445 100644
--- a/tests/unit/test_option_manager.py
+++ b/tests/unit/test_option_manager.py
@@ -2,6 +2,7 @@
import optparse
import os
+import mock
import pytest
from flake8 import utils
@@ -194,3 +195,11 @@ def test_extend_default_ignore(optmanager):
assert optmanager.extended_default_ignore == set(['T100',
'T101',
'T102'])
+
+
+def test_parse_known_args(optmanager):
+ """Verify we ignore unknown options."""
+ with mock.patch('sys.exit') as sysexit:
+ optmanager.parse_known_args(['--max-complexity', '5'])
+
+ assert sysexit.called is False