changeset 402:be18c88a0fc8

report when end of transcript never seen
author catherine.devlin@gmail.com
date Sun, 07 Nov 2010 06:48:15 -0500
parents 3397b9c199f5
children cc5c68e15a83
files cmd2.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Tue Sep 21 15:25:56 2010 -0400
+++ b/cmd2.py	Sun Nov 07 06:48:15 2010 -0500
@@ -1482,14 +1482,17 @@
         lineNum = 0
         try:
             line = transcript.next()
+            lineNum += 1
             while True:
                 while not line.startswith(self.cmdapp.prompt):
                     line = transcript.next()
+                    lineNum += 1
                 command = [line[len(self.cmdapp.prompt):]]
                 line = transcript.next()
                 while line.startswith(self.cmdapp.continuation_prompt):
                     command.append(line[len(self.cmdapp.continuation_prompt):])
                     line = transcript.next()
+                    lineNum += 1
                 command = ''.join(command)               
                 stop = self.cmdapp.onecmd_plus_hooks(command)
                 #TODO: should act on ``stop``
@@ -1503,6 +1506,7 @@
                 while not line.startswith(self.cmdapp.prompt):
                     expected.append(line)
                     line = transcript.next()
+                    lineNum += 1
                 expected = ''.join(expected)
                 message = '\nFile %s, line %d\nCommand was:\n%s\nExpected:\n%s\nGot:\n%s\n'%\
                     (fname, lineNum, command, expected, result)      
@@ -1512,7 +1516,8 @@
                 result = self.anyWhitespace.sub('', result)
                 self.assert_(re.match(expected, result, re.MULTILINE | re.DOTALL), message)
         except StopIteration:
-            pass
+            message = 'Last %d lines never seen, beginning with\n%s' % (len(expected), expected[0])
+            self.assert_(len(expected) < 3, message)
     def tearDown(self):
         if self.CmdApp:
             self.outputTrap.tearDown()