From 5657ff8aa0aa9d53f92fc11cc2d4b7e23f5cb95a Mon Sep 17 00:00:00 2001 From: Michael Foord Date: Sun, 19 Dec 2010 14:12:23 +0000 Subject: [PATCH] Improvement to fix for issue 9926 to allow TestResult to be reused. --- Lib/unittest/suite.py | 1 + Lib/unittest/test/test_suite.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/unittest/suite.py b/Lib/unittest/suite.py index e8fbdc31fed..c0ae2aeeb66 100644 --- a/Lib/unittest/suite.py +++ b/Lib/unittest/suite.py @@ -107,6 +107,7 @@ class TestSuite(BaseTestSuite): if topLevel: self._tearDownPreviousClass(None, result) self._handleModuleTearDown(result) + result._testRunEntered = False return result def debug(self): diff --git a/Lib/unittest/test/test_suite.py b/Lib/unittest/test/test_suite.py index d212bd05dc4..72fb527a685 100644 --- a/Lib/unittest/test/test_suite.py +++ b/Lib/unittest/test/test_suite.py @@ -353,11 +353,15 @@ class Test_TestSuite(unittest.TestCase, TestEquality): unittest.TestSuite.__call__(self, *args, **kw) suite = MySuite() + result = unittest.TestResult() wrapper = unittest.TestSuite() wrapper.addTest(suite) - wrapper(unittest.TestResult()) + wrapper(result) self.assertTrue(suite.called) + # reusing results should be permitted even if abominable + self.assertFalse(result._testRunEntered) + if __name__ == '__main__': unittest.main()