Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_bare_command_version(capsys):
"``briefcase create -V`` returns the version"
with pytest.raises(SystemExit) as excinfo:
parse_cmdline('create -V'.split())
# Normal exit due to displaying help
assert excinfo.value.code == 0
# Version is displayed.
output = capsys.readouterr().out
assert output == '{__version__}\n'.format(__version__=__version__)
def test_version_only(capsys):
"``briefcase -V`` returns current version"
with pytest.raises(SystemExit) as excinfo:
parse_cmdline('-V'.split())
# Normal exit due to displaying help
assert excinfo.value.code == 0
# Version is displayed.
output = capsys.readouterr().out
assert output == '{__version__}\n'.format(__version__=__version__)
description="Package Python code for distribution.",
usage="briefcase [-h] [] [] ...",
epilog="Each command, platform and format has additional options. "
"Use the -h option on a specific command for more details.",
add_help=False
)
parser.add_argument(
'-f', '--formats',
action='store_true',
dest='show_output_formats',
help="show the available output formats and exit (specify a platform for more details)."
)
parser.add_argument(
'-V', '--version',
action='version',
version=__version__
)
# isn't actually optional; but if it's marked as required,
# there's no way to get help for subcommands. So; treat
# as optional, handle the case where isn't provided
# as the case where top-level help is displayed, and provide an explicit
# usage string so that the instructions displayed are correct
parser.add_argument(
'command',
choices=[
'new', 'dev', 'create', 'update', 'build', 'run', 'package', 'publish'
],
metavar='command',
nargs='?',
help='the command to execute (one of: %(choices)s)',
)
def add_default_options(self, parser):
"""
Add the default options that exist on *all* commands
:param parser: a stub argparse parser for the command.
"""
parser.add_argument(
'-v', '--verbosity',
action='count',
default=1,
help="set the verbosity of output"
)
parser.add_argument(
'-V', '--version',
action='version',
version=__version__
)