[Checkins] SVN: zope.testrunner/trunk/ Adding back 3.1 support.

Lennart Regebro regebro at gmail.com
Mon Mar 14 16:24:52 EDT 2011


Log message for revision 120925:
  Adding back 3.1 support.

Changed:
  U   zope.testrunner/trunk/CHANGES.txt
  U   zope.testrunner/trunk/setup.py
  U   zope.testrunner/trunk/src/zope/testrunner/runner.py
  U   zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging.txt
  U   zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-ntd.txt
  U   zope.testrunner/trunk/src/zope/testrunner/testrunner-unexpected-success.txt

-=-
Modified: zope.testrunner/trunk/CHANGES.txt
===================================================================
--- zope.testrunner/trunk/CHANGES.txt	2011-03-14 20:10:32 UTC (rev 120924)
+++ zope.testrunner/trunk/CHANGES.txt	2011-03-14 20:24:52 UTC (rev 120925)
@@ -4,7 +4,7 @@
 4.0.2 (unreleased)
 ==================
 
-- Nothing changed yet.
+- Added back Python 3 support which was broken in 4.0.1.
 
 
 4.0.1 (2011-02-21)

Modified: zope.testrunner/trunk/setup.py
===================================================================
--- zope.testrunner/trunk/setup.py	2011-03-14 20:10:32 UTC (rev 120924)
+++ zope.testrunner/trunk/setup.py	2011-03-14 20:24:52 UTC (rev 120925)
@@ -26,7 +26,7 @@
 
 if sys.version_info < (2,4) or sys.version_info[:2] == (3,0):
     raise ValueError("zope.testrunner requires Python 2.4 or higher, "
-                     "but not Python 3.0.")
+                     "or 3.1 or higher.")
 
 
 
@@ -132,10 +132,6 @@
         'testrunner-verbose.txt',
         'testrunner-test-selection.txt',
         'testrunner-progress.txt',
-
-        # The following seems to cause weird unicode in the output: :(
-        ##     'testrunner-errors.txt',
-
         'testrunner-debugging.txt',
         'testrunner-layers-ntd.txt',
         'testrunner-coverage.txt',
@@ -145,6 +141,11 @@
         'testrunner-gc.txt',
         'testrunner-leaks.txt',
         'testrunner-knit.txt',
+        'testrunner-edge-cases.txt',
+
+        # The following seems to cause weird unicode in the output: :(
+             'testrunner-errors.txt',
+
     )])
 
 long_description=(
@@ -178,6 +179,8 @@
         "Programming Language :: Python :: 2.4",
         "Programming Language :: Python :: 2.5",
         "Programming Language :: Python :: 2.6",
+        "Programming Language :: Python :: 3",
+        "Programming Language :: Python :: 3.1",
         "Topic :: Software Development :: Libraries :: Python Modules",
         "Topic :: Software Development :: Testing",
         ],

Modified: zope.testrunner/trunk/src/zope/testrunner/runner.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/runner.py	2011-03-14 20:10:32 UTC (rev 120924)
+++ zope.testrunner/trunk/src/zope/testrunner/runner.py	2011-03-14 20:24:52 UTC (rev 120925)
@@ -46,6 +46,15 @@
 import zope.testrunner.tb_format
 import zope.testrunner.shuffle
 
+try:
+    from unittest import _UnexpectedSuccess # Python 3.1
+except ImportError:
+    try:
+        from unittest.case import _UnexpectedSuccess # Python 2.7 and 3.2
+    except ImportError:
+        class _UnexpectedSuccess(Exception):
+            pass
+    
 
 PYREFCOUNT_PATTERN = re.compile('\[[0-9]+ refs\]')
 
@@ -313,8 +322,9 @@
         t = time.time() - t
         output.stop_tests()
         failures.extend(result.failures)
+        failures.extend(result.unexpectedSuccesses)
         errors.extend(result.errors)
