Skip to content

Commit 4849a80

Browse files
gh-102251: Disable non-rerunnable test in test_import (#106013)
1 parent 8ef0ee4 commit 4849a80

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Lib/test/test_import/__init__.py

+20-4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,25 @@ def remove_files(name):
107107
rmtree('__pycache__')
108108

109109

110+
def no_rerun(reason):
111+
"""Skip rerunning for a particular test.
112+
113+
WARNING: Use this decorator with care; skipping rerunning makes it
114+
impossible to find reference leaks. Provide a clear reason for skipping the
115+
test using the 'reason' parameter.
116+
"""
117+
def deco(func):
118+
_has_run = False
119+
def wrapper(self):
120+
nonlocal _has_run
121+
if _has_run:
122+
self.skipTest(reason)
123+
func(self)
124+
_has_run = True
125+
return wrapper
126+
return deco
127+
128+
110129
@contextlib.contextmanager
111130
def _ready_to_import(name=None, source=""):
112131
# sets up a temporary directory and removes it
@@ -1989,10 +2008,6 @@ class SinglephaseInitTests(unittest.TestCase):
19892008

19902009
@classmethod
19912010
def setUpClass(cls):
1992-
if '-R' in sys.argv or '--huntrleaks' in sys.argv:
1993-
# https://github.com/python/cpython/issues/102251
1994-
raise unittest.SkipTest('unresolved refleaks (see gh-102251)')
1995-
19962011
spec = importlib.util.find_spec(cls.NAME)
19972012
from importlib.machinery import ExtensionFileLoader
19982013
cls.FILE = spec.origin
@@ -2502,6 +2517,7 @@ def test_basic_multiple_interpreters_main_no_reset(self):
25022517
# * m_copy was copied from interp2 (was from interp1)
25032518
# * module's global state was updated, not reset
25042519

2520+
@no_rerun(reason="rerun not possible; module state is never cleared (see gh-102251)")
25052521
@requires_subinterpreters
25062522
def test_basic_multiple_interpreters_deleted_no_reset(self):
25072523
# without resetting; already loaded in a deleted interpreter

0 commit comments

Comments
 (0)