diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-07-12 12:42:04 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-07-12 12:42:04 -0400 |
commit | 9bb6b84608b6262d228c021c7115e1389eed33e3 (patch) | |
tree | fe47cc9b863fd6ed0a76196dd4f27e51fdc3eb6f /tests/test_argparse_custom.py | |
parent | 98dd8cf6a5e03e33a383c64bff4ff4b1bf2804cf (diff) | |
download | cmd2-git-9bb6b84608b6262d228c021c7115e1389eed33e3.tar.gz |
Renamed Cmd2ArgParser to ArgParser
Diffstat (limited to 'tests/test_argparse_custom.py')
-rw-r--r-- | tests/test_argparse_custom.py | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/tests/test_argparse_custom.py b/tests/test_argparse_custom.py index 35d97974..b738efa3 100644 --- a/tests/test_argparse_custom.py +++ b/tests/test_argparse_custom.py @@ -7,7 +7,6 @@ import argparse import pytest import cmd2 -from cmd2.argparse_custom import Cmd2ArgParser from .conftest import run_cmd @@ -16,7 +15,7 @@ class ApCustomTestApp(cmd2.Cmd): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - range_parser = Cmd2ArgParser() + range_parser = cmd2.ArgParser() range_parser.add_argument('--arg1', nargs=(2, 3)) range_parser.add_argument('--arg2', nargs=argparse.ZERO_OR_MORE) range_parser.add_argument('--arg3', nargs=argparse.ONE_OR_MORE) @@ -47,7 +46,7 @@ def fake_func(): ({'choices_method': fake_func, 'completer_method': fake_func}, False), ]) def test_apcustom_invalid_args(args, is_valid): - parser = Cmd2ArgParser(prog='test') + parser = cmd2.ArgParser(prog='test') try: parser.add_argument('name', **args) assert is_valid @@ -58,7 +57,7 @@ def test_apcustom_invalid_args(args, is_valid): def test_apcustom_usage(): usage = "A custom usage statement" - parser = Cmd2ArgParser(usage=usage) + parser = cmd2.ArgParser(usage=usage) help = parser.format_help() assert usage in help @@ -76,46 +75,46 @@ def test_apcustom_nargs_not_enough(cust_app): def test_apcustom_narg_empty_tuple(): with pytest.raises(ValueError) as excinfo: - parser = Cmd2ArgParser(prog='test') + parser = cmd2.ArgParser(prog='test') parser.add_argument('invalid_tuple', nargs=()) assert 'Ranged values for nargs must be a tuple of 2 integers' in str(excinfo.value) def test_apcustom_narg_single_tuple(): with pytest.raises(ValueError) as excinfo: - parser = Cmd2ArgParser(prog='test') + parser = cmd2.ArgParser(prog='test') parser.add_argument('invalid_tuple', nargs=(1,)) assert 'Ranged values for nargs must be a tuple of 2 integers' in str(excinfo.value) def test_apcustom_narg_tuple_triple(): with pytest.raises(ValueError) as excinfo: - parser = Cmd2ArgParser(prog='test') + parser = cmd2.ArgParser(prog='test') parser.add_argument('invalid_tuple', nargs=(1, 2, 3)) assert 'Ranged values for nargs must be a tuple of 2 integers' in str(excinfo.value) def test_apcustom_narg_tuple_order(): with pytest.raises(ValueError) as excinfo: - parser = Cmd2ArgParser(prog='test') + parser = cmd2.ArgParser(prog='test') 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 = Cmd2ArgParser(prog='test') + parser = cmd2.ArgParser(prog='test') parser.add_argument('invalid_tuple', nargs=(-1, 1)) assert 'Negative numbers are invalid for nargs range' in str(excinfo.value) def test_apcustom_narg_tuple_zero_base(): - parser = Cmd2ArgParser(prog='test') + parser = cmd2.ArgParser(prog='test') parser.add_argument('tuple', nargs=(0, 3)) def test_apcustom_narg_tuple_zero_to_one(): - parser = Cmd2ArgParser(prog='test') + parser = cmd2.ArgParser(prog='test') parser.add_argument('tuple', nargs=(0, 1)) @@ -124,13 +123,13 @@ def test_apcustom_print_message(capsys): test_message = 'The test message' # Specify the file - parser = Cmd2ArgParser(prog='test') + parser = cmd2.ArgParser(prog='test') 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 = Cmd2ArgParser(prog='test') + parser = cmd2.ArgParser(prog='test') parser._print_message(test_message) out, err = capsys.readouterr() assert test_message in err @@ -138,7 +137,7 @@ def test_apcustom_print_message(capsys): def test_apcustom_required_options(): # Make sure a 'required arguments' section shows when a flag is marked required - parser = Cmd2ArgParser(prog='test') + parser = cmd2.ArgParser(prog='test') parser.add_argument('--required_flag', required=True) help = parser.format_help() |