From: Doug H. <dou...@us...> - 2002-08-25 14:40:28
|
Update of /cvsroot/happydoc/HappyDoc/happydoclib In directory usw-pr-cvs1:/tmp/cvs-serv373/happydoclib Modified Files: happydocstring.py Log Message: Added _compareText() method to make it easier to see where a converted block of text differs from the expected result. Index: happydocstring.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc/happydoclib/happydocstring.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** happydocstring.py 4 Aug 2002 10:47:30 -0000 1.3 --- happydocstring.py 25 Aug 2002 14:40:24 -0000 1.4 *************** *** 192,195 **** --- 192,213 ---- return + def _compareText(self, expected, actual): + expected_lines = expected.split('\n') + actual_lines = actual.split('\n') + num_lines = max(len(expected_lines), len(actual_lines)) + for i in range(num_lines): + try: + e_line = expected_lines[i] + except IndexError: + self.fail('Actual result has more lines than expected.') + try: + a_line = actual_lines[i] + except IndexError: + self.fail('Expected result has more lines than actual.') + self.failUnlessEqual( + e_line, a_line, + 'Mismatch at line %d: "%s" is not "%s"' % (i, a_line, e_line)) + return + def _testConversion(self, inputText, inputFormat, outputFormat, expectedText, errorMessage, *************** *** 204,210 **** print '[EXPECTED[%s]EXPECTED]' % expectedText print '[CONVERTED[%s]CONVERTED]' % converted_text ! assert (converted_text == expectedText), '%s ("%s", "%s") ' % (errorMessage, ! expectedText, ! converted_text) return --- 222,226 ---- print '[EXPECTED[%s]EXPECTED]' % expectedText print '[CONVERTED[%s]CONVERTED]' % converted_text ! self._compareText(expectedText, converted_text) return |