summaryrefslogtreecommitdiff
path: root/Lib/ctypes/test/test_structures.py
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-01-17 18:46:55 +0000
committerThomas Heller <theller@ctypes.org>2008-01-17 18:46:55 +0000
commit95f2dfcc9834342a33b7808a888510d6b4b57bc6 (patch)
treeb6b9189b66afc659685a686ae3f6dc12fd5210e1 /Lib/ctypes/test/test_structures.py
parent3f32d534a77601b257badcb9ddfbbafb180e64b6 (diff)
downloadcpython-95f2dfcc9834342a33b7808a888510d6b4b57bc6.tar.gz
Merged revisions 60001,60003-60004,60008 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r60001 | thomas.heller | 2008-01-16 20:16:27 +0100 (Mi, 16 Jan 2008) | 3 lines Convert the internal ctypes array type cache to a WeakValueDict so that array types do not live longer than needed. ........ r60003 | thomas.heller | 2008-01-16 20:37:33 +0100 (Mi, 16 Jan 2008) | 3 lines Raise a TypeError if conflicting positional and named arguments are passed to a Structure or Union constructor. ........ r60004 | thomas.heller | 2008-01-16 20:45:51 +0100 (Mi, 16 Jan 2008) | 3 lines Raise a TypeError instead of a ValueError when too many initializers are used in a Structure or Union constructor. ........ r60008 | thomas.heller | 2008-01-16 21:34:37 +0100 (Mi, 16 Jan 2008) | 3 lines Use 'g' instead of 'D' as the ctypes typecode for c_longdouble, for compliance with PEP 3118. ........
Diffstat (limited to 'Lib/ctypes/test/test_structures.py')
-rw-r--r--Lib/ctypes/test/test_structures.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index b50e4df6bd..c4eee86f1f 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)
+
+ # too many initializers
+ self.assertRaises(TypeError, POINT, 2, 3, 4)
def test_keyword_initializers(self):
class POINT(Structure):
@@ -305,9 +314,9 @@ class StructureTestCase(unittest.TestCase):
self.failUnlessEqual(cls, RuntimeError)
if issubclass(Exception, object):
self.failUnlessEqual(msg,
- "(Phone) <type 'ValueError'>: too many initializers")
+ "(Phone) <type 'TypeError'>: too many initializers")
else:
- self.failUnlessEqual(msg, "(Phone) ValueError: too many initializers")
+ self.failUnlessEqual(msg, "(Phone) TypeError: too many initializers")
def get_except(self, func, *args):