1
##############################################################################
3
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE.
13
##############################################################################
14
"""Set up testing environment
16
$Id: __init__.py 68482 2006-06-04 14:58:55Z jim $
23
import zope.exceptions.exceptionformatter
24
import zope.testing.testrunner.feature
27
def format_exception(t, v, tb, limit=None):
28
fmt = zope.exceptions.exceptionformatter.TextExceptionFormatter(
29
limit=None, with_filenames=True)
30
return fmt.formatException(t, v, tb)
33
def print_exception(t, v, tb, limit=None, file=None):
36
file.writelines(format_exception(t, v, tb, limit))
39
class Traceback(zope.testing.testrunner.feature.Feature):
43
def global_setup(self):
44
self.old_format = traceback.format_exception
45
traceback.format_exception = format_exception
47
self.old_print = traceback.print_exception
48
traceback.print_exception = print_exception
50
def global_teardown(self):
51
traceback.format_exception = self.old_format
52
traceback.print_exception = self.old_print