Mercurial > python-cmd2
diff cmd2.py @ 117:33cd0e1bebb8
stripping continuation prompts during testing
author | catherine@dellzilla |
---|---|
date | Tue, 28 Oct 2008 14:05:12 -0400 |
parents | 7d215852f9a6 |
children | fe47c5b269cc |
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()