summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Frye <charlesfrye@berkeley.edu>2019-03-07 20:27:59 -0800
committerCharles Frye <charlesfrye@berkeley.edu>2019-03-07 20:27:59 -0800
commit16ca17388ab4a8136617390329328e1a13219f84 (patch)
tree549993eb2a8fda683b7de627331d79efce8b71cf /tests
parent88caf5ac484f5c09aedc02167c59c66ff0af0068 (diff)
downloadflake8-16ca17388ab4a8136617390329328e1a13219f84.tar.gz
Fixes handling of empty lists by Application
`Application.parse_preliminary_options_and_args` was previously, against expectations, treating empty lists passed as the `argv` argument the same way it treated `None`s. This has been addressed and the correct behavior tested for in a unit test of the `Application` class. See issue #518 for details.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_application.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/unit/test_application.py b/tests/unit/test_application.py
index 5ec9f1f..875ed6e 100644
--- a/tests/unit/test_application.py
+++ b/tests/unit/test_application.py
@@ -1,5 +1,6 @@
"""Tests for the Application class."""
import optparse
+import sys
import mock
import pytest
@@ -97,3 +98,12 @@ def test_prelim_opts_args(application):
assert application.prelim_opts.statistics
assert application.prelim_opts.verbose
assert application.prelim_args == ['src', 'setup.py']
+
+
+def test_prelim_opts_handles_empty(application):
+ """Verify empty argv lists are handled correctly."""
+ irrelevant_args = ['myexe', '/path/to/foo']
+ with mock.patch.object(sys, 'argv', irrelevant_args):
+ application.parse_preliminary_options_and_args([])
+
+ assert application.prelim_args != irrelevant_args