Skip to content

Commit e948a1a

Browse files
Update test file
1 parent 5587067 commit e948a1a

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

Lib/test/test_ctypes/test_pointers.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,16 @@ class Cls(Structure):
404404
self.assertEqual(len(ws_typ), 0, ws_typ)
405405
self.assertEqual(len(ws_ptr), 0, ws_ptr)
406406

407+
def test_pointer_proto_missing_argtypes_error(self):
408+
class BadType(ctypes._Pointer):
409+
# _type_ is intentionally missing
410+
pass
411+
412+
func = ctypes.pythonapi.Py_GetVersion
413+
func.argtypes = (BadType,)
414+
415+
with self.assertRaises(ctypes.ArgumentError):
416+
func(None)
407417

408418
class PointerTypeCacheTestCase(unittest.TestCase):
409419
# dummy tests to check warnings and base behavior
@@ -473,23 +483,6 @@ class C(Structure):
473483
ptr.set_type(c_int)
474484
self.assertIs(ptr._type_, c_int)
475485

476-
class TestPointerStringProto(unittest.TestCase):
477-
def test_pointer_string_proto_argtypes_error(self):
478-
with self.assertWarns(DeprecationWarning):
479-
BadType = ctypes.POINTER("BugTrigger")
480-
481-
if os.name == "nt":
482-
libc = ctypes.WinDLL("kernel32.dll")
483-
func = libc.GetCurrentProcessId
484-
else:
485-
libc = ctypes.CDLL(None)
486-
func = libc.getpid
487-
488-
func.argtypes = (BadType,)
489-
490-
with self.assertRaises(ctypes.ArgumentError):
491-
func(ctypes.byref(ctypes.c_int(0)))
492-
493486

494487
if __name__ == '__main__':
495488
unittest.main()

0 commit comments

Comments
 (0)