summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/suite.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/unittest/suite.py')
-rw-r--r--Lib/unittest/suite.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/unittest/suite.py b/Lib/unittest/suite.py
index cde5d38..176af57 100644
--- a/Lib/unittest/suite.py
+++ b/Lib/unittest/suite.py
@@ -57,12 +57,21 @@ class BaseTestSuite(object):
self.addTest(test)
def run(self, result):
- for test in self:
+ for index, test in enumerate(self):
if result.shouldStop:
break
test(result)
+ self._removeTestAtIndex(index)
return result
+ def _removeTestAtIndex(self, index):
+ """Stop holding a reference to the TestCase at index."""
+ try:
+ self._tests[index] = None
+ except TypeError:
+ # support for suite implementations that have overriden self._test
+ pass
+
def __call__(self, *args, **kwds):
return self.run(*args, **kwds)
@@ -87,7 +96,7 @@ class TestSuite(BaseTestSuite):
if getattr(result, '_testRunEntered', False) is False:
result._testRunEntered = topLevel = True
- for test in self:
+ for index, test in enumerate(self):
if result.shouldStop:
break
@@ -106,6 +115,8 @@ class TestSuite(BaseTestSuite):
else:
test.debug()
+ self._removeTestAtIndex(index)
+
if topLevel:
self._tearDownPreviousClass(None, result)
self._handleModuleTearDown(result)