Issue #22104: Don't hold a reference to the loaded TestSuite in runtest_inner
authorZachary Ware <zachary.ware@gmail.com>
Mon, 4 Aug 2014 16:15:10 +0000 (11:15 -0500)
committerZachary Ware <zachary.ware@gmail.com>
Mon, 4 Aug 2014 16:15:10 +0000 (11:15 -0500)
Lib/test/regrtest.py
Misc/NEWS

index c1c831ff867c037fa4e3c297df8512a019291e1e..b633631b00d9a21e7658fec50c1a575719ef2b1b 100755 (executable)
@@ -1273,8 +1273,10 @@ def runtest_inner(test, verbose, quiet,
             # tests.  If not, use normal unittest test loading.
             test_runner = getattr(the_module, "test_main", None)
             if test_runner is None:
-                tests = unittest.TestLoader().loadTestsFromModule(the_module)
-                test_runner = lambda: support.run_unittest(tests)
+                def test_runner():
+                    loader = unittest.TestLoader()
+                    tests = loader.loadTestsFromModule(the_module)
+                    support.run_unittest(tests)
             test_runner()
             if huntrleaks:
                 refleak = dash_R(the_module, test, test_runner, huntrleaks)
index b554afd4b5c4cd6bba46ed0d60b843d97b7dfb17..21b5ffa417022a82aaf6cac306da6a97d38aa5d9 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -239,6 +239,9 @@ IDLE
 Tests
 -----
 
+- Issue #22104: regrtest.py no longer holds a reference to the suite of tests
+  loaded from test modules that don't define test_main().
+
 - Issue #22002: Added ``load_package_tests`` function to test.support and used
   it to implement/augment test discovery in test_asyncio, test_email,
   test_importlib, test_json, and test_tools.