diff options
author | Thomas Heller <theller@ctypes.org> | 2008-01-16 19:37:33 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2008-01-16 19:37:33 (GMT) |
commit | 02ec289f3e16ee6b00ecf7ec8f8e0f2a3e1ad152 (patch) | |
tree | 8cbd8dd33cbe3bcad02e4adf86b57e3a27788d7a /Lib/ctypes/test | |
parent | 902d30752fa79fa787114b3f2cde37513909bc57 (diff) | |
download | cpython-02ec289f3e16ee6b00ecf7ec8f8e0f2a3e1ad152.zip cpython-02ec289f3e16ee6b00ecf7ec8f8e0f2a3e1ad152.tar.gz cpython-02ec289f3e16ee6b00ecf7ec8f8e0f2a3e1ad152.tar.bz2 |
Raise a TypeError if conflicting positional and named arguments are
passed to a Structure or Union constructor.
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r-- | Lib/ctypes/test/test_structures.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py index f9a1109..3005e82 100644 --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -215,6 +215,15 @@ class StructureTestCase(unittest.TestCase): # too long self.assertRaises(ValueError, Person, "1234567", 5) + def test_conflicting_initializers(self): + class POINT(Structure): + _fields_ = [("x", c_int), ("y", c_int)] + # conflicting positional and keyword args + self.assertRaises(TypeError, POINT, 2, 3, x=4) + self.assertRaises(TypeError, POINT, 2, 3, y=4) + + # Should this raise TypeError instead? + self.assertRaises(ValueError, POINT, 2, 3, 4) def test_keyword_initializers(self): class POINT(Structure): |