[Zope3-checkins] SVN: zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/ Various Python 3 support.
Lennart Regebro
regebro at gmail.com
Thu Dec 10 05:20:28 EST 2009
Log message for revision 106370:
Various Python 3 support.
Changed:
U zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/debug.py
U zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py
U zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/tb_format.py
U zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/testrunner-debugging-layer-setup.test
-=-
Modified: zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/debug.py
===================================================================
--- zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/debug.py 2009-12-10 10:18:09 UTC (rev 106369)
+++ zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/debug.py 2009-12-10 10:20:28 UTC (rev 106370)
@@ -46,7 +46,7 @@
except:
exc_info = sys.exc_info()
- print "%s:" % (exc_info[0], )
+ print "%s.%s:" % (exc_info[0].__module__, exc_info[0].__name__)
print exc_info[1]
pdb.post_mortem(exc_info[2])
raise zope.testing.testrunner.interfaces.EndRun()
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 10:18:09 UTC (rev 106369)
+++ zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py 2009-12-10 10:20:28 UTC (rev 106370)
@@ -366,7 +366,7 @@
except zope.testing.testrunner.interfaces.EndRun:
raise
except Exception:
- f = cStringIO.StringIO()
+ f = cStringIO.StringIO()
traceback.print_exc(file=f)
output.error(f.getvalue())
errors.append((SetUpLayerFailure(), sys.exc_info()))
@@ -491,6 +491,11 @@
"""Sends complete output to queue."""
def write(self, out):
+ if not isinstance(out, str):
+ # In Python 3, a Popen process stdout uses bytes,
+ # While normal stdout uses strings. So we need to convert
+ # from bytes to strings here.
+ out = out.decode()
sys.stdout.write(out)
# Help keep-alive monitors (human or automated) keep up-to-date.
sys.stdout.flush()
Modified: zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/tb_format.py
===================================================================
--- zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/tb_format.py 2009-12-10 10:18:09 UTC (rev 106369)
+++ zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/tb_format.py 2009-12-10 10:20:28 UTC (rev 106370)
@@ -22,16 +22,26 @@
import zope.testing.testrunner.feature
-def format_exception(t, v, tb, limit=None):
+def format_exception(t, v, tb, limit=None, chain=None):
+ if chain:
+ values = traceback._iter_chain(v, tb)
+ else:
+ values = [(v, tb)]
fmt = zope.exceptions.exceptionformatter.TextExceptionFormatter(
limit=None, with_filenames=True)
- return fmt.formatException(t, v, tb)
+ for v, tb in values:
+ return fmt.formatException(t, v, tb)
-def print_exception(t, v, tb, limit=None, file=None):
+def print_exception(t, v, tb, limit=None, file=None, chain=None):
+ if chain:
+ values = traceback._iter_chain(v, tb)
+ else:
+ values = [(v, tb)]
if file is None:
file = sys.stdout
- file.writelines(format_exception(t, v, tb, limit))
+ for v, tb in values:
+ file.writelines(format_exception(t, v, tb, limit))
class Traceback(zope.testing.testrunner.feature.Feature):
Modified: zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/testrunner-debugging-layer-setup.test
===================================================================
--- zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/testrunner-debugging-layer-setup.test 2009-12-10 10:18:09 UTC (rev 106369)
+++ zope.testing/branches/regebro-python3-reloaded/src/zope/testing/testrunner/testrunner-debugging-layer-setup.test 2009-12-10 10:20:28 UTC (rev 106370)
@@ -5,7 +5,7 @@
>>> tdir = tempfile.mkdtemp()
>>> dir = os.path.join(tdir, 'TESTS-DIR')
>>> os.mkdir(dir)
- >>> open(os.path.join(dir, 'tests.py'), 'w').write(
+ >>> written = open(os.path.join(dir, 'tests.py'), 'w').write(
... '''
... import doctest
...
@@ -47,7 +47,7 @@
... finally: sys.stdin = real_stdin
... # doctest: +ELLIPSIS
Running tests.Layer tests:
- Set up tests.Layer exceptions.ValueError:
+ Set up tests.Layer ....ValueError:
<BLANKLINE>
> ...tests.py(8)setUp()
-> raise ValueError
@@ -64,7 +64,7 @@
... else:
... sys.stdin = Input('p x\nc')
- >>> open(os.path.join(dir, 'tests2.py'), 'w').write(
+ >>> written = open(os.path.join(dir, 'tests2.py'), 'w').write(
... '''
... import doctest, unittest
...
More information about the Zope3-Checkins
mailing list