diff options
-rwxr-xr-x | cmd2.py | 2 | ||||
-rw-r--r-- | tests/test_cmd2.py | 4 | ||||
-rw-r--r-- | tests/test_transcript.py | 7 |
3 files changed, 11 insertions, 2 deletions
@@ -554,7 +554,7 @@ class Cmd(cmd.Cmd): traceback.print_exc() if exception_type is None: - err = self.colorize("ERROR: {}'\n".format(errmsg), 'red') + err = self.colorize("ERROR: {}\n".format(errmsg), 'red') sys.stderr.write(err) else: err = "EXCEPTION of type '{}' occured with message: '{}'\n".format(exception_type, errmsg) diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index aa9a76f2..b89f96d4 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -231,13 +231,15 @@ load {} def test_base_load_default_file(base_app, capsys): + # TODO: Make sure to remove the 'command.txt' file in case it exists + # The way the load command works, we can't directly capture its stdout or stderr run_cmd(base_app, 'load') out, err = capsys.readouterr() # The default file 'command.txt' doesn't exist, so we should get an error message expected = normalize("""ERROR: Problem accessing script from command.txt: -[Errno 2] No such file or directory: 'command.txt.txt'' +[Errno 2] No such file or directory: 'command.txt.txt' To enable full traceback, run the following command: 'set debug true' """) assert normalize(str(err)) == expected diff --git a/tests/test_transcript.py b/tests/test_transcript.py index 7e89180a..6b229862 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -302,3 +302,10 @@ def test_multiline_command_transcript_with_comments_at_beginning(request, capsys else: assert err == '' assert out == '' + + +def test_invalid_syntax(_cmdline_app, capsys): + run_cmd(_cmdline_app, 'speak "') + out, err = capsys.readouterr() + expected = normalize("""ERROR: Invalid syntax: No closing quotation""") + assert normalize(str(err)) == expected |