gh-105751: test_ctypes avoids "from ctypes import *" by vstinner · Pull Request #105768 · python/cpython
@@ -1,16 +1,18 @@
import unittest
import _ctypes_test
import ctypes
from ctypes import *
import unittest
from ctypes import (CDLL, Structure, CFUNCTYPE, sizeof,
c_void_p, c_char_p, c_char, c_int, c_uint, c_long)
try: WINFUNCTYPE = ctypes.WINFUNCTYPE except AttributeError: # fake to enable this test on Linux WINFUNCTYPE = CFUNCTYPE
import _ctypes_test lib = CDLL(_ctypes_test.__file__)
class CFuncPtrTestCase(unittest.TestCase): def test_basic(self): X = WINFUNCTYPE(c_int, c_int, c_int)Expand All
@@ -21,8 +23,8 @@ def func(*args):
x = X(func)
self.assertEqual(x.restype, c_int)
self.assertEqual(x.argtypes, (c_int, c_int))
self.assertEqual(sizeof(x), sizeof(c_voidp))
self.assertEqual(sizeof(X), sizeof(c_voidp))
self.assertEqual(sizeof(x), sizeof(c_void_p))
self.assertEqual(sizeof(X), sizeof(c_void_p))
def test_first(self): StdCallback = WINFUNCTYPE(c_int, c_int, c_int)Expand Down
Expand Up
@@ -129,5 +131,6 @@ def test_abstract(self):
self.assertRaises(TypeError, _CFuncPtr, 13, "name", 42, "iid")
if __name__ == '__main__': unittest.main()
try: WINFUNCTYPE = ctypes.WINFUNCTYPE except AttributeError: # fake to enable this test on Linux WINFUNCTYPE = CFUNCTYPE
import _ctypes_test lib = CDLL(_ctypes_test.__file__)
class CFuncPtrTestCase(unittest.TestCase): def test_basic(self): X = WINFUNCTYPE(c_int, c_int, c_int)
def test_first(self): StdCallback = WINFUNCTYPE(c_int, c_int, c_int)
self.assertRaises(TypeError, _CFuncPtr, 13, "name", 42, "iid")
if __name__ == '__main__': unittest.main()