Back to index

python3.2  3.2.2
Classes | Functions | Variables
ctypes.test.test_structures Namespace Reference

Classes

class  SubclassesTest
class  StructureTestCase
class  PointerMemberTestCase
class  TestRecursiveStructure

Functions

def test_abstract_class
 def test_subclass_creation(self): meta = type(Structure)

same as 'class X(Structure): pass'

fails, since we need either a fields or a abstract attribute

cls, msg = self.get_except(meta, "X", (Structure,), {}) self.assertEqual((cls, msg), (AttributeError, "class must define a '<em>fields</em>' attribute"))
def test_methods
def test_positional_args
 class X(Structure): fields = []
def test_none_to_pointer_fields

Variables

list items = [s.array[i] for i in range(3)]
 s.array[1] = 42

Function Documentation

def test_subclass_creation(self): meta = type(Structure)

same as 'class X(Structure): pass'

fails, since we need either a fields or a abstract attribute

cls, msg = self.get_except(meta, "X", (Structure,), {}) self.assertEqual((cls, msg), (AttributeError, "class must define a '<em>fields</em>' attribute"))

Definition at line 337 of file test_structures.py.

00337 
00338     def test_abstract_class(self):
00339         class X(Structure):
00340             _abstract_ = "something"
00341         # try 'X()'
00342         cls, msg = self.get_except(eval, "X()", locals())
00343         self.assertEqual((cls, msg), (TypeError, "abstract class"))

Definition at line 344 of file test_structures.py.

00344 
    def test_methods(self):

Definition at line 402 of file test_structures.py.

00402 
00403     def test_none_to_pointer_fields(self):
00404         class S(Structure):
00405             _fields_ = [("x", c_int),
00406                         ("p", POINTER(c_int))]
00407 
00408         s = S()
00409         s.x = 12345678
00410         s.p = None
00411         self.assertEqual(s.x, 12345678)

class X(Structure): fields = []

Definition at line 352 of file test_structures.py.

00352 
00353     def test_positional_args(self):
00354         # see also http://bugs.python.org/issue5042
00355         class W(Structure):
00356             _fields_ = [("a", c_int), ("b", c_int)]
00357         class X(W):
00358             _fields_ = [("c", c_int)]
00359         class Y(X):
00360             pass
00361         class Z(Y):
00362             _fields_ = [("d", c_int), ("e", c_int), ("f", c_int)]
00363 
00364         z = Z(1, 2, 3, 4, 5, 6)
00365         self.assertEqual((z.a, z.b, z.c, z.d, z.e, z.f),
00366                          (1, 2, 3, 4, 5, 6))
00367         z = Z(1)
00368         self.assertEqual((z.a, z.b, z.c, z.d, z.e, z.f),
00369                          (1, 0, 0, 0, 0, 0))
00370         self.assertRaises(TypeError, lambda: Z(1, 2, 3, 4, 5, 6, 7))


Variable Documentation

list ctypes.test.test_structures.items = [s.array[i] for i in range(3)]

s.array[1] = 42

Definition at line 399 of file test_structures.py.