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 $
21
import zope.exceptions.exceptionformatter
22
import zope.testing.testrunner.feature
25
def format_exception(t, v, tb, limit=None):
26
fmt = zope.exceptions.exceptionformatter.TextExceptionFormatter(
27
limit=None, with_filenames=True)
28
return fmt.formatException(t, v, tb)
31
def print_exception(t, v, tb, limit=None, file=None):
34
file.writelines(format_exception(t, v, tb, limit))
37
class Traceback(zope.testing.testrunner.feature.Feature):
41
def global_setup(self):
42
self.old_format = traceback.format_exception
43
traceback.format_exception = format_exception
45
self.old_print = traceback.print_exception
46
traceback.print_exception = print_exception
48
def global_teardown(self):
49
traceback.format_exception = self.old_format
50
traceback.print_exception = self.old_print