[ctypes-commit] ctypes/unittests test_structures.py,1.31,1.32
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2005-03-14 08:06:23
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30055 Modified Files: test_structures.py Log Message: Test invalid types in Structure _fields_. Test keyword arguments in Structure.__init__(). Index: test_structures.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_structures.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** test_structures.py 20 Jan 2005 21:06:46 -0000 1.31 --- test_structures.py 14 Mar 2005 08:06:12 -0000 1.32 *************** *** 216,219 **** --- 216,234 ---- self.assertRaises(ValueError, Person, "1234567", 5) + + def test_keyword_initializers(self): + class POINT(Structure): + _fields_ = [("x", c_int), ("y", c_int)] + pt = POINT(1, 2) + self.failUnlessEqual((pt.x, pt.y), (1, 2)) + + pt = POINT(y=2, x=1) + self.failUnlessEqual((pt.x, pt.y), (1, 2)) + + def test_invalid_field_types(self): + class POINT(Structure): + pass + self.assertRaises(TypeError, setattr, POINT, "_fields_", [("x", 1), ("y", 2)]) + def test_intarray_fields(self): class SomeInts(Structure): |