]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-120579: Guard `_testcapi` import in `test_free_threading` (GH-120580) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 16 Jun 2024 08:50:33 +0000 (10:50 +0200)
committerGitHub <noreply@github.com>
Sun, 16 Jun 2024 08:50:33 +0000 (08:50 +0000)
gh-120579: Guard `_testcapi` import in `test_free_threading` (GH-120580)
(cherry picked from commit 0c0348adbfca991f78b3aaa6790e5c26606a1c0f)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/test/test_free_threading/test_dict.py

index f877582e6b565c987f2ba5cab3be9d4ae9ee60fc..3126458e08e50abe927b052e47baa7f9140a47e7 100644 (file)
@@ -8,7 +8,10 @@ from functools import partial
 from threading import Thread
 from unittest import TestCase
 
-from _testcapi import dict_version
+try:
+    import _testcapi
+except ImportError:
+    _testcapi = None
 
 from test.support import threading_helper
 
@@ -139,7 +142,9 @@ class TestDict(TestCase):
             for ref in thread_list:
                 self.assertIsNone(ref())
 
+    @unittest.skipIf(_testcapi is None, 'need _testcapi module')
     def test_dict_version(self):
+        dict_version = _testcapi.dict_version
         THREAD_COUNT = 10
         DICT_COUNT = 10000
         lists = []