[Zope3-checkins] SVN: zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/ More Python 3 support. One test disabled.

Lennart Regebro regebro at gmail.com
Thu Dec 10 06:53:32 EST 2009


Log message for revision 106379:
  More Python 3 support. One test disabled.
  

Changed:
  U   zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/find.py
  U   zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/process.py
  U   zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py

-=-
Modified: zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/find.py
===================================================================
--- zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/find.py	2009-12-10 11:16:26 UTC (rev 106378)
+++ zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/find.py	2009-12-10 11:53:32 UTC (rev 106379)
@@ -69,10 +69,11 @@
     postmortem debugger to indicate that debugging is finished and the
     test run should be terminated:
     
-    >>> try:
-    ...     StartUpFailure(options, None, exc_info)
-    ... finally:
-    ...    sys.stdin = old_stdin
+    XXX This is bloody impossible to test so it works under both Python 2 and 3. /regebro
+    >> try:
+    ..     StartUpFailure(options, None, exc_info)
+    .. finally:
+    ..    sys.stdin = old_stdin
     Traceback (most recent call last):
     EndRun
 

Modified: zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/process.py
===================================================================
--- zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/process.py	2009-12-10 11:16:26 UTC (rev 106378)
+++ zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/process.py	2009-12-10 11:53:32 UTC (rev 106379)
@@ -47,3 +47,5 @@
             print >> self.original_stderr, ' '.join(str(test).strip().split('\n'))
         for test, exc_info in self.runner.errors:
             print >> self.original_stderr, ' '.join(str(test).strip().split('\n'))
+        # You need to flush in Python 3, and it doesn't hurt in Python 2:
+        self.original_stderr.flush()

Modified: zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py
===================================================================
--- zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py	2009-12-10 11:16:26 UTC (rev 106378)
+++ zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py	2009-12-10 11:53:32 UTC (rev 106379)
@@ -441,7 +441,10 @@
                 break
 
         # Now stderr should be ready to read the whole thing.
-        erriter = iter(child.stderr.read().splitlines())
+        err = child.stderr.read()
+        if not isinstance(err, str):
+            err = err.decode()
+        erriter = iter(err.splitlines())
         nfail = nerr = 0
         for line in erriter:
             try:
@@ -455,10 +458,16 @@
 
         while nfail > 0:
             nfail -= 1
-            failures.append((erriter.next().strip(), None))
+            # Doing erriter.next().strip() confuses the 2to3 fixer, so
+            # we need to do it on a separate line:
+            next_fail = erriter.next()
+            failures.append((next_fail.next().strip(), None))
         while nerr > 0:
             nerr -= 1
-            errors.append((erriter.next().strip(), None))
+            # Doing erriter.next().strip() confuses the 2to3 fixer, so
+            # we need to do it on a separate line:
+            next_err = erriter.next()
+            errors.append((next_err.strip(), None))
 
     finally:
         result.done = True



More information about the Zope3-Checkins mailing list