diff cmd2.py @ 262:e81378f82c7c 0.5.2

transcript tests with regex now work smoothly
author Catherine Devlin <catherine.devlin@gmail.com>
date Fri, 03 Apr 2009 13:02:36 -0400
parents 57070e181cf7
children ba45c2df855b
line wrap: on
line diff
--- a/cmd2.py	Fri Apr 03 12:47:13 2009 -0400
+++ b/cmd2.py	Fri Apr 03 13:02:36 2009 -0400
@@ -1122,20 +1122,11 @@
                 tfile.close()
         if not len(self.transcripts):
             raise StandardError, "No test files found - nothing to test."
-            
     def setUp(self):
         if self.CmdApp:
             self.outputTrap = OutputTrap()
             self.cmdapp = self.CmdApp()
             self.fetchTranscripts()
-    def assertEqualEnough(self, got, expected, message):
-        got = got.strip().splitlines()
-        expected = expected.strip().splitlines()
-        self.assertEqual(len(got), len(expected), message)
-        for (linegot, lineexpected) in zip(got, expected):
-            matchme = re.escape(lineexpected.strip()).replace('\\*', '.*').  \
-                      replace('\\ ', ' ')
-            self.assert_(re.match(matchme, linegot.strip()), message)
     def testall(self):
         if self.CmdApp:
             its = sorted(self.transcripts.items())
@@ -1163,9 +1154,9 @@
                 self.cmdapp.onecmd(command)
                 result = self.outputTrap.read().strip()
                 if line.startswith(self.cmdapp.prompt):
-                    self.assertEqualEnough(result, '', 
-                        '\nFile %s, line %d\nCommand was:\n%s\nExpected: (nothing) \nGot:\n%s\n' % 
-                        (fname, lineNum, command, result))    
+                    message = '\nFile %s, line %d\nCommand was:\n%s\nExpected: (nothing)\nGot:\n%s\n'%\
+                        (fname, lineNum, command, result)     
+                    self.assert_(not(result.strip()), message)
                     continue
                 expected = []
                 while not line.startswith(self.cmdapp.prompt):
@@ -1177,7 +1168,6 @@
                 expected = self.expectationParser.transformString(expected)
                 expected = self.endStrippingRegex.sub('\s*\n', expected)
                 self.assert_(re.match(expected, result, re.MULTILINE | re.DOTALL), message)
-                # this needs to account for a line-by-line strip()ping
         except StopIteration:
             pass
     def tearDown(self):