]> granicus.if.org Git - python/commitdiff
bpo-30604: Skip CoExtra tests if ctypes is missing (#2356) (#2358)
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 23 Jun 2017 13:24:28 +0000 (15:24 +0200)
committerGitHub <noreply@github.com>
Fri, 23 Jun 2017 13:24:28 +0000 (15:24 +0200)
(cherry picked from commit a4b091e135ccf345cfafdd8477aef897c5214f82)

Lib/test/test_code.py

index 9f9df9dba6b3d680096b8c877287eec4fb405416..68537482ac91f3415fa339e1577d51a8e80dc7c4 100644 (file)
@@ -106,6 +106,10 @@ import sys
 import threading
 import unittest
 import weakref
+try:
+    import ctypes
+except ImportError:
+    ctypes = None
 from test.support import (run_doctest, run_unittest, cpython_only,
                           check_impl_detail)
 
@@ -214,8 +218,7 @@ class CodeWeakRefTest(unittest.TestCase):
         self.assertTrue(self.called)
 
 
-if check_impl_detail(cpython=True):
-    import ctypes
+if check_impl_detail(cpython=True) and ctypes is not None:
     py = ctypes.pythonapi
     freefunc = ctypes.CFUNCTYPE(None,ctypes.c_voidp)
 
@@ -311,7 +314,7 @@ def test_main(verbose=None):
     from test import test_code
     run_doctest(test_code, verbose)
     tests = [CodeTest, CodeConstsTest, CodeWeakRefTest]
-    if check_impl_detail(cpython=True):
+    if check_impl_detail(cpython=True) and ctypes is not None:
         tests.append(CoExtra)
     run_unittest(*tests)