diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | cmd2/transcript.py | 5 | ||||
-rw-r--r-- | tests/test_transcript.py | 1 | ||||
-rw-r--r-- | tests/transcripts/no_output.txt | 2 | ||||
-rw-r--r-- | tests/transcripts/no_output_last.txt | 7 |
5 files changed, 14 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e3d704d..e09d25b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Fixed bug where ``get_all_commands`` could return non-callable attributes * Fixed bug where **alias** command was dropping quotes around arguments * Fixed bug where running help on argparse commands didn't work if they didn't support -h + * Fixed transcript testing bug where last command in transcript has no expected output * Enhancements * Added ``exit_code`` attribute of ``cmd2.Cmd`` class * Enables applications to return a non-zero exit code when exiting from ``cmdloop`` diff --git a/cmd2/transcript.py b/cmd2/transcript.py index 2d94f4e4..baaa6caf 100644 --- a/cmd2/transcript.py +++ b/cmd2/transcript.py @@ -67,7 +67,10 @@ class Cmd2TestCase(unittest.TestCase): break line_num += 1 command = [line[len(self.cmdapp.visible_prompt):]] - line = next(transcript) + try: + line = next(transcript) + except StopIteration: + line = '' # Read the entirety of a multi-line command while line.startswith(self.cmdapp.continuation_prompt): command.append(line[len(self.cmdapp.continuation_prompt):]) diff --git a/tests/test_transcript.py b/tests/test_transcript.py index 9a63cf09..58ae16b4 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -103,6 +103,7 @@ def test_commands_at_invocation(): ('multiline_no_regex.txt', False), ('multiline_regex.txt', False), ('no_output.txt', False), + ('no_output_last.txt', False), ('regex_set.txt', False), ('singleslash.txt', False), ('slashes_escaped.txt', False), diff --git a/tests/transcripts/no_output.txt b/tests/transcripts/no_output.txt index d1089a39..6b84e8e7 100644 --- a/tests/transcripts/no_output.txt +++ b/tests/transcripts/no_output.txt @@ -1,4 +1,4 @@ -# ensure the transcript can play a command with no output +# ensure the transcript can play a command with no output from a command somewhere in the middle (Cmd) say something something diff --git a/tests/transcripts/no_output_last.txt b/tests/transcripts/no_output_last.txt new file mode 100644 index 00000000..c75d7e7f --- /dev/null +++ b/tests/transcripts/no_output_last.txt @@ -0,0 +1,7 @@ +# ensure the transcript can play a command with no output from the last command + +(Cmd) say something +something +(Cmd) say something else +something else +(Cmd) nothing |