diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-27 01:39:45 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-27 01:39:45 -0400 |
commit | 24ab916bef3c082935ed9d1329d7941a5d0efbfa (patch) | |
tree | 7f816314769c002059b17af3b02a447df01806ff /tests | |
parent | e60206b92e465b13cb4e4c9ac6a8a73da595a514 (diff) | |
download | cmd2-git-24ab916bef3c082935ed9d1329d7941a5d0efbfa.tar.gz |
More unit tests
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 c6578756..8a56bad3 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -1991,9 +1991,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 @@ -2031,6 +2041,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...' |