]> granicus.if.org Git - python/commitdiff
Added unittest for calling a function with paramflags (backport from py3k branch).
authorThomas Heller <theller@ctypes.org>
Wed, 24 Oct 2007 19:50:45 +0000 (19:50 +0000)
committerThomas Heller <theller@ctypes.org>
Wed, 24 Oct 2007 19:50:45 +0000 (19:50 +0000)
Lib/ctypes/test/test_prototypes.py

index 9f020866f4a19676dad8670956304150e0852330..5a4117a5a6402ddbd76714ddb9ab33e588f86833 100644 (file)
@@ -48,6 +48,24 @@ class CharPointersTestCase(unittest.TestCase):
         func.restype = c_long
         func.argtypes = None
 
+    def test_paramflags(self):
+        # function returns c_void_p result,
+        # and has a required parameter named 'input'
+        prototype = CFUNCTYPE(c_void_p, c_void_p)
+        func = prototype(("_testfunc_p_p", testdll),
+                         ((1, "input"),))
+
+        try:
+            func()
+        except TypeError as details:
+            self.failUnlessEqual(str(details), "required argument 'input' missing")
+        else:
+            self.fail("TypeError not raised")
+
+        self.failUnlessEqual(func(None), None)
+        self.failUnlessEqual(func(input=None), None)
+
+
     def test_int_pointer_arg(self):
         func = testdll._testfunc_p_p
         func.restype = c_long