[Zope3-checkins] SVN: zope.testing/trunk/ Clean up support for displaying tracebacks with supplements by turning it into
Christian Theune
ct at gocept.com
Tue Jul 14 11:23:20 EDT 2009
Log message for revision 101909:
Clean up support for displaying tracebacks with supplements by turning it into
an always-enabled feature and making the dependency on zope.exceptions
explicit.
Changed:
U zope.testing/trunk/CHANGES.txt
U zope.testing/trunk/setup.py
U zope.testing/trunk/src/zope/testing/__init__.py
U zope.testing/trunk/src/zope/testing/testrunner/runner.py
A zope.testing/trunk/src/zope/testing/testrunner/tb_format.py
U zope.testing/trunk/src/zope/testing/testrunner/testrunner-edge-cases.txt
U zope.testing/trunk/src/zope/testing/testrunner/testrunner-errors.txt
U zope.testing/trunk/src/zope/testing/testrunner/testrunner-ex/sample2/sampletests_e.py
A zope.testing/trunk/src/zope/testing/testrunner/testrunner-tb-format.txt
-=-
Modified: zope.testing/trunk/CHANGES.txt
===================================================================
--- zope.testing/trunk/CHANGES.txt 2009-07-14 15:01:37 UTC (rev 101908)
+++ zope.testing/trunk/CHANGES.txt 2009-07-14 15:23:20 UTC (rev 101909)
@@ -4,6 +4,10 @@
3.7.7 (unreleased)
==================
+- Clean up support for displaying tracebacks with supplements by turning it
+ into an always-enabled feature and making the dependency on zope.exceptions
+ explicit.
+
- Fix #251759: Test runner descended into directories that aren't Python
packages.
Modified: zope.testing/trunk/setup.py
===================================================================
--- zope.testing/trunk/setup.py 2009-07-14 15:01:37 UTC (rev 101908)
+++ zope.testing/trunk/setup.py 2009-07-14 15:23:20 UTC (rev 101909)
@@ -23,8 +23,8 @@
extra = dict(
namespace_packages=['zope',],
install_requires = ['setuptools',
+ 'zope.exceptions',
'zope.interface'],
- extras_require={'zope_tracebacks': 'zope.exceptions'},
entry_points = {'console_scripts': ['zope-testrunner = zope.testing.testrunner:run',]},
include_package_data = True,
zip_safe = False,
Modified: zope.testing/trunk/src/zope/testing/__init__.py
===================================================================
--- zope.testing/trunk/src/zope/testing/__init__.py 2009-07-14 15:01:37 UTC (rev 101908)
+++ zope.testing/trunk/src/zope/testing/__init__.py 2009-07-14 15:23:20 UTC (rev 101909)
@@ -11,20 +11,3 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Set up testing environment
-
-$Id$
-"""
-import os
-
-def patchTracebackModule():
- """Use the ExceptionFormatter to show more info in tracebacks.
- """
- from zope.exceptions.exceptionformatter import format_exception
- import traceback
- traceback.format_exception = format_exception
-
-# Don't use the new exception formatter by default, since it
-# doesn't show filenames.
-if os.environ.get('NEW_ZOPE_EXCEPTION_FORMATTER', 0):
- patchTracebackModule()
Modified: zope.testing/trunk/src/zope/testing/testrunner/runner.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner/runner.py 2009-07-14 15:01:37 UTC (rev 101908)
+++ zope.testing/trunk/src/zope/testing/testrunner/runner.py 2009-07-14 15:23:20 UTC (rev 101909)
@@ -47,7 +47,9 @@
import zope.testing.testrunner.process
import zope.testing.testrunner.interfaces
import zope.testing.testrunner.debug
+import zope.testing.testrunner.tb_format
+
PYREFCOUNT_PATTERN = re.compile('\[[0-9]+ refs\]')
is_jython = sys.platform.startswith('java')
@@ -189,6 +191,7 @@
self.features.append(zope.testing.testrunner.filter.Filter(self))
self.features.append(zope.testing.testrunner.listing.Listing(self))
self.features.append(zope.testing.testrunner.statistics.Statistics(self))
+ self.features.append(zope.testing.testrunner.tb_format.Traceback(self))
# Remove all features that aren't activated
self.features = [f for f in self.features if f.active]
Added: zope.testing/trunk/src/zope/testing/testrunner/tb_format.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner/tb_format.py (rev 0)
+++ zope.testing/trunk/src/zope/testing/testrunner/tb_format.py 2009-07-14 15:23:20 UTC (rev 101909)
@@ -0,0 +1,40 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Set up testing environment
+
+$Id: __init__.py 68482 2006-06-04 14:58:55Z jim $
+"""
+
+import os
+import traceback
+import zope.exceptions.exceptionformatter
+import zope.testing.testrunner.feature
+
+
+def format_exception(t, v, tb, limit=None):
+ fmt = zope.exceptions.exceptionformatter.TextExceptionFormatter(
+ limit=None, with_filenames=True)
+ return fmt.formatException(t, v, tb)
+
+
+class Traceback(zope.testing.testrunner.feature.Feature):
+
+ active = True
+
+ def global_setup(self):
+ self.old_format = traceback.format_exception
+ traceback.format_exception = format_exception
+
+ def global_teardown(self):
+ traceback.format_exception = self.old_format
Property changes on: zope.testing/trunk/src/zope/testing/testrunner/tb_format.py
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: zope.testing/trunk/src/zope/testing/testrunner/testrunner-edge-cases.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner/testrunner-edge-cases.txt 2009-07-14 15:01:37 UTC (rev 101908)
+++ zope.testing/trunk/src/zope/testing/testrunner/testrunner-edge-cases.txt 2009-07-14 15:23:20 UTC (rev 101909)
@@ -28,6 +28,7 @@
<BLANKLINE>
Module: sampletestsf
<BLANKLINE>
+ Traceback (most recent call last):
ImportError: No module named sampletestsf
...
@@ -454,6 +455,7 @@
<BLANKLINE>
Module: sample1.sampletests_none_suite
<BLANKLINE>
+ Traceback (most recent call last):
TypeError: Invalid test_suite, None, in sample1.sampletests_none_suite
<BLANKLINE>
<BLANKLINE>
@@ -472,6 +474,7 @@
<BLANKLINE>
Module: sample1.sampletests_none_test
<BLANKLINE>
+ Traceback (most recent call last):
TypeError: ...
<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 15:01:37 UTC (rev 101908)
+++ zope.testing/trunk/src/zope/testing/testrunner/testrunner-errors.txt 2009-07-14 15:23:20 UTC (rev 101909)
@@ -62,6 +62,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>
@@ -148,6 +149,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>
...
@@ -240,6 +242,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>
5/56 (8.9%)##r##
@@ -707,6 +710,7 @@
<BLANKLINE>
Module: sample2.sampletests_i
<BLANKLINE>
+ Traceback (most recent call last):
File "testrunner-ex/sample2/sampletests_i.py", line 1
importx unittest
^
@@ -723,6 +727,7 @@
<BLANKLINE>
Module: sample2.sample22.sampletests_i
<BLANKLINE>
+ Traceback (most recent call last):
AttributeError: 'module' object has no attribute 'test_suite'
<BLANKLINE>
<BLANKLINE>
Modified: zope.testing/trunk/src/zope/testing/testrunner/testrunner-ex/sample2/sampletests_e.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner/testrunner-ex/sample2/sampletests_e.py 2009-07-14 15:01:37 UTC (rev 101908)
+++ zope.testing/trunk/src/zope/testing/testrunner/testrunner-ex/sample2/sampletests_e.py 2009-07-14 15:23:20 UTC (rev 101909)
@@ -21,6 +21,7 @@
def g():
x = 1
x = x + 1
+ __traceback_info__ = "I don't know what Y should be."
x = y + 1
x = x + 1
Property changes on: zope.testing/trunk/src/zope/testing/testrunner/testrunner-tb-format.txt
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the Zope3-Checkins
mailing list