Mercurial > python-cmd2
diff cmd2.py @ 396:e60e2c15f026
ignore whitespace during comparisons
author | Catherine Devlin <catherine.devlin@gmail.com> |
---|---|
date | Thu, 16 Sep 2010 07:38:26 -0400 |
parents | 9f9c69fbb78f |
children | 50acba85cf9e 3bef4253cf1b |
line wrap: on
line diff
--- a/cmd2.py Tue Sep 07 07:25:49 2010 -0400 +++ b/cmd2.py Thu Sep 16 07:38:26 2010 -0400 @@ -1469,7 +1469,7 @@ notRegexPattern = pyparsing.Word(pyparsing.printables) notRegexPattern.setParseAction(lambda t: re.escape(t[0])) expectationParser = regexPattern | notRegexPattern - endStrippingRegex = re.compile(r'[ \t]*\n') + anyWhitespace = re.compile(r'\s', re.DOTALL | re.MULTILINE) def _test_transcript(self, fname, transcript): lineNum = 0 try: @@ -1499,7 +1499,9 @@ message = '\nFile %s, line %d\nCommand was:\n%s\nExpected:\n%s\nGot:\n%s\n'%\ (fname, lineNum, command, expected, result) expected = self.expectationParser.transformString(expected) - expected = self.endStrippingRegex.sub('\s*\n', expected) + # checking whitespace is a pain - let's skip it + expected = self.anyWhitespace.sub('', expected) + result = self.anyWhitespace.sub('', result) self.assert_(re.match(expected, result, re.MULTILINE | re.DOTALL), message) except StopIteration: pass