Skip to content

Commit

Permalink
[3.12] gh-102251: Disable non-rerunnable test in test_import (GH-106013
Browse files Browse the repository at this point in the history
…) (#109540)

gh-102251: Disable non-rerunnable test in test_import (GH-106013)
(cherry picked from commit 4849a80)

Co-authored-by: Erlend E. Aasland <[email protected]>
  • Loading branch information
miss-islington and erlend-aasland authored Sep 18, 2023
1 parent fbf703c commit f6fc831
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,25 @@ def remove_files(name):
rmtree('__pycache__')


def no_rerun(reason):
"""Skip rerunning for a particular test.
WARNING: Use this decorator with care; skipping rerunning makes it
impossible to find reference leaks. Provide a clear reason for skipping the
test using the 'reason' parameter.
"""
def deco(func):
_has_run = False
def wrapper(self):
nonlocal _has_run
if _has_run:
self.skipTest(reason)
func(self)
_has_run = True
return wrapper
return deco


@contextlib.contextmanager
def _ready_to_import(name=None, source=""):
# sets up a temporary directory and removes it
Expand Down Expand Up @@ -2018,10 +2037,6 @@ class SinglephaseInitTests(unittest.TestCase):

@classmethod
def setUpClass(cls):
if '-R' in sys.argv or '--huntrleaks' in sys.argv:
# https://github.com/python/cpython/issues/102251
raise unittest.SkipTest('unresolved refleaks (see gh-102251)')

spec = importlib.util.find_spec(cls.NAME)
from importlib.machinery import ExtensionFileLoader
cls.FILE = spec.origin
Expand Down Expand Up @@ -2535,6 +2550,7 @@ def test_basic_multiple_interpreters_main_no_reset(self):
# * m_copy was copied from interp2 (was from interp1)
# * module's global state was updated, not reset

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

0 comments on commit f6fc831

Please sign in to comment.