Skip to content

Commit f81c03a

Browse files
Allactagancoghlan
andauthored
gh-142414: Isolate reloading modules in test_interpreters (#144096)
Isolate reloading modules in test_interpreters Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
1 parent 41b3f0a commit f81c03a

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

Lib/test/test_interpreters/test_channels.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import importlib
21
import pickle
32
import threading
43
from textwrap import dedent
@@ -28,7 +27,12 @@ class LowLevelTests(TestBase):
2827

2928
def test_highlevel_reloaded(self):
3029
# See gh-115490 (https://github.com/python/cpython/issues/115490).
31-
importlib.reload(channels)
30+
interp = interpreters.create()
31+
interp.exec(dedent(f"""
32+
import importlib
33+
from test.support import channels
34+
importlib.reload(channels)
35+
"""));
3236

3337

3438
class TestChannels(TestBase):

Lib/test/test_interpreters/test_queues.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import importlib
21
import pickle
32
import threading
43
from textwrap import dedent
@@ -41,7 +40,12 @@ class LowLevelTests(TestBase):
4140

4241
def test_highlevel_reloaded(self):
4342
# See gh-115490 (https://github.com/python/cpython/issues/115490).
44-
importlib.reload(queues)
43+
interp = interpreters.create()
44+
interp.exec(dedent(f"""
45+
import importlib
46+
from concurrent.interpreters import _queues as queues
47+
importlib.reload(queues)
48+
"""));
4549

4650
def test_create_destroy(self):
4751
qid = _queues.create(2, REPLACE, -1)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Isolate reloading modules in test_interpreters to avoid having broken
2+
references.

0 commit comments

Comments
 (0)