[Zope3-checkins] SVN: zope.testing/trunk/src/zope/testing/testrunner/ - Fix tests on Windows.

Sidnei da Silva sidnei.da.silva at gmail.com
Fri Mar 12 14:33:31 EST 2010


Log message for revision 109932:
  - Fix tests on Windows.

Changed:
  U   zope.testing/trunk/src/zope/testing/testrunner/formatter.py
  U   zope.testing/trunk/src/zope/testing/testrunner/tests.py

-=-
Modified: zope.testing/trunk/src/zope/testing/testrunner/formatter.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner/formatter.py	2010-03-12 16:28:15 UTC (rev 109931)
+++ zope.testing/trunk/src/zope/testing/testrunner/formatter.py	2010-03-12 19:33:30 UTC (rev 109932)
@@ -945,17 +945,22 @@
 
     def profiler_stats(self, stats):
         """Report profiler stats."""
-        ignored, filename = tempfile.mkstemp()
+        fd, filename = tempfile.mkstemp()
+        os.close(fd)
         try:
             stats.dump_stats(filename)
-            profile_content = content.Content(
-                self.PROFILE_CONTENT_TYPE, open(filename).read)
-            details = {'profiler-stats': profile_content}
+            stats_dump = open(filename)
+            try:
+                profile_content = content.Content(
+                    self.PROFILE_CONTENT_TYPE, stats_dump.read)
+                details = {'profiler-stats': profile_content}
+                # Name the test 'zope:profiler_stats' just like its tag.
+                self._emit_fake_test(
+                    self.TAG_PROFILER_STATS, self.TAG_PROFILER_STATS, details)
+            finally:
+                stats_dump.close()
         finally:
             os.unlink(filename)
-        # Name the test 'zope:profiler_stats' just like its tag.
-        self._emit_fake_test(
-            self.TAG_PROFILER_STATS, self.TAG_PROFILER_STATS, details)
 
     def tests_with_errors(self, errors):
         """Report tests with errors.

Modified: zope.testing/trunk/src/zope/testing/testrunner/tests.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner/tests.py	2010-03-12 16:28:15 UTC (rev 109931)
+++ zope.testing/trunk/src/zope/testing/testrunner/tests.py	2010-03-12 19:33:30 UTC (rev 109932)
@@ -46,6 +46,17 @@
         (re.compile(r"<type 'exceptions.(\w+)Error'>:"),
                     r'exceptions.\1Error:'),
 
+        # Remove '\r', since this only causes confusion.
+        (re.compile(r'\\r', re.MULTILINE), ''),
+        (re.compile(r'\r', re.MULTILINE), ''),
+
+        # testtools content formatter is used to mime-encode
+        # tracebacks when the SubunitOutputFormatter is used, and the
+        # resulting text includes a size which can vary depending on
+        # the path included in the traceback.
+        (re.compile(r'traceback\n[A-F\d]+', re.MULTILINE),
+         r'traceback\nNNN'),
+
         (re.compile("'[A-Za-z]:\\\\"), "'"), # hopefully, we'll make Windows happy
                                              # replaces drives with nothing
 
@@ -61,6 +72,8 @@
         (re.compile(r'\d+[.]\d\d\d seconds'), 'N.NNN seconds'),
         (re.compile(r'\d+[.]\d\d\d s'), 'N.NNN s'),
         (re.compile(r'\d+[.]\d\d\d{'), 'N.NNN{'),
+        (re.compile(r'\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d+'),
+         'YYYY-MM-DD HH:MM:SS.mmmmmm'),
         (re.compile('( |")[^\n]+testrunner-ex'), r'\1testrunner-ex'),
         (re.compile('( |")[^\n]+testrunner.py'), r'\1testrunner.py'),
         (re.compile(r'> [^\n]*(doc|unit)test[.]py\(\d+\)'),
@@ -70,11 +83,6 @@
         (re.compile(r' line \d+,', re.IGNORECASE), r' Line NNN,'),
         (re.compile(r' line {([a-z]+)}\d+{', re.IGNORECASE), r' Line {\1}NNN{'),
 
-        # testtools formatter includes a size hint, which can vary
-        # depending on the path included in the traceback.
-        (re.compile(r'traceback\n[A-F\d]+\\r', re.MULTILINE),
-         r'traceback\nXXX\\r'),
-
         # omit traceback entries for unittest.py or doctest.py (and
         # their package variants) from output:
         (re.compile(r'^ +File "[^\n]*(doctest|unittest|case)(/__init__)?.py", [^\n]+\n[^\n]+\n',
@@ -119,10 +127,12 @@
         (re.compile(r' line \d+,', re.IGNORECASE), r' Line NNN,'),
         (re.compile(r' line {([a-z]+)}\d+{', re.IGNORECASE), r' Line {\1}NNN{'),
 
-        # testtools formatter includes a size hint, which can vary
-        # depending on the path included in the traceback.
-        (re.compile(r'traceback\n[A-F\d]+\\r', re.MULTILINE),
-         r'traceback\nXXX\\r'),
+        # testtools content formatter is used to mime-encode
+        # tracebacks when the SubunitOutputFormatter is used, and the
+        # resulting text includes a size which can vary depending on
+        # the path included in the traceback.
+        (re.compile(r'traceback\n[A-F\d]+', re.MULTILINE),
+         r'traceback\nNNN'),
 
         # omit traceback entries for unittest.py or doctest.py (and
         # their package variants) from output:



More information about the Zope3-Checkins mailing list