summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-09-18 14:31:01 (GMT)
committerGitHub <noreply@github.com>2023-09-18 14:31:01 (GMT)
commitf6fc831aa96f82b74c8dae9a20dc88c89e457967 (patch)
treeffd51f59334d8b49f3963f2199decb642dc836a9 /Lib/test
parentfbf703ce6e1a17ced464396f4a48f69f1c777b8a (diff)
downloadcpython-f6fc831aa96f82b74c8dae9a20dc88c89e457967.zip
cpython-f6fc831aa96f82b74c8dae9a20dc88c89e457967.tar.gz
cpython-f6fc831aa96f82b74c8dae9a20dc88c89e457967.tar.bz2
[3.12] gh-102251: Disable non-rerunnable test in test_import (GH-106013) (#109540)
gh-102251: Disable non-rerunnable test in test_import (GH-106013) (cherry picked from commit 4849a80dd1cbbc5010e8749ba60eb91a541ae4e7) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_import/__init__.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py
index f7df6d7..62585b2 100644
--- a/Lib/test/test_import/__init__.py
+++ b/Lib/test/test_import/__init__.py
@@ -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
@@ -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
@@ -2535,6 +2550,7 @@ class SinglephaseInitTests(unittest.TestCase):
# * 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