diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-27 01:40:57 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-27 01:40:57 -0400 |
commit | 1b2545798373c3416d482c0e3c8cf11f62606624 (patch) | |
tree | 85a85dcaa25f63709cd2bcf4c12765b0a858889a /tests | |
parent | 4e949387d6424b3f3d860c9fe0890d83acd58d09 (diff) | |
parent | 24ab916bef3c082935ed9d1329d7941a5d0efbfa (diff) | |
download | cmd2-git-1b2545798373c3416d482c0e3c8cf11f62606624.tar.gz |
Merge branch 'macro' into argparse_conversion
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cmd2.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 5ee0d26b..707fce49 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -1992,9 +1992,19 @@ def test_macro_create_with_invalid_arg_num(base_app, capsys): out, err = capsys.readouterr() assert "Argument numbers must be greater than 0" in err +def test_macro_create_with_wrong_arg_count(base_app, capsys): + # Create the macro + out = run_cmd(base_app, 'macro create fake help {1} {2}') + assert out == normalize("Macro 'fake' created") + + # Run the macro + run_cmd(base_app, 'fake arg1') + out, err = capsys.readouterr() + assert "expects 2 argument(s)" in err + def test_macro_list_invalid_macro(base_app, capsys): # Look up invalid macro - out = run_cmd(base_app, 'macro list invalid') + run_cmd(base_app, 'macro list invalid') out, err = capsys.readouterr() assert "Macro 'invalid' not found" in err @@ -2032,6 +2042,17 @@ def test_multiple_macros(base_app): expected = normalize(BASE_HELP_VERBOSE) assert out == expected +def test_nonexistent_macro(base_app, capsys): + from cmd2.parsing import StatementParser + exception = None + + try: + base_app._run_macro(StatementParser().parse('fake')) + except KeyError as e: + exception = e + + assert exception is not None + def test_ppaged(base_app): msg = 'testing...' |