Back to index

python3.2  3.2.2
Public Member Functions
ctypes.test.test_structures.SubclassesTest Class Reference

List of all members.

Public Member Functions

def test_subclass
def test_subclass_delayed

Detailed Description

Definition at line 5 of file test_structures.py.


Member Function Documentation

Definition at line 6 of file test_structures.py.

00006 
00007     def test_subclass(self):
00008         class X(Structure):
00009             _fields_ = [("a", c_int)]
00010 
00011         class Y(X):
00012             _fields_ = [("b", c_int)]
00013 
00014         class Z(X):
00015             pass
00016 
00017         self.assertEqual(sizeof(X), sizeof(c_int))
00018         self.assertEqual(sizeof(Y), sizeof(c_int)*2)
00019         self.assertEqual(sizeof(Z), sizeof(c_int))
00020         self.assertEqual(X._fields_, [("a", c_int)])
00021         self.assertEqual(Y._fields_, [("b", c_int)])
00022         self.assertEqual(Z._fields_, [("a", c_int)])

Definition at line 23 of file test_structures.py.

00023 
00024     def test_subclass_delayed(self):
00025         class X(Structure):
00026             pass
00027         self.assertEqual(sizeof(X), 0)
00028         X._fields_ = [("a", c_int)]
00029 
00030         class Y(X):
00031             pass
00032         self.assertEqual(sizeof(Y), sizeof(X))
00033         Y._fields_ = [("b", c_int)]
00034 
00035         class Z(X):
00036             pass
00037 
00038         self.assertEqual(sizeof(X), sizeof(c_int))
00039         self.assertEqual(sizeof(Y), sizeof(c_int)*2)
00040         self.assertEqual(sizeof(Z), sizeof(c_int))
00041         self.assertEqual(X._fields_, [("a", c_int)])
00042         self.assertEqual(Y._fields_, [("b", c_int)])
00043         self.assertEqual(Z._fields_, [("a", c_int)])


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