This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Regression in unittest traceback formating extensibility
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brian.curtin, gz, michael.foord
Priority: normal Keywords:

Created on 2010-01-30 18:00 by gz, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg98573 - (view) Author: Martin (gz) * Date: 2010-01-30 18:00
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:

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

--- old/Lib/unittest/
+++ new/Lib/unittest/
@@ -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/
+++ new/Lib/unittest/
@@ -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
msg101471 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-03-22 00:07
Committed revision 79263. As external modules are already using __unittest it would be backwards incompatible not to restore the functionality.
Date User Action Args
2022-04-11 14:56:57adminsetgithub: 52063
2010-03-22 00:07:43michael.foordsetstatus: open -> closed
resolution: fixed
messages: + msg101471

stage: needs patch -> resolved
2010-01-30 18:35:53brian.curtinsetpriority: normal
nosy: + michael.foord, brian.curtin

stage: needs patch
2010-01-30 18:00:48gzcreate