[New-bugs-announce] [issue7815] Regression in unittest traceback formating extensibility

Martin report at bugs.python.org
Sat Jan 30 19:00:50 CET 2010


New submission from Martin <gzlist at googlemail.com>:

Prior to being split up into a package, unittest had an extensible method of trimming uninteresting, testing-framework related parts from tracebacks. As an unintended side effect, this is no longer the case, only modules actually named "unittest" are excluded. Code depending on the old method exists in a number of different projects, and there is no benefit to breaking them.

More details and discussion of this issue on python-dev can be read at:
<http://mail.python.org/pipermail/python-dev/2009-December/094734.html>

Reverting this change is trivial, something along the lines of:

--- old/Lib/unittest/case.py
+++ new/Lib/unittest/case.py
@@ -9,7 +9,9 @@
 
 from . import result, util
 
+__unittest = True
 
+
 class SkipTest(Exception):
     """
     Raise this exception in a test to skip it.
--- old/Lib/unittest/result.py
+++ new/Lib/unittest/result.py
@@ -94,11 +94,7 @@
         return ''.join(traceback.format_exception(exctype, value, tb))
 
     def _is_relevant_tb_level(self, tb):
-        globs = tb.tb_frame.f_globals
-        is_relevant =  '__name__' in globs and \
-            globs["__name__"].startswith("unittest")
-        del globs
-        return is_relevant
+        return tb.tb_frame.f_globals.has_key('__unittest')
 
     def _count_relevant_tb_levels(self, tb):
         length = 0

----------
components: Library (Lib)
messages: 98573
nosy: gz
severity: normal
status: open
title: Regression in unittest traceback formating extensibility
type: behavior
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7815>
_______________________________________


More information about the New-bugs-announce mailing list