comparison cmd2/cmd2.py @ 107:3e2651cbe376

vigorous whitespace stripping from test results
author catherine@dellzilla
date Fri, 24 Oct 2008 16:13:47 -0400
parents 2d3232693807
children f7b0152c57f9
comparison
equal deleted inserted replaced
106:2d3232693807 107:3e2651cbe376
760 if self.CmdApp: 760 if self.CmdApp:
761 for (cmdInput, lineNum) in self.transcriptReader.inputGenerator(): 761 for (cmdInput, lineNum) in self.transcriptReader.inputGenerator():
762 self.cmdapp.onecmd(cmdInput) 762 self.cmdapp.onecmd(cmdInput)
763 result = self.outputTrap.read() 763 result = self.outputTrap.read()
764 expected = self.transcriptReader.nextExpected() 764 expected = self.transcriptReader.nextExpected()
765 self.assertEqual(result.strip(), expected.strip(), 765 self.assertEqual(self.stripByLine(result), self.stripByLine(expected),
766 '\nFile %s, line %d\nCommand was:\n%s\nExpected:\n%s\nGot:\n%s\n' % 766 '\nFile %s, line %d\nCommand was:\n%s\nExpected:\n%s\nGot:\n%s\n' %
767 (self.transcriptFileName, lineNum, cmdInput, expected, result)) 767 (self.transcriptFileName, lineNum, cmdInput, expected, result))
768 def stripByLine(self, s):
769 lines = s.splitlines()
770 return '\n'.join(line.rstrip() for line in lines).strip()
768 def tearDown(self): 771 def tearDown(self):
769 if self.CmdApp: 772 if self.CmdApp:
770 self.outputTrap.tearDown() 773 self.outputTrap.tearDown()
771 774
772 if __name__ == '__main__': 775 if __name__ == '__main__':