diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-03-22 00:06:30 (GMT) |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-03-22 00:06:30 (GMT) |
commit | b1aa30f94ded4e9d1094ec890758d913b8725085 (patch) | |
tree | 0b7f5565510f05a8f2b66bb7668f646ec1439632 /Lib/unittest | |
parent | bb9d726357854a8dcae597e22d02f5d3a2122431 (diff) | |
download | cpython-b1aa30f94ded4e9d1094ec890758d913b8725085.zip cpython-b1aa30f94ded4e9d1094ec890758d913b8725085.tar.gz cpython-b1aa30f94ded4e9d1094ec890758d913b8725085.tar.bz2 |
Issue 7815. __unittest in module globals trims frames from reported stacktraces in unittest.
Diffstat (limited to 'Lib/unittest')
-rw-r--r-- | Lib/unittest/__init__.py | 2 | ||||
-rw-r--r-- | Lib/unittest/__main__.py | 3 | ||||
-rw-r--r-- | Lib/unittest/case.py | 3 | ||||
-rw-r--r-- | Lib/unittest/loader.py | 2 | ||||
-rw-r--r-- | Lib/unittest/main.py | 2 | ||||
-rw-r--r-- | Lib/unittest/result.py | 8 | ||||
-rw-r--r-- | Lib/unittest/runner.py | 2 | ||||
-rw-r--r-- | Lib/unittest/suite.py | 2 | ||||
-rw-r--r-- | Lib/unittest/util.py | 3 |
9 files changed, 22 insertions, 5 deletions
diff --git a/Lib/unittest/__init__.py b/Lib/unittest/__init__.py index 06fe55d..8f77127 100644 --- a/Lib/unittest/__init__.py +++ b/Lib/unittest/__init__.py @@ -64,3 +64,5 @@ from .runner import TextTestRunner, TextTestResult # deprecated _TextTestResult = TextTestResult + +__unittest = True diff --git a/Lib/unittest/__main__.py b/Lib/unittest/__main__.py index 5bbda1c..5023610 100644 --- a/Lib/unittest/__main__.py +++ b/Lib/unittest/__main__.py @@ -4,5 +4,8 @@ import sys if sys.argv[0].endswith("__main__.py"): sys.argv[0] = "unittest" +__unittest = True + + from .main import main main(module=None) diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index feae3fa..9495689 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -12,6 +12,9 @@ from .util import ( strclass, safe_repr, sorted_list_difference, unorderable_list_difference ) +__unittest = True + + class SkipTest(Exception): """ Raise this exception in a test to skip it. diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py index 9eede8b..d6c8d84 100644 --- a/Lib/unittest/loader.py +++ b/Lib/unittest/loader.py @@ -10,6 +10,8 @@ from fnmatch import fnmatch from . import case, suite +__unittest = True + def _CmpToKey(mycmp): 'Convert a cmp= function into a key= function' diff --git a/Lib/unittest/main.py b/Lib/unittest/main.py index bd758e0..3f0f43d 100644 --- a/Lib/unittest/main.py +++ b/Lib/unittest/main.py @@ -6,6 +6,8 @@ import types from . import loader, runner +__unittest = True + USAGE_AS_MAIN = """\ Usage: %(progName)s [options] [tests] diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py index 746967e..91cf218 100644 --- a/Lib/unittest/result.py +++ b/Lib/unittest/result.py @@ -4,6 +4,8 @@ import traceback from . import util +__unittest = True + class TestResult(object): """Holder for test result information. @@ -98,11 +100,7 @@ class TestResult(object): 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 '__unittest' in tb.tb_frame.f_globals def _count_relevant_tb_levels(self, tb): length = 0 diff --git a/Lib/unittest/runner.py b/Lib/unittest/runner.py index 2fe01f6..f9e1995 100644 --- a/Lib/unittest/runner.py +++ b/Lib/unittest/runner.py @@ -5,6 +5,8 @@ import time from . import result +__unittest = True + class _WritelnDecorator(object): """Used to decorate file-like objects with a handy 'writeln' method""" diff --git a/Lib/unittest/suite.py b/Lib/unittest/suite.py index cccc7ef..0dd2dc5 100644 --- a/Lib/unittest/suite.py +++ b/Lib/unittest/suite.py @@ -5,6 +5,8 @@ import sys from . import case from . import util +__unittest = True + class BaseTestSuite(object): """A simple test suite that doesn't provide class or module shared fixtures. diff --git a/Lib/unittest/util.py b/Lib/unittest/util.py index 9ddf879..7d90ddf 100644 --- a/Lib/unittest/util.py +++ b/Lib/unittest/util.py @@ -1,5 +1,8 @@ """Various utility functions.""" +__unittest = True + + def safe_repr(obj): try: return repr(obj) |