Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in unittest traceback formating extensibility #52063

Closed
bz2 mannequin opened this issue Jan 30, 2010 · 2 comments
Closed

Regression in unittest traceback formating extensibility #52063

bz2 mannequin opened this issue Jan 30, 2010 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@bz2
Copy link
Mannequin

bz2 mannequin commented Jan 30, 2010

BPO 7815
Nosy @voidspace, @briancurtin, @bz2

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2010-03-22.00:07:43.838>
created_at = <Date 2010-01-30.18:00:48.685>
labels = ['type-bug', 'library']
title = 'Regression in unittest traceback formating extensibility'
updated_at = <Date 2010-03-22.00:07:43.836>
user = 'https://github.com/bz2'

bugs.python.org fields:

activity = <Date 2010-03-22.00:07:43.836>
actor = 'michael.foord'
assignee = 'none'
closed = True
closed_date = <Date 2010-03-22.00:07:43.838>
closer = 'michael.foord'
components = ['Library (Lib)']
creation = <Date 2010-01-30.18:00:48.685>
creator = 'gz'
dependencies = []
files = []
hgrepos = []
issue_num = 7815
keywords = []
message_count = 2.0
messages = ['98573', '101471']
nosy_count = 3.0
nosy_names = ['michael.foord', 'brian.curtin', 'gz']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue7815'
versions = ['Python 2.7', 'Python 3.2']

@bz2
Copy link
Mannequin Author

bz2 mannequin commented Jan 30, 2010

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

@bz2 bz2 mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jan 30, 2010
@voidspace
Copy link
Contributor

Committed revision 79263. As external modules are already using __unittest it would be backwards incompatible not to restore the functionality.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant