summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSylvain <sylvain.desodt+github@gmail.com>2017-06-15 15:05:23 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-06-15 15:05:23 (GMT)
commit96c7c0685045b739fdc5145018cddfd252155713 (patch)
tree8c99f9484c33d59c49b45146e50f7d6c7b08a4a7 /Lib
parent8acb4cf2b3436652568d7a70228b166316181466 (diff)
downloadcpython-96c7c0685045b739fdc5145018cddfd252155713.zip
cpython-96c7c0685045b739fdc5145018cddfd252155713.tar.gz
cpython-96c7c0685045b739fdc5145018cddfd252155713.tar.bz2
bpo-20627: Fix error message when keyword arguments are used (#2115)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_call.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py
index f46eb21..ca678b9 100644
--- a/Lib/test/test_call.py
+++ b/Lib/test/test_call.py
@@ -5,6 +5,8 @@ try:
import _testcapi
except ImportError:
_testcapi = None
+import struct
+import collections
# The test cases here cover several paths through the function calling
# code. They depend on the METH_XXX flag that is used to define a C
@@ -160,6 +162,30 @@ class CFunctionCallsErrorMessages(unittest.TestCase):
msg = r"^hasattr\(\) takes no keyword arguments$"
self.assertRaisesRegex(TypeError, msg, hasattr, x=2)
+ def test_varargs6_kw(self):
+ msg = r"^getattr\(\) takes no keyword arguments$"
+ self.assertRaisesRegex(TypeError, msg, getattr, x=2)
+
+ def test_varargs7_kw(self):
+ msg = r"^next\(\) takes no keyword arguments$"
+ self.assertRaisesRegex(TypeError, msg, next, x=2)
+
+ def test_varargs8_kw(self):
+ msg = r"^pack\(\) takes no keyword arguments$"
+ self.assertRaisesRegex(TypeError, msg, struct.pack, x=2)
+
+ def test_varargs9_kw(self):
+ msg = r"^pack_into\(\) takes no keyword arguments$"
+ self.assertRaisesRegex(TypeError, msg, struct.pack_into, x=2)
+
+ def test_varargs10_kw(self):
+ msg = r"^index\(\) takes no keyword arguments$"
+ self.assertRaisesRegex(TypeError, msg, collections.deque().index, x=2)
+
+ def test_varargs11_kw(self):
+ msg = r"^pack\(\) takes no keyword arguments$"
+ self.assertRaisesRegex(TypeError, msg, struct.Struct.pack, struct.Struct(""), x=2)
+
def test_oldargs0_1(self):
msg = r"keys\(\) takes no arguments \(1 given\)"
self.assertRaisesRegex(TypeError, msg, {}.keys, 0)