[Python-checkins] r87392 - in python/branches/py3k/Lib/unittest: suite.py test/test_suite.py

michael.foord python-checkins at python.org
Sun Dec 19 05:07:29 CET 2010


Author: michael.foord
Date: Sun Dec 19 05:07:28 2010
New Revision: 87392

Log:
Improvement to fix for issue 9926 to allow TestResult to be reused.

Modified:
   python/branches/py3k/Lib/unittest/suite.py
   python/branches/py3k/Lib/unittest/test/test_suite.py

Modified: python/branches/py3k/Lib/unittest/suite.py
==============================================================================
--- python/branches/py3k/Lib/unittest/suite.py	(original)
+++ python/branches/py3k/Lib/unittest/suite.py	Sun Dec 19 05:07:28 2010
@@ -104,6 +104,7 @@
         if topLevel:
             self._tearDownPreviousClass(None, result)
             self._handleModuleTearDown(result)
+            result._testRunEntered = False
         return result
 
     def debug(self):

Modified: python/branches/py3k/Lib/unittest/test/test_suite.py
==============================================================================
--- python/branches/py3k/Lib/unittest/test/test_suite.py	(original)
+++ python/branches/py3k/Lib/unittest/test/test_suite.py	Sun Dec 19 05:07:28 2010
@@ -353,11 +353,16 @@
                 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()


More information about the Python-checkins mailing list