diff --git a/Lib/test/test_interpreters/test_channels.py b/Lib/test/test_interpreters/test_channels.py index 52827357078b85..13af52d1d645e7 100644 --- a/Lib/test/test_interpreters/test_channels.py +++ b/Lib/test/test_interpreters/test_channels.py @@ -1,4 +1,3 @@ -import importlib import pickle import threading from textwrap import dedent @@ -28,7 +27,12 @@ class LowLevelTests(TestBase): def test_highlevel_reloaded(self): # See gh-115490 (https://github.com/python/cpython/issues/115490). - importlib.reload(channels) + interp = interpreters.create() + interp.exec(dedent(f""" + import importlib + from test.support import channels + importlib.reload(channels) + """)); class TestChannels(TestBase): diff --git a/Lib/test/test_interpreters/test_queues.py b/Lib/test/test_interpreters/test_queues.py index 77334aea3836b9..d415cb0e1f0ab9 100644 --- a/Lib/test/test_interpreters/test_queues.py +++ b/Lib/test/test_interpreters/test_queues.py @@ -1,4 +1,3 @@ -import importlib import pickle import threading from textwrap import dedent @@ -39,7 +38,12 @@ class LowLevelTests(TestBase): def test_highlevel_reloaded(self): # See gh-115490 (https://github.com/python/cpython/issues/115490). - importlib.reload(queues) + interp = interpreters.create() + interp.exec(dedent(f""" + import importlib + from concurrent.interpreters import _queues as queues + importlib.reload(queues) + """)); def test_create_destroy(self): qid = _queues.create(2, REPLACE, -1) diff --git a/Misc/NEWS.d/next/Tests/2026-01-21-02-03-31.gh-issue-142414.CfcgiR.rst b/Misc/NEWS.d/next/Tests/2026-01-21-02-03-31.gh-issue-142414.CfcgiR.rst new file mode 100644 index 00000000000000..6d4cbfc490a17d --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-01-21-02-03-31.gh-issue-142414.CfcgiR.rst @@ -0,0 +1,2 @@ +Isolate reloading modules in test_interpreters to avoid having broken +references.