summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2009-09-18 19:05:13 (GMT)
committerThomas Heller <theller@ctypes.org>2009-09-18 19:05:13 (GMT)
commitd7cb1b9119beab9a4ffb627bd65cf9e287d32b66 (patch)
treeae062b3d272829a36dc702c94d4bf09aa8345af0 /Lib
parenta91ded2842521f1eb4b56d6eadc242e5228c8ac6 (diff)
downloadcpython-d7cb1b9119beab9a4ffb627bd65cf9e287d32b66.zip
cpython-d7cb1b9119beab9a4ffb627bd65cf9e287d32b66.tar.gz
cpython-d7cb1b9119beab9a4ffb627bd65cf9e287d32b66.tar.bz2
Merged revisions 74917 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r74917 | thomas.heller | 2009-09-18 20:55:17 +0200 (Fr, 18 Sep 2009) | 3 lines Issue #5042: Structure sub-subclass does now initialize correctly with base class positional arguments. ........ Also made small stylistic changes.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_structures.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index 23468dc..c58d949 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -349,6 +349,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.assertEqual((z.a, z.b, z.c, z.d, z.e, z.f),
+ (1, 2, 3, 4, 5, 6))
+ z = Z(1)
+ self.assertEqual((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):