Skip to content

Commit cea2174

Browse files
authored
bpo-30604: Skip CoExtra tests if ctypes is missing (#2356) (#2358)
(cherry picked from commit a4b091e)
1 parent d32a059 commit cea2174

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Lib/test/test_code.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@
106106
import threading
107107
import unittest
108108
import weakref
109+
try:
110+
import ctypes
111+
except ImportError:
112+
ctypes = None
109113
from test.support import (run_doctest, run_unittest, cpython_only,
110114
check_impl_detail)
111115

@@ -214,8 +218,7 @@ def callback(code):
214218
self.assertTrue(self.called)
215219

216220

217-
if check_impl_detail(cpython=True):
218-
import ctypes
221+
if check_impl_detail(cpython=True) and ctypes is not None:
219222
py = ctypes.pythonapi
220223
freefunc = ctypes.CFUNCTYPE(None,ctypes.c_voidp)
221224

@@ -311,7 +314,7 @@ def test_main(verbose=None):
311314
from test import test_code
312315
run_doctest(test_code, verbose)
313316
tests = [CodeTest, CodeConstsTest, CodeWeakRefTest]
314-
if check_impl_detail(cpython=True):
317+
if check_impl_detail(cpython=True) and ctypes is not None:
315318
tests.append(CoExtra)
316319
run_unittest(*tests)
317320

0 commit comments

Comments
 (0)