summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2009-09-18 19:46:56 (GMT)
committerThomas Heller <theller@ctypes.org>2009-09-18 19:46:56 (GMT)
commit35888e2b3c0c36e6a6286416a60324da14b5560e (patch)
tree32b81c91693d8e98c4474387b6b27ccc66ef61d7 /Lib
parente40c4de982625ef1cea86a3ea2e84160a04d3cca (diff)
downloadcpython-35888e2b3c0c36e6a6286416a60324da14b5560e.zip
cpython-35888e2b3c0c36e6a6286416a60324da14b5560e.tar.gz
cpython-35888e2b3c0c36e6a6286416a60324da14b5560e.tar.bz2
Merged revisions 74918 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r74918 | thomas.heller | 2009-09-18 21:05:13 +0200 (Fr, 18 Sep 2009) | 11 lines 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):