Skip to content

Commit 9208c1d

Browse files
committed
Isolate reloading modules in test_interpreters
1 parent 48795b6 commit 9208c1d

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
@@ -39,7 +38,12 @@ class LowLevelTests(TestBase):
3938

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

4448
def test_create_destroy(self):
4549
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)