mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
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.
This commit is contained in:
parent
a91ded2842
commit
d7cb1b9119
3 changed files with 95 additions and 58 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue