mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-09 22:34:17 +00:00
application: Return namespace and args from preliminary arg parsing
This is the initial step towards removing state from the `Application` object during argument parsing and handling. The goal is to remove `Application.prelim_opts` and `Application.prelim_args`.
This commit is contained in:
parent
6bae5f7ef6
commit
6043e90855
2 changed files with 13 additions and 4 deletions
|
|
@ -92,18 +92,22 @@ def test_returns_specified_plugin(application):
|
|||
|
||||
def test_prelim_opts_args(application):
|
||||
"""Verify we get sensible prelim opts and args."""
|
||||
application.parse_preliminary_options_and_args(
|
||||
opts, args = application.parse_preliminary_options_and_args(
|
||||
['flake8', '--foo', '--verbose', 'src', 'setup.py', '--statistics'])
|
||||
|
||||
assert application.prelim_opts.statistics
|
||||
assert application.prelim_opts.verbose
|
||||
assert application.prelim_args == ['src', 'setup.py']
|
||||
assert opts.statistics is application.prelim_opts.statistics
|
||||
assert opts.verbose is application.prelim_opts.verbose
|
||||
assert args is application.prelim_args
|
||||
|
||||
|
||||
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([])
|
||||
opts, args = application.parse_preliminary_options_and_args([])
|
||||
|
||||
assert application.prelim_args == []
|
||||
assert args is application.prelim_args
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue