# HG changeset patch # User Catherine Devlin # Date 1284637106 14400 # Node ID e60e2c15f026a0bc9d55be8875db700756191bda # Parent 9f9c69fbb78f93c8ec5a80d7e9456babb509c75a ignore whitespace during comparisons diff -r 9f9c69fbb78f -r e60e2c15f026 cmd2.py --- 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 diff -r 9f9c69fbb78f -r e60e2c15f026 docs/freefeatures.rst --- a/docs/freefeatures.rst Tue Sep 07 07:25:49 2010 -0400 +++ b/docs/freefeatures.rst Thu Sep 16 07:38:26 2010 -0400 @@ -181,6 +181,11 @@ python app.py --test transcript.txt -Any deviations between the output prescribed in ``transcript.txt`` and +Any non-whitespace deviations between the output prescribed in ``transcript.txt`` and the actual output from a fresh run of the application will be reported -as a unit test failure. +as a unit test failure. (Whitespace is ignored during the comparison.) + +Regular expressions can be embedded in the transcript inside paired ``/`` +slashes. These regular expressions should not include any whitespace +expressions. +