mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-25 04:44:31 +00:00
Hoist passing through sys.argv at the CLI layer
`flake8.main.cli.main()` is the primary entry point for the command-line implementation of flake8 (invoked via `__main__` or `console_scripts`). Therefore, it is reasonable for the entry point to be responsible for obtaining command line arguments from `sys.argv` there. Additionally, the contract for various argument parsing methods to be guaranteed a `List[str]`.
This commit is contained in:
parent
7708e5b4ab
commit
50ac2f7237
3 changed files with 21 additions and 7 deletions
|
|
@ -126,3 +126,13 @@ def test_bug_report_successful(capsys):
|
|||
out, err = capsys.readouterr()
|
||||
assert json.loads(out)
|
||||
assert err == ''
|
||||
|
||||
|
||||
def test_obtaining_args_from_sys_argv_when_not_explicity_provided(capsys):
|
||||
"""Test that arguments are obtained from 'sys.argv'."""
|
||||
with mock.patch('sys.argv', ['--help']):
|
||||
_call_main(None)
|
||||
|
||||
out, err = capsys.readouterr()
|
||||
assert out.startswith('usage: flake8 [options] file file ...\n')
|
||||
assert err == ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue