application: Ensure -h/--help is unknown during preliminary parsing

Now that the preliminary parser is being used, we can remove needing to
prune out `-h` and `--help` from the copied `args` list.
This commit is contained in:
Eric N. Vander Weele 2019-10-25 15:01:30 -04:00
parent 2260f5362e
commit b9c8c3e118
2 changed files with 14 additions and 8 deletions

View file

@ -129,14 +129,6 @@ class Application(object):
args.remove("--version")
except ValueError:
pass
try:
args.remove("--help")
except ValueError:
pass
try:
args.remove("-h")
except ValueError:
pass
return self.prelim_arg_parser.parse_known_args(args)

View file

@ -99,6 +99,20 @@ def test_prelim_opts_args(application):
assert args == ['--foo', 'src', 'setup.py', '--statistics']
def test_prelim_opts_ignore_help(application):
"""Verify -h/--help is not handled."""
# GIVEN
# WHEN
_, args = application.parse_preliminary_options_and_args([
'--help',
'-h',
])
# THEN
assert args == ['--help', '-h']
def test_prelim_opts_handles_empty(application):
"""Verify empty argv lists are handled correctly."""
irrelevant_args = ['myexe', '/path/to/foo']