]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-75876: Use functools.wraps() in test.support test decorators (GH-155262)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 6 Aug 2026 15:09:22 +0000 (18:09 +0300)
committerGitHub <noreply@github.com>
Thu, 6 Aug 2026 15:09:22 +0000 (18:09 +0300)
bigmemtest(), bigaddrspacetest() and no_rerun() returned a wrapper named
"wrapper", so a decorator applied on top of them could not identify the test.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Lib/test/support/__init__.py

index 7898ef5e15b2c4043c139cc2443bcc35932276a5..74d3794289bf69f657061482b926f0f8060c12e7 100644 (file)
@@ -1293,6 +1293,7 @@ def bigmemtest(size, memuse, dry_run=True):
     test doesn't support dummy runs when -M is not specified.
     """
     def decorator(f):
+        @functools.wraps(f)
         def wrapper(self):
             size = wrapper.size
             memuse = wrapper.memuse
@@ -1345,6 +1346,7 @@ def nomemtest(f):
 
 def bigaddrspacetest(f):
     """Decorator for tests that fill the address space."""
+    @functools.wraps(f)
     def wrapper(self):
         if max_memuse < MAX_Py_ssize_t:
             if MAX_Py_ssize_t >= 2**63 - 1 and max_memuse >= 2**31:
@@ -1450,6 +1452,7 @@ def no_rerun(reason):
     def deco(func):
         assert not isinstance(func, type), func
         _has_run = False
+        @functools.wraps(func)
         def wrapper(self):
             nonlocal _has_run
             if _has_run: