|
7 | 7 | _testcapi = None |
8 | 8 | import struct |
9 | 9 | import collections |
| 10 | +import itertools |
10 | 11 |
|
11 | 12 | # The test cases here cover several paths through the function calling |
12 | 13 | # code. They depend on the METH_XXX flag that is used to define a C |
@@ -194,6 +195,26 @@ def test_varargs13_kw(self): |
194 | 195 | msg = r"^classmethod\(\) takes no keyword arguments$" |
195 | 196 | self.assertRaisesRegex(TypeError, msg, classmethod, func=id) |
196 | 197 |
|
| 198 | + def test_varargs14_kw(self): |
| 199 | + msg = r"^product\(\) takes at most 1 keyword argument \(2 given\)$" |
| 200 | + self.assertRaisesRegex(TypeError, msg, |
| 201 | + itertools.product, 0, repeat=1, foo=2) |
| 202 | + |
| 203 | + def test_varargs15_kw(self): |
| 204 | + msg = r"^ImportError\(\) takes at most 2 keyword arguments \(3 given\)$" |
| 205 | + self.assertRaisesRegex(TypeError, msg, |
| 206 | + ImportError, 0, name=1, path=2, foo=3) |
| 207 | + |
| 208 | + def test_varargs16_kw(self): |
| 209 | + msg = r"^min\(\) takes at most 2 keyword arguments \(3 given\)$" |
| 210 | + self.assertRaisesRegex(TypeError, msg, |
| 211 | + min, 0, default=1, key=2, foo=3) |
| 212 | + |
| 213 | + def test_varargs17_kw(self): |
| 214 | + msg = r"^print\(\) takes at most 4 keyword arguments \(5 given\)$" |
| 215 | + self.assertRaisesRegex(TypeError, msg, |
| 216 | + print, 0, sep=1, end=2, file=3, flush=4, foo=5) |
| 217 | + |
197 | 218 | def test_oldargs0_1(self): |
198 | 219 | msg = r"keys\(\) takes no arguments \(1 given\)" |
199 | 220 | self.assertRaisesRegex(TypeError, msg, {}.keys, 0) |
|
0 commit comments