diff options
author | Thomas Heller <theller@ctypes.org> | 2009-09-18 18:55:17 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2009-09-18 18:55:17 (GMT) |
commit | 7a352c0ed8a12d868d9b682f4adf33f558d19855 (patch) | |
tree | e1f8936cff27bcce3b1cd9730092669a518fddd1 /Lib/ctypes/test | |
parent | db9925a56bd522aebe93afb7dc76800a58e59a07 (diff) | |
download | cpython-7a352c0ed8a12d868d9b682f4adf33f558d19855.zip cpython-7a352c0ed8a12d868d9b682f4adf33f558d19855.tar.gz cpython-7a352c0ed8a12d868d9b682f4adf33f558d19855.tar.bz2 |
Issue #5042: Structure sub-subclass does now initialize correctly with
base class positional arguments.
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r-- | Lib/ctypes/test/test_structures.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py index 168c3cd..32f87d8 100644 --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -355,6 +355,25 @@ class StructureTestCase(unittest.TestCase): self.assertTrue("from_address" in dir(type(Structure))) self.assertTrue("in_dll" in dir(type(Structure))) + def test_positional_args(self): + # see also http://bugs.python.org/issue5042 + class W(Structure): + _fields_ = [("a", c_int), ("b", c_int)] + class X(W): + _fields_ = [("c", c_int)] + class Y(X): + pass + class Z(Y): + _fields_ = [("d", c_int), ("e", c_int), ("f", c_int)] + + z = Z(1, 2, 3, 4, 5, 6) + self.failUnlessEqual((z.a, z.b, z.c, z.d, z.e, z.f), + (1, 2, 3, 4, 5, 6)) + z = Z(1) + self.failUnlessEqual((z.a, z.b, z.c, z.d, z.e, z.f), + (1, 0, 0, 0, 0, 0)) + self.assertRaises(TypeError, lambda: Z(1, 2, 3, 4, 5, 6, 7)) + class PointerMemberTestCase(unittest.TestCase): def test(self): |