diff options
-rw-r--r-- | tests/test_cmd2.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 91e0d08a..9be1158b 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -293,6 +293,16 @@ def test_base_load_with_empty_args(base_app, capsys): assert normalize(str(err)) == expected +def test_base_load_with_nonexistent_file(base_app, capsys): + # The way the load command works, we can't directly capture its stdout or stderr + run_cmd(base_app, 'load does_not_exist.txt') + out, err = capsys.readouterr() + + # The load command requires a path to an existing file + assert str(err).startswith("ERROR") + assert "does not exist or is not a file" in str(err) + + def test_base_relative_load(base_app, request): test_dir = os.path.dirname(request.module.__file__) filename = os.path.join(test_dir, 'script.txt') @@ -458,10 +468,10 @@ now: True def test_base_debug(base_app, capsys): - # Try to load a non-existent file with debug set to False by default - run_cmd(base_app, 'load does_not_exist.txt') + # Try to set a non-existent parameter with debug set to False by default + run_cmd(base_app, 'set does_not_exist 5') out, err = capsys.readouterr() - assert err.startswith('ERROR') + assert err.startswith('EXCEPTION') # Set debug true out = run_cmd(base_app, 'set debug True') @@ -472,7 +482,7 @@ now: True assert out == expected # Verify that we now see the exception traceback - run_cmd(base_app, 'load does_not_exist.txt') + run_cmd(base_app, 'set does_not_exist 5') out, err = capsys.readouterr() assert str(err).startswith('Traceback (most recent call last):') |