summaryrefslogtreecommitdiffstats
path: root/Lib/test/support/__init__.py
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-04-04 18:10:46 (GMT)
committerGitHub <noreply@github.com>2024-04-04 18:10:46 (GMT)
commit42205143f8b3211d1392f1d9f2cf6717bdaa5b47 (patch)
tree0f1c7cb3e548bd1fd726d27aa59486534e5af29d /Lib/test/support/__init__.py
parentde5ca0bf71760aad8f2b8449c89242498bff64c8 (diff)
downloadcpython-42205143f8b3211d1392f1d9f2cf6717bdaa5b47.zip
cpython-42205143f8b3211d1392f1d9f2cf6717bdaa5b47.tar.gz
cpython-42205143f8b3211d1392f1d9f2cf6717bdaa5b47.tar.bz2
gh-117478: Add `@support.requires_gil_enabled` decorator (#117479)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r--Lib/test/support/__init__.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index d7bc416..2be9cd0 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -29,7 +29,7 @@ __all__ = [
"captured_stdin", "captured_stderr",
# unittest
"is_resource_enabled", "requires", "requires_freebsd_version",
- "requires_linux_version", "requires_mac_ver",
+ "requires_gil_enabled", "requires_linux_version", "requires_mac_ver",
"check_syntax_error",
"requires_gzip", "requires_bz2", "requires_lzma",
"bigmemtest", "bigaddrspacetest", "cpython_only", "get_attribute",
@@ -837,6 +837,11 @@ def check_cflags_pgo():
Py_GIL_DISABLED = bool(sysconfig.get_config_var('Py_GIL_DISABLED'))
+
+def requires_gil_enabled(msg="needs the GIL enabled"):
+ """Decorator for skipping tests on the free-threaded build."""
+ return unittest.skipIf(Py_GIL_DISABLED, msg)
+
if Py_GIL_DISABLED:
_header = 'PHBBInP'
else: