diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-10-30 23:28:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-30 23:28:02 -0400 |
commit | 245dc33730d2a27bc9744be7cf36f176f5a0c10a (patch) | |
tree | ba6cfaae945625c28934b38bf537f78a5040b567 /tests | |
parent | b1873c3e6a19276417e7b3a046b48db54a2d6304 (diff) | |
parent | 5a58199590f06996cc741063da29ffb166026ced (diff) | |
download | cmd2-git-245dc33730d2a27bc9744be7cf36f176f5a0c10a.tar.gz |
Merge pull request #796 from python-cmd2/set_prog
Recursively set parser.prog
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_argparse.py | 2 | ||||
-rw-r--r-- | tests/test_argparse_completer.py | 2 | ||||
-rw-r--r-- | tests/test_argparse_custom.py | 32 | ||||
-rwxr-xr-x | tests/test_completion.py | 2 |
4 files changed, 19 insertions, 19 deletions
diff --git a/tests/test_argparse.py b/tests/test_argparse.py index e5fa6dd0..21ec17e8 100644 --- a/tests/test_argparse.py +++ b/tests/test_argparse.py @@ -207,7 +207,7 @@ class SubcommandApp(cmd2.Cmd): self.poutput('((%s))' % args.z) # create the top-level parser for the base command - base_parser = argparse.ArgumentParser(prog='base') + base_parser = argparse.ArgumentParser() base_subparsers = base_parser.add_subparsers(title='subcommands', help='subcommand help') # create the parser for the "foo" subcommand diff --git a/tests/test_argparse_completer.py b/tests/test_argparse_completer.py index e54e49c2..b904a6ac 100644 --- a/tests/test_argparse_completer.py +++ b/tests/test_argparse_completer.py @@ -63,7 +63,7 @@ class AutoCompleteTester(cmd2.Cmd): # Begin code related to help and command name completion ############################################################################################################ # Top level parser for music command - music_parser = Cmd2ArgumentParser(description='Manage music', prog='music') + music_parser = Cmd2ArgumentParser(description='Manage music') # Add subcommands to music music_subparsers = music_parser.add_subparsers() diff --git a/tests/test_argparse_custom.py b/tests/test_argparse_custom.py index 99afe2dd..65cbc8da 100644 --- a/tests/test_argparse_custom.py +++ b/tests/test_argparse_custom.py @@ -49,7 +49,7 @@ def fake_func(): ({'completer_function': fake_func, 'completer_method': fake_func}, False), ]) def test_apcustom_choices_callable_count(kwargs, is_valid): - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() try: parser.add_argument('name', **kwargs) assert is_valid @@ -66,7 +66,7 @@ def test_apcustom_choices_callable_count(kwargs, is_valid): ]) def test_apcustom_no_choices_callables_alongside_choices(kwargs): with pytest.raises(TypeError) as excinfo: - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() parser.add_argument('name', choices=['my', 'choices', 'list'], **kwargs) assert 'None of the following parameters can be used alongside a choices parameter' in str(excinfo.value) @@ -79,7 +79,7 @@ def test_apcustom_no_choices_callables_alongside_choices(kwargs): ]) def test_apcustom_no_choices_callables_when_nargs_is_0(kwargs): with pytest.raises(TypeError) as excinfo: - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() parser.add_argument('name', action='store_true', **kwargs) assert 'None of the following parameters can be used on an action that takes no arguments' in str(excinfo.value) @@ -126,40 +126,40 @@ def test_apcustom_nargs_range_validation(cust_app): ]) def test_apcustom_narg_invalid_tuples(nargs_tuple): with pytest.raises(ValueError) as excinfo: - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() parser.add_argument('invalid_tuple', nargs=nargs_tuple) assert 'Ranged values for nargs must be a tuple of 1 or 2 integers' in str(excinfo.value) def test_apcustom_narg_tuple_order(): with pytest.raises(ValueError) as excinfo: - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() parser.add_argument('invalid_tuple', nargs=(2, 1)) assert 'Invalid nargs range. The first value must be less than the second' in str(excinfo.value) def test_apcustom_narg_tuple_negative(): with pytest.raises(ValueError) as excinfo: - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() parser.add_argument('invalid_tuple', nargs=(-1, 1)) assert 'Negative numbers are invalid for nargs range' in str(excinfo.value) # noinspection PyUnresolvedReferences def test_apcustom_narg_tuple_zero_base(): - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() arg = parser.add_argument('arg', nargs=(0,)) assert arg.nargs == argparse.ZERO_OR_MORE assert arg.nargs_range is None assert "[arg [...]]" in parser.format_help() - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() arg = parser.add_argument('arg', nargs=(0, 1)) assert arg.nargs == argparse.OPTIONAL assert arg.nargs_range is None assert "[arg]" in parser.format_help() - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() arg = parser.add_argument('arg', nargs=(0, 3)) assert arg.nargs == argparse.ZERO_OR_MORE assert arg.nargs_range == (0, 3) @@ -168,13 +168,13 @@ def test_apcustom_narg_tuple_zero_base(): # noinspection PyUnresolvedReferences def test_apcustom_narg_tuple_one_base(): - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() arg = parser.add_argument('arg', nargs=(1,)) assert arg.nargs == argparse.ONE_OR_MORE assert arg.nargs_range is None assert "arg [...]" in parser.format_help() - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() arg = parser.add_argument('arg', nargs=(1, 5)) assert arg.nargs == argparse.ONE_OR_MORE assert arg.nargs_range == (1, 5) @@ -185,13 +185,13 @@ def test_apcustom_narg_tuple_one_base(): def test_apcustom_narg_tuple_other_ranges(): # Test range with no upper bound on max - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() arg = parser.add_argument('arg', nargs=(2,)) assert arg.nargs == argparse.ONE_OR_MORE assert arg.nargs_range == (2, INFINITY) # Test finite range - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() arg = parser.add_argument('arg', nargs=(2, 5)) assert arg.nargs == argparse.ONE_OR_MORE assert arg.nargs_range == (2, 5) @@ -202,13 +202,13 @@ def test_apcustom_print_message(capsys): test_message = 'The test message' # Specify the file - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() parser._print_message(test_message, file=sys.stdout) out, err = capsys.readouterr() assert test_message in out # Make sure file defaults to sys.stderr - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() parser._print_message(test_message) out, err = capsys.readouterr() assert test_message in err @@ -239,6 +239,6 @@ def test_generate_range_error(): def test_apcustom_required_options(): # Make sure a 'required arguments' section shows when a flag is marked required - parser = Cmd2ArgumentParser(prog='test') + parser = Cmd2ArgumentParser() parser.add_argument('--required_flag', required=True) assert 'required arguments' in parser.format_help() diff --git a/tests/test_completion.py b/tests/test_completion.py index c7d9bd21..3b26b044 100755 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -1078,7 +1078,7 @@ class SubcommandsWithUnknownExample(cmd2.Cmd): self.poutput('Sport is {}'.format(args.sport)) # create the top-level parser for the base command - base_parser = argparse.ArgumentParser(prog='base') + base_parser = argparse.ArgumentParser() base_subparsers = base_parser.add_subparsers(title='subcommands', help='subcommand help') # create the parser for the "foo" subcommand |