summaryrefslogtreecommitdiff
path: root/cmd2/transcript.py
diff options
context:
space:
mode:
Diffstat (limited to 'cmd2/transcript.py')
-rw-r--r--cmd2/transcript.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/cmd2/transcript.py b/cmd2/transcript.py
index a635c1d3..b5cb5397 100644
--- a/cmd2/transcript.py
+++ b/cmd2/transcript.py
@@ -84,14 +84,16 @@ class Cmd2TestCase(unittest.TestCase):
line_num += 1
command = ''.join(command)
# Send the command into the application and capture the resulting output
- # TODO: Should we get the return value and act if stop == True?
- self.cmdapp.onecmd_plus_hooks(command)
+ stop = self.cmdapp.onecmd_plus_hooks(command)
result = self.cmdapp.stdout.read()
+ stop_msg = 'Command indicated application should quit, but more commands in transcript'
# Read the expected result from transcript
if utils.strip_ansi(line).startswith(self.cmdapp.visible_prompt):
message = '\nFile {}, line {}\nCommand was:\n{}\nExpected: (nothing)\nGot:\n{}\n'.format(
fname, line_num, command, result)
self.assertTrue(not (result.strip()), message)
+ # If the command signaled the application to quit there should be no more commands
+ self.assertFalse(stop, stop_msg)
continue
expected = []
while not utils.strip_ansi(line).startswith(self.cmdapp.visible_prompt):
@@ -102,9 +104,13 @@ class Cmd2TestCase(unittest.TestCase):
finished = True
break
line_num += 1
- expected = ''.join(expected)
+
+ if stop:
+ # This should only be hit if cmd2.Cmd.do_quit is overridden to have output text
+ self.assertTrue(finished, stop_msg)
# transform the expected text into a valid regular expression
+ expected = ''.join(expected)
expected = self._transform_transcript_expected(expected)
message = '\nFile {}, line {}\nCommand was:\n{}\nExpected:\n{}\nGot:\n{}\n'.format(
fname, line_num, command, expected, result)