summaryrefslogtreecommitdiff
path: root/Lib/unittest/suite.py
diff options
context:
space:
mode:
authorMichael Foord <fuzzyman@voidspace.org.uk>2010-11-01 22:11:53 +0000
committerMichael Foord <fuzzyman@voidspace.org.uk>2010-11-01 22:11:53 +0000
commite5dc24e874da603d29d1e15035e38dd28e72a39f (patch)
treee4c059c61d65606b085fe213ab389cfda11e2817 /Lib/unittest/suite.py
parent68c3678253eb0bf1a15537d2725df9af15e2c913 (diff)
downloadcpython-git-e5dc24e874da603d29d1e15035e38dd28e72a39f.tar.gz
Merged revisions 86101 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86101 | michael.foord | 2010-11-01 21:09:03 +0000 (Mon, 01 Nov 2010) | 1 line Fix issue 9926. TestSuite subclasses that override __call__ are called correctly. ........
Diffstat (limited to 'Lib/unittest/suite.py')
-rw-r--r--Lib/unittest/suite.py36
1 files changed, 17 insertions, 19 deletions
diff --git a/Lib/unittest/suite.py b/Lib/unittest/suite.py
index 8602107eb8..e8fbdc31fe 100644
--- a/Lib/unittest/suite.py
+++ b/Lib/unittest/suite.py
@@ -80,23 +80,11 @@ class TestSuite(BaseTestSuite):
subclassing, do not forget to call the base class constructor.
"""
+ def run(self, result, debug=False):
+ topLevel = False
+ if getattr(result, '_testRunEntered', False) is False:
+ result._testRunEntered = topLevel = True
- def run(self, result):
- self._wrapped_run(result)
- self._tearDownPreviousClass(None, result)
- self._handleModuleTearDown(result)
- return result
-
- def debug(self):
- """Run the tests without collecting errors in a TestResult"""
- debug = _DebugResult()
- self._wrapped_run(debug, True)
- self._tearDownPreviousClass(None, debug)
- self._handleModuleTearDown(debug)
-
- ################################
- # private methods
- def _wrapped_run(self, result, debug=False):
for test in self:
if result.shouldStop:
break
@@ -111,13 +99,23 @@ class TestSuite(BaseTestSuite):
getattr(result, '_moduleSetUpFailed', False)):
continue
- if hasattr(test, '_wrapped_run'):
- test._wrapped_run(result, debug)
- elif not debug:
+ if not debug:
test(result)
else:
test.debug()
+ if topLevel:
+ self._tearDownPreviousClass(None, result)
+ self._handleModuleTearDown(result)
+ return result
+
+ def debug(self):
+ """Run the tests without collecting errors in a TestResult"""
+ debug = _DebugResult()
+ self.run(debug, True)
+
+ ################################
+
def _handleClassSetUp(self, test, result):
previousClass = getattr(result, '_previousTestClass', None)
currentClass = test.__class__