-        output.summary(result.testsRun, len(result.failures),
+        output.summary(result.testsRun, len(failures),
             len(result.errors), t)
         ran = result.testsRun
 
@@ -387,9 +397,10 @@
         pass
 
     def __str__(self):
-        return "Layer: %s" % self.layer
+        return "Layer: %s.%s" % (self.layer.__module__, self.layer.__name__)
 
 
+
 def spawn_layer_in_subprocess(result, script_parts, options, features,
                               layer_name, layer, failures, errors,
                               resume_number):
@@ -675,10 +686,6 @@
 
 class TestResult(unittest.TestResult):
 
-    # Handle unexpected success as failure:
-    # https://bugs.launchpad.net/zope.testrunner/+bug/719369
-    addUnexpectedSuccess = None
-
     def __init__(self, options, tests, layer_name=None):
         unittest.TestResult.__init__(self)
         self.options = options
@@ -757,6 +764,28 @@
         elif self.options.stop_on_error:
             self.stop()
 
+    def addExpectedFailure(self, test, exc_info):
+        t = max(time.time() - self._start_time, 0.0)
+        self.options.output.test_success(test, t)
+
+        unittest.TestResult.addExpectedFailure(self, test, exc_info)
+
+    def addUnexpectedSuccess(self, test):
+        self.options.output.test_error(test, time.time() - self._start_time, 
+                                       (_UnexpectedSuccess, None, None))
+
+        unittest.TestResult.addUnexpectedSuccess(self, test)
+
+        if self.options.post_mortem:
+            if self.options.resume_layer:
+                self.options.output.error_with_banner("Can't post-mortem debug"
+                                                      " when running a layer"
+                                                      " as a subprocess!")
+            else:
+                zope.testrunner.debug.post_mortem(exc_info)
+        elif self.options.stop_on_error:
+            self.stop()
+            
     def stopTest(self, test):
         self.testTearDown()
         self.options.output.stop_test(test)

Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging.txt
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging.txt	2011-03-14 20:10:32 UTC (rev 120924)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-debugging.txt	2011-03-14 20:24:52 UTC (rev 120925)
@@ -86,7 +86,7 @@
     ...             ' -t post_mortem_failure1 -D').split()
     >>> try: testrunner.run_internal(defaults)
     ... finally: sys.stdin = real_stdin
-    ... # doctest: +NORMALIZE_WHITESPACE +REPORT_NDIFF
+    ... # doctest: +NORMALIZE_WHITESPACE +REPORT_NDIFF +ELLIPSIS
     Running zope.testrunner.layer.UnitTests tests:
     ...
     Error in test test_post_mortem_failure1 (sample3.sampletests_d.TestSomething)

Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-ntd.txt
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-ntd.txt	2011-03-14 20:10:32 UTC (rev 120924)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-ntd.txt	2011-03-14 20:24:52 UTC (rev 120925)
@@ -263,7 +263,7 @@
     Total: 2 tests, 0 failures, 0 errors in 0.197 seconds.
     False
 
-    >>> print sys.stderr.getvalue()
+    >>> print(sys.stderr.getvalue())
     A message on stderr.  Please ignore (expected in test output).
 
     >>> sys.stderr = real_stderr

Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-unexpected-success.txt
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-unexpected-success.txt	2011-03-14 20:10:32 UTC (rev 120924)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-unexpected-success.txt	2011-03-14 20:24:52 UTC (rev 120925)
@@ -33,9 +33,12 @@
     ... # doctest: +ELLIPSIS
     Running zope.testrunner.layer.UnitTests tests:
       Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
-    Failure in test test_ef (sampletestsf.TestUnexpectedSuccess)
+    <BLANKLINE>
+    <BLANKLINE>
+    Error in test test_ef (sampletestsf.TestUnexpectedSuccess)
     Traceback (most recent call last):
-    _UnexpectedSuccess
+    ..._UnexpectedSuccess
+    <BLANKLINE>
       Ran 1 tests with 1 failures and 0 errors in N.NNN seconds.
     Tearing down left over layers:
       Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.



More information about the checkins mailing list