changeset 117:33cd0e1bebb8

stripping continuation prompts during testing
author catherine@dellzilla
date Tue, 28 Oct 2008 14:05:12 -0400
parents 06f5eba2f588
children db366853074c
files cmd2.py example/exampleSession.txt
diffstat 2 files changed, 15 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Sat Oct 25 21:07:23 2008 -0400
+++ b/cmd2.py	Tue Oct 28 14:05:12 2008 -0400
@@ -761,15 +761,20 @@
     def testall(self):
         if self.CmdApp:            
             for (cmdInput, lineNum) in self.transcriptReader.inputGenerator():
-                self.cmdapp.onecmd(cmdInput)
+                self.cmdapp.onecmd(cmdInput, assumeComplete=True)
                 result = self.outputTrap.read()
                 expected = self.transcriptReader.nextExpected()
                 self.assertEqual(self.stripByLine(result), self.stripByLine(expected), 
                     '\nFile %s, line %d\nCommand was:\n%s\nExpected:\n%s\nGot:\n%s\n' % 
                     (self.transcriptFileName, lineNum, cmdInput, expected, result))
     def stripByLine(self, s):
-        lines = s.splitlines()
-        return '\n'.join(line.rstrip() for line in lines).strip()
+        bareprompt = self.cmdapp.continuationPrompt.strip()
+        lines = (line.rstrip() for line in s.splitlines())
+        lines = (   line.replace(bareprompt, '', 1) 
+                 if line.startswith(bareprompt)
+                 else line
+                 for line in lines)
+        return '\n'.join(lines).strip()
     def tearDown(self):
         if self.CmdApp:
             self.outputTrap.tearDown()
--- a/example/exampleSession.txt	Sat Oct 25 21:07:23 2008 -0400
+++ b/example/exampleSession.txt	Tue Oct 28 14:05:12 2008 -0400
@@ -1,89 +1,7 @@
-This is cut-and-pasted from an interactive example.py session.
-Calling `example.py -t` runs it as a series of unit tests,
-verifying that the same output is still returned.
-
-(Cmd) help
-
-Documented commands (type help <topic>):
-========================================
-_load  edit  history  li    load   r    save  set    shortcuts  speak
-ed     hi    l        list  orate  run  say   shell  show     
-
-Undocumented commands:
-======================
-EOF  cmdenvironment  eof  exit  help  q  quit
-
-(Cmd) help say
-Repeats what you tell me to.
-Usage: speak [options] arg
-
-Options:
-  -h, --help            show this help message and exit
-  -p, --piglatin        atinLay
-  -s, --shout           N00B EMULATION MODE
-  -r REPEAT, --repeat=REPEAT
-                        output [n] times
-
-(Cmd) say goodnight, Gracie
-goodnight, Gracie
-(Cmd) say -ps --repeat=5 goodnight, gracie
-OODNIGHT, GRACIEGAY
-OODNIGHT, GRACIEGAY
-OODNIGHT, GRACIEGAY
-(Cmd) set
-prompt: (Cmd) 
-editor: gedit
-echo: False
-maxrepeats: 3
-(Cmd) set maxrepeats 5
-maxrepeats - was: 3
-now: 5
-(Cmd) say -ps --repeat=5 goodnight, gracie
-OODNIGHT, GRACIEGAY
-OODNIGHT, GRACIEGAY
-OODNIGHT, GRACIEGAY
-OODNIGHT, GRACIEGAY
-OODNIGHT, GRACIEGAY
-(Cmd) orate these are the
-> times that
-> try mens' souls
-> 
-> 
-these are the times that try mens' souls
-(Cmd) & we made a shortcut!
-we made a shortcut!
-(Cmd) history
--------------------------[1]
-help
--------------------------[2]
-help say
--------------------------[3]
-say goodnight, Gracie
--------------------------[4]
-say -ps --repeat=5 goodnight, gracie
--------------------------[5]
-set
--------------------------[6]
-set maxrepeats 5
--------------------------[7]
-say -ps --repeat=5 goodnight, gracie
--------------------------[8]
-orate these are the
-times that
-try mens' souls
-
-
--------------------------[9]
-& we made a shortcut!
-(Cmd) run 3
-say goodnight, Gracie
-goodnight, Gracie
-(Cmd) say put this in a file > text.txt
-(Cmd) say < text.txt
-put this in a file
-(Cmd) set prompt "---> "
-prompt - was: (Cmd) 
-now: ---> 
----> say goodbye
-goodbye
----> 
+(Cmd) orate Four score and
+> seven releases ago
+> our BDFL
+> blah blah blah
+>
+>
+Four score and seven releases ago our BDFL blah blah blah
\ No newline at end of file