Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 69fb6a4

Browse files
committed
Issue #22104: Don't hold a reference to the loaded TestSuite in runtest_inner
1 parent d577480 commit 69fb6a4

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

Lib/test/regrtest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,8 +1273,10 @@ def runtest_inner(test, verbose, quiet,
12731273
# tests. If not, use normal unittest test loading.
12741274
test_runner = getattr(the_module, "test_main", None)
12751275
if test_runner is None:
1276-
tests = unittest.TestLoader().loadTestsFromModule(the_module)
1277-
test_runner = lambda: support.run_unittest(tests)
1276+
def test_runner():
1277+
loader = unittest.TestLoader()
1278+
tests = loader.loadTestsFromModule(the_module)
1279+
support.run_unittest(tests)
12781280
test_runner()
12791281
if huntrleaks:
12801282
refleak = dash_R(the_module, test, test_runner, huntrleaks)

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ IDLE
239239
Tests
240240
-----
241241

242+
- Issue #22104: regrtest.py no longer holds a reference to the suite of tests
243+
loaded from test modules that don't define test_main().
244+
242245
- Issue #22002: Added ``load_package_tests`` function to test.support and used
243246
it to implement/augment test discovery in test_asyncio, test_email,
244247
test_importlib, test_json, and test_tools.

0 commit comments

Comments
 (0)