diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-09-22 20:51:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-22 20:51:58 (GMT) |
commit | 8ded34a1ff2d355e95213ab72493908f2ca25dd9 (patch) | |
tree | 68cbfed2bb3f53e1b92248e76d0bfa6d289d14a4 | |
parent | 8a82bff12c8e6c6c204c8a48ee4993d908ec4b73 (diff) | |
download | cpython-8ded34a1ff2d355e95213ab72493908f2ca25dd9.zip cpython-8ded34a1ff2d355e95213ab72493908f2ca25dd9.tar.gz cpython-8ded34a1ff2d355e95213ab72493908f2ca25dd9.tar.bz2 |
gh-109721: Guard `_testinternalcapi` imports in tests (GH-109722)
-rw-r--r-- | Lib/test/test_cmd_line.py | 1 | ||||
-rw-r--r-- | Lib/test/test_import/__init__.py | 5 | ||||
-rw-r--r-- | Lib/test/test_opcache.py | 8 |
3 files changed, 11 insertions, 3 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index e88b7c8..f4754db 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -799,6 +799,7 @@ class CmdLineTest(unittest.TestCase): self.assertEqual(proc.stdout.rstrip(), name) self.assertEqual(proc.returncode, 0) + @support.cpython_only def test_pythonmalloc(self): # Test the PYTHONMALLOC environment variable pymalloc = support.with_pymalloc() diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py index a302a60..48553f9 100644 --- a/Lib/test/test_import/__init__.py +++ b/Lib/test/test_import/__init__.py @@ -22,7 +22,6 @@ import time import types import unittest from unittest import mock -import _testinternalcapi import _imp from test.support import os_helper @@ -50,6 +49,10 @@ try: import _xxsubinterpreters as _interpreters except ModuleNotFoundError: _interpreters = None +try: + import _testinternalcapi +except ImportError: + _testinternalcapi = None skip_if_dont_write_bytecode = unittest.skipIf( diff --git a/Lib/test/test_opcache.py b/Lib/test/test_opcache.py index 692e03f..2b2783d 100644 --- a/Lib/test/test_opcache.py +++ b/Lib/test/test_opcache.py @@ -4,13 +4,17 @@ import dis import threading import types import unittest -from test.support import threading_helper +from test.support import threading_helper, check_impl_detail + +# Skip this module on other interpreters, it is cpython specific: +if check_impl_detail(cpython=False): + raise unittest.SkipTest('implementation detail specific to cpython') + import _testinternalcapi def disabling_optimizer(func): def wrapper(*args, **kwargs): - import _testinternalcapi old_opt = _testinternalcapi.get_optimizer() _testinternalcapi.set_optimizer(None) try: |