diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-07-11 02:40:26 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-07-11 02:40:26 -0400 |
commit | 969dab29bbaed194edce881d60643f5e95a02366 (patch) | |
tree | 5db01e9916dde5da64db004a6b063e406a545da2 /tests | |
parent | 6ddb6842e5ac87fb5c433eb8d86df48f3e045da2 (diff) | |
download | cmd2-git-969dab29bbaed194edce881d60643f5e95a02366.tar.gz |
Added --clear argument to history command
Added better error checking when loading readline history file
Improved some error messages
Changed IOError usages to OSError since they were merged in Python 3.3.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conftest.py | 7 | ||||
-rw-r--r-- | tests/test_cmd2.py | 10 |
2 files changed, 8 insertions, 9 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 90d45bd9..3f3b862e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -37,7 +37,7 @@ Documented commands (type help <topic>): alias Define or display aliases edit Edit a file in a text editor. help List available commands with "help" or detailed help with "help cmd". -history View, run, edit, and save previously entered commands. +history View, run, edit, save, or clear previously entered commands. load Runs commands in script file that is encoded as either ASCII or UTF-8 text. py Invoke python command, shell, or script pyscript Runs a python script file inside the console @@ -49,9 +49,9 @@ unalias Unsets aliases """ # Help text for the history command -HELP_HISTORY = """usage: history [-h] [-r | -e | -s | -o FILE | -t TRANSCRIPT] [arg] +HELP_HISTORY = """usage: history [-h] [-r | -e | -s | -o FILE | -t TRANSCRIPT | -c] [arg] -View, run, edit, and save previously entered commands. +View, run, edit, save, or clear previously entered commands. positional arguments: arg empty all history items @@ -69,6 +69,7 @@ optional arguments: output commands to a script file -t TRANSCRIPT, --transcript TRANSCRIPT output commands and results to a transcript file + -c, --clear clears all history """ # Output from the shortcuts command with default built-in shortcuts diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 77dcc875..7b0b93a6 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -231,7 +231,7 @@ def test_pyscript_with_nonexist_file(base_app, capsys): python_script = 'does_not_exist.py' run_cmd(base_app, "pyscript {}".format(python_script)) out, err = capsys.readouterr() - assert err.startswith("EXCEPTION of type 'FileNotFoundError' occurred with message:") + assert "Error opening script file" in err def test_pyscript_with_exception(base_app, capsys, request): test_dir = os.path.dirname(request.module.__file__) @@ -457,8 +457,7 @@ def test_load_with_empty_args(base_app, capsys): out, err = capsys.readouterr() # The load command requires a file path argument, so we should get an error message - expected = normalize("""ERROR: load command requires a file path:\n""") - assert normalize(str(err)) == expected + assert "load command requires a file path" in str(err) assert base_app.cmdqueue == [] @@ -468,8 +467,7 @@ def test_load_with_nonexistent_file(base_app, capsys): 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) + assert "does not exist" in str(err) assert base_app.cmdqueue == [] @@ -1225,7 +1223,7 @@ Other ================================================================================ alias Define or display aliases help List available commands with "help" or detailed help with "help cmd". -history View, run, edit, and save previously entered commands. +history View, run, edit, save, or clear previously entered commands. load Runs commands in script file that is encoded as either ASCII or UTF-8 text. py Invoke python command, shell, or script pyscript Runs a python script file inside the console |