summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_call.py
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2017-08-23 18:16:48 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-08-23 18:16:48 (GMT)
commitbf9075a0c55186d2f34df63e6c8512dd6414ff4b (patch)
treeb2a84f87f0a22a086ea282d2c6b99f3234b6003b /Lib/test/test_call.py
parent772d809a63f40fd35679da3fb115cdf7fa81bd20 (diff)
downloadcpython-bf9075a0c55186d2f34df63e6c8512dd6414ff4b.zip
cpython-bf9075a0c55186d2f34df63e6c8512dd6414ff4b.tar.gz
cpython-bf9075a0c55186d2f34df63e6c8512dd6414ff4b.tar.bz2
bpo-31229: Fixed wrong error messages when too many keyword arguments are received. (#3180)
Diffstat (limited to 'Lib/test/test_call.py')
-rw-r--r--Lib/test/test_call.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py
index b004b58..3f9987c 100644
--- a/Lib/test/test_call.py
+++ b/Lib/test/test_call.py
@@ -7,6 +7,7 @@ except ImportError:
_testcapi = None
import struct
import collections
+import itertools
# 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
@@ -194,6 +195,26 @@ class CFunctionCallsErrorMessages(unittest.TestCase):
msg = r"^classmethod\(\) takes no keyword arguments$"
self.assertRaisesRegex(TypeError, msg, classmethod, func=id)
+ def test_varargs14_kw(self):
+ msg = r"^product\(\) takes at most 1 keyword argument \(2 given\)$"
+ self.assertRaisesRegex(TypeError, msg,
+ itertools.product, 0, repeat=1, foo=2)
+
+ def test_varargs15_kw(self):
+ msg = r"^ImportError\(\) takes at most 2 keyword arguments \(3 given\)$"
+ self.assertRaisesRegex(TypeError, msg,
+ ImportError, 0, name=1, path=2, foo=3)
+
+ def test_varargs16_kw(self):
+ msg = r"^min\(\) takes at most 2 keyword arguments \(3 given\)$"
+ self.assertRaisesRegex(TypeError, msg,
+ min, 0, default=1, key=2, foo=3)
+
+ def test_varargs17_kw(self):
+ msg = r"^print\(\) takes at most 4 keyword arguments \(5 given\)$"
+ self.assertRaisesRegex(TypeError, msg,
+ print, 0, sep=1, end=2, file=3, flush=4, foo=5)
+
def test_oldargs0_1(self):
msg = r"keys\(\) takes no arguments \(1 given\)"
self.assertRaisesRegex(TypeError, msg, {}.keys, 0)