Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: Allow optional arguments after file arguments in test_backend. #9455

Merged
merged 1 commit into from
May 18, 2018

Conversation

shubham-padia
Copy link
Member

@shubham-padia shubham-padia commented May 18, 2018

Fixes #9233.
Uses nargs='' instead of nargs='argparse.REMAINDER'.
nargs='argparse.REMAINDER' gathers remaining terms as arguments
even if it is an option e.g --coverage, while '
' gathers all the
command-line arguments until the next option is encountered.

From https://docs.python.org/3/library/argparse.html#nargs:

  • '*'. All command-line arguments present are gathered into a list.:
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--foo', nargs='*')
>>> parser.add_argument('--bar', nargs='*')
>>> parser.add_argument('baz', nargs='*')
>>> parser.parse_args('a b --foo x y --bar 1 2'.split())
Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y'])
  • argparse.REMAINDER. All the remaining command-line arguments are gathered into a list. This is commonly useful for command line utilities that dispatch to other command line utilities:
>>> parser = argparse.ArgumentParser(prog='PROG')
>>> parser.add_argument('--foo')
>>> parser.add_argument('command')
>>> parser.add_argument('args', nargs=argparse.REMAINDER)
>>> print(parser.parse_args('--foo B cmd --arg1 XX ZZ'.split()))
Namespace(args=['--arg1', 'XX', 'ZZ'], command='cmd', foo='B')

Fixes zulip#9233.
Uses nargs='*' instead of nargs='argparse.REMAINDER'.
nargs='argparse.REMAINDER' gathers remaining terms as arguments
even if it is an option e.g --coverage, while '*' gathers all the
command-line arguments until the next option is encountered.
@zulipbot
Copy link
Member

Hello @zulip/server-testing members, this pull request was labeled with the "area: testing-infrastructure" label, so you may want to check it out!

@timabbott
Copy link
Sponsor Member

Nice, merged, thanks @shubham-padia!

@timabbott timabbott closed this May 18, 2018
@timabbott timabbott merged commit 0824308 into zulip:master May 18, 2018
@shubham-padia shubham-padia deleted the tools_test_backend branch September 8, 2018 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants