Back to index

python3.2  3.2.2
Public Member Functions
ctypes.test.test_simplesubclasses.Test Class Reference

List of all members.

Public Member Functions

def test_compare
def test_ignore_retval
def test_int_callback
def test_int_struct

Detailed Description

Definition at line 10 of file test_simplesubclasses.py.


Member Function Documentation

Definition at line 12 of file test_simplesubclasses.py.

00012 
00013     def test_compare(self):
00014         self.assertEqual(MyInt(3), MyInt(3))
00015         self.assertNotEqual(MyInt(42), MyInt(43))

Here is the call graph for this function:

Definition at line 16 of file test_simplesubclasses.py.

00016 
00017     def test_ignore_retval(self):
00018         # Test if the return value of a callback is ignored
00019         # if restype is None
00020         proto = CFUNCTYPE(None)
00021         def func():
00022             return (1, "abc", None)
00023 
00024         cb = proto(func)
00025         self.assertEqual(None, cb())
00026 

Here is the call graph for this function:

Definition at line 27 of file test_simplesubclasses.py.

00027 
00028     def test_int_callback(self):
00029         args = []
00030         def func(arg):
00031             args.append(arg)
00032             return arg
00033 
00034         cb = CFUNCTYPE(None, MyInt)(func)
00035 
00036         self.assertEqual(None, cb(42))
00037         self.assertEqual(type(args[-1]), MyInt)
00038 
00039         cb = CFUNCTYPE(c_int, c_int)(func)
00040 
00041         self.assertEqual(42, cb(42))
00042         self.assertEqual(type(args[-1]), int)

Here is the call graph for this function:

Definition at line 43 of file test_simplesubclasses.py.

00043 
00044     def test_int_struct(self):
00045         class X(Structure):
00046             _fields_ = [("x", MyInt)]
00047 
00048         self.assertEqual(X().x, MyInt())
00049 
00050         s = X()
00051         s.x = MyInt(42)
00052 
00053         self.assertEqual(s.x, MyInt(42))

Here is the call graph for this function:


The documentation for this class was generated from the following file: