]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-102251: Disable non-rerunnable test in test_import (#106013)
authorErlend E. Aasland <erlend.aasland@protonmail.com>
Fri, 23 Jun 2023 23:34:05 +0000 (01:34 +0200)
committerGitHub <noreply@github.com>
Fri, 23 Jun 2023 23:34:05 +0000 (01:34 +0200)
Lib/test/test_import/__init__.py

index e0e2354ae2f19f26f0874cea1a6ed0a5827f6e6b..ec8ccf0bd78d37fd1789c65e95178072f5687d8f 100644 (file)
@@ -107,6 +107,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
@@ -1989,10 +2008,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
@@ -2502,6 +2517,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