[Zope3-checkins] SVN: zope.testing/trunk/src/zope/testing/testrunner/t Also patch traceback.print_exception to enable doctests to include extended

Christian Theune ct at gocept.com
Tue Jul 14 14:39:44 EDT 2009


Log message for revision 101915:
  Also patch traceback.print_exception to enable doctests to include extended
  traceback information.
  

Changed:
  U   zope.testing/trunk/src/zope/testing/testrunner/tb_format.py
  U   zope.testing/trunk/src/zope/testing/testrunner/testrunner-colors.txt
  U   zope.testing/trunk/src/zope/testing/testrunner/testrunner-errors.txt

-=-
Modified: zope.testing/trunk/src/zope/testing/testrunner/tb_format.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner/tb_format.py	2009-07-14 17:51:26 UTC (rev 101914)
+++ zope.testing/trunk/src/zope/testing/testrunner/tb_format.py	2009-07-14 18:39:43 UTC (rev 101915)
@@ -16,7 +16,9 @@
 $Id: __init__.py 68482 2006-06-04 14:58:55Z jim $
 """
 
+import StringIO
 import os
+import sys
 import traceback
 import zope.exceptions.exceptionformatter
 import zope.testing.testrunner.feature
@@ -28,6 +30,12 @@
     return fmt.formatException(t, v, tb)
 
 
+def print_exception(t, v, tb, limit=None, file=None):
+    if file is None:
+        file = sys.stdout
+    file.writelines(format_exception(t, v, tb, limit))
+
+
 class Traceback(zope.testing.testrunner.feature.Feature):
 
     active = True
@@ -36,5 +44,9 @@
         self.old_format = traceback.format_exception
         traceback.format_exception = format_exception
 
+        self.old_print = traceback.print_exception
+        traceback.print_exception = print_exception
+
     def global_teardown(self):
         traceback.format_exception = self.old_format
+        traceback.print_exception = self.old_print

Modified: zope.testing/trunk/src/zope/testing/testrunner/testrunner-colors.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner/testrunner-colors.txt	2009-07-14 17:51:26 UTC (rev 101914)
+++ zope.testing/trunk/src/zope/testing/testrunner/testrunner-colors.txt	2009-07-14 18:39:43 UTC (rev 101915)
@@ -124,6 +124,7 @@
     {red}        g(){normal}
     {red}      File "testrunner-ex/sample2/sampletests_e.py", line 24, in g{normal}
     {red}        x = y + 1{normal}
+    {red}       - __traceback_info__: I don't know what Y should be.{normal}
     {red}    NameError: global name 'y' is not defined{normal}
     <BLANKLINE>
     <BLANKLINE>

Modified: zope.testing/trunk/src/zope/testing/testrunner/testrunner-errors.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner/testrunner-errors.txt	2009-07-14 17:51:26 UTC (rev 101914)
+++ zope.testing/trunk/src/zope/testing/testrunner/testrunner-errors.txt	2009-07-14 18:39:43 UTC (rev 101915)
@@ -50,6 +50,7 @@
             g()
           File "testrunner-ex/sample2/sampletests_e.py", line 24, in g
             x = y + 1
+           - __traceback_info__: I don't know what Y should be.
         NameError: global name 'y' is not defined
     <BLANKLINE>
     <BLANKLINE>
@@ -136,6 +137,7 @@
             g()
           File "testrunner-ex/sample2/sampletests_e.py", line 24, in g
             x = y + 1
+           - __traceback_info__: I don't know what Y should be.
         NameError: global name 'y' is not defined
     <BLANKLINE>
     ...
@@ -226,6 +228,7 @@
             g()
           File "testrunner-ex/sample2/sampletests_e.py", line 24, in g
             x = y + 1
+           - __traceback_info__: I don't know what Y should be.
         NameError: global name 'y' is not defined
     <BLANKLINE>
         2/56 (3.6%)##r##



More information about the Zope3-Checkins mailing list