summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2013-09-01 04:58:41 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2013-09-01 04:58:41 (GMT)
commit8913a6c83dd34300f4a13950036b01c0e2cad1b0 (patch)
tree3accedf450c81d822efb09c3ef32c0d406d3ebd1 /Lib
parent59360aadd31f9bdd4e018ad8acb8f06ece5423a6 (diff)
downloadcpython-8913a6c83dd34300f4a13950036b01c0e2cad1b0.zip
cpython-8913a6c83dd34300f4a13950036b01c0e2cad1b0.tar.gz
cpython-8913a6c83dd34300f4a13950036b01c0e2cad1b0.tar.bz2
Issue #11798: fix tests for regrtest -R :
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/regrtest.py5
-rw-r--r--Lib/unittest/suite.py8
-rw-r--r--Lib/unittest/test/test_suite.py8
3 files changed, 19 insertions, 2 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 03f168e..1f734c4 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -496,6 +496,8 @@ def main(tests=None, **kwargs):
if ns.slaveargs is not None:
args, kwargs = json.loads(ns.slaveargs)
+ if kwargs.get('huntrleaks'):
+ unittest.BaseTestSuite._cleanup = False
try:
result = runtest(*args, **kwargs)
except KeyboardInterrupt:
@@ -528,6 +530,9 @@ def main(tests=None, **kwargs):
#gc.set_debug(gc.DEBUG_SAVEALL)
found_garbage = []
+ if ns.huntrleaks:
+ unittest.BaseTestSuite._cleanup = False
+
if ns.single:
filename = os.path.join(TEMPDIR, 'pynexttest')
try:
diff --git a/Lib/unittest/suite.py b/Lib/unittest/suite.py
index 176af57..ca82765 100644
--- a/Lib/unittest/suite.py
+++ b/Lib/unittest/suite.py
@@ -16,6 +16,8 @@ def _call_if_exists(parent, attr):
class BaseTestSuite(object):
"""A simple test suite that doesn't provide class or module shared fixtures.
"""
+ _cleanup = True
+
def __init__(self, tests=()):
self._tests = []
self.addTests(tests)
@@ -61,7 +63,8 @@ class BaseTestSuite(object):
if result.shouldStop:
break
test(result)
- self._removeTestAtIndex(index)
+ if self._cleanup:
+ self._removeTestAtIndex(index)
return result
def _removeTestAtIndex(self, index):
@@ -115,7 +118,8 @@ class TestSuite(BaseTestSuite):
else:
test.debug()
- self._removeTestAtIndex(index)
+ if self._cleanup:
+ self._removeTestAtIndex(index)
if topLevel:
self._tearDownPreviousClass(None, result)
diff --git a/Lib/unittest/test/test_suite.py b/Lib/unittest/test/test_suite.py
index 1ad9b56..54cec6e 100644
--- a/Lib/unittest/test/test_suite.py
+++ b/Lib/unittest/test/test_suite.py
@@ -303,6 +303,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite.run(unittest.TestResult())
def test_remove_test_at_index(self):
+ if not unittest.BaseTestSuite._cleanup:
+ raise unittest.SkipTest("Suite cleanup is disabled")
+
suite = unittest.TestSuite()
suite._tests = [1, 2, 3]
@@ -311,6 +314,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
self.assertEqual([1, None, 3], suite._tests)
def test_remove_test_at_index_not_indexable(self):
+ if not unittest.BaseTestSuite._cleanup:
+ raise unittest.SkipTest("Suite cleanup is disabled")
+
suite = unittest.TestSuite()
suite._tests = None
@@ -318,6 +324,8 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite._removeTestAtIndex(2)
def assert_garbage_collect_test_after_run(self, TestSuiteClass):
+ if not unittest.BaseTestSuite._cleanup:
+ raise unittest.SkipTest("Suite cleanup is disabled")
class Foo(unittest.TestCase):
def test_nothing(self):