[Python-Dev] [Python-checkins] cpython: Issue #11798: fix tests for regrtest -R : (original) (raw)

Andrew Svetlov andrew.svetlov at gmail.com
Mon Sep 2 04:37:20 CEST 2013


regrtest -R runs test suites several times. That's why test cleanup should be disabled for this case. Details discussed in issue. I'll do more expressive commit messages next time. Thanks.

On Mon, Sep 2, 2013 at 1:58 AM, Eli Bendersky <eliben at gmail.com> wrote:

On Sat, Aug 31, 2013 at 9:58 PM, andrew.svetlov <python-checkins at python.org> wrote: http://hg.python.org/cpython/rev/39781c3737f8 changeset: 85490:39781c3737f8 user: Andrew Svetlov <andrew.svetlov at gmail.com> date: Sun Sep 01 07:58:41 2013 +0300 summary: Issue #11798: fix tests for regrtest -R : files: Lib/test/regrtest.py | 5 +++++ Lib/unittest/suite.py | 8 ++++++-- Lib/unittest/test/testsuite.py | 8 ++++++++ 3 files changed, 19 insertions(+), 2 deletions(-)

Hi Andrew, It would help if you could add more details into the commit message. This would make both post-commit reviews and future code archeology simpler. Eli diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -496,6 +496,8 @@ 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 @@ #gc.setdebug(gc.DEBUGSAVEALL) foundgarbage = [] + 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 --- a/Lib/unittest/suite.py +++ b/Lib/unittest/suite.py @@ -16,6 +16,8 @@ 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 @@ 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 @@ else: test.debug() - self.removeTestAtIndex(index) + if self.cleanup: + self.removeTestAtIndex(index) if topLevel: self.tearDownPreviousClass(None, result) diff --git a/Lib/unittest/test/testsuite.py b/Lib/unittest/test/testsuite.py --- a/Lib/unittest/test/testsuite.py +++ b/Lib/unittest/test/testsuite.py @@ -303,6 +303,9 @@ suite.run(unittest.TestResult()) def testremovetestatindex(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 @@ self.assertEqual([1, None, 3], suite.tests) def testremovetestatindexnotindexable(self): + if not unittest.BaseTestSuite.cleanup: + raise unittest.SkipTest("Suite cleanup is disabled") + suite = unittest.TestSuite() suite.tests = None @@ -318,6 +324,8 @@ suite.removeTestAtIndex(2) def assertgarbagecollecttestafterrun(self, TestSuiteClass): + if not unittest.BaseTestSuite.cleanup: + raise unittest.SkipTest("Suite cleanup is disabled") class Foo(unittest.TestCase): def testnothing(self): -- Repository URL: http://hg.python.org/cpython


Python-checkins mailing list Python-checkins at python.org http://mail.python.org/mailman/listinfo/python-checkins


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com

-- Thanks, Andrew Svetlov



More information about the Python-Dev mailing list