Fix --output-file regression

This commit is contained in:
Anthony Sottile 2020-05-11 18:26:34 -07:00
parent b4d2850192
commit 4888eb65c5
5 changed files with 29 additions and 25 deletions

View file

@ -79,28 +79,22 @@ def test_returns_specified_plugin(application):
def test_prelim_opts_args(application):
"""Verify we get sensible prelim opts and args."""
opts, args = application.parse_preliminary_options(
opts = application.parse_preliminary_options(
['--foo', '--verbose', 'src', 'setup.py', '--statistics', '--version'])
assert opts.verbose
assert args == ['--foo', 'src', 'setup.py', '--statistics', '--version']
def test_prelim_opts_ignore_help(application):
"""Verify -h/--help is not handled."""
# GIVEN
# WHEN
_, args = application.parse_preliminary_options(['--help', '-h'])
# THEN
assert args == ['--help', '-h']
# normally argparse would `SystemExit` on `--help`
application.parse_preliminary_options(['--help', '-h'])
def test_prelim_opts_handles_empty(application):
"""Verify empty argv lists are handled correctly."""
irrelevant_args = ['myexe', '/path/to/foo']
# this would set `.verbose` but we validate that it does not
irrelevant_args = ['--verbose']
with mock.patch.object(sys, 'argv', irrelevant_args):
opts, args = application.parse_preliminary_options([])
assert args == []
opts = application.parse_preliminary_options([])
assert not opts.verbose

View file

@ -19,7 +19,7 @@ def test_get_style_guide():
verbose=0,
)
mockedapp = mock.Mock()
mockedapp.parse_preliminary_options.return_value = (prelim_opts, [])
mockedapp.parse_preliminary_options.return_value = prelim_opts
mockedapp.program = 'flake8'
with mock.patch('flake8.api.legacy.config.ConfigFileFinder') as mock_config_finder: # noqa: E501
config_finder = ConfigFileFinder(mockedapp.program)