diff options
Diffstat (limited to 'Lib/test/test_call.py')
-rw-r--r-- | Lib/test/test_call.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py index 07355e8..a2eec41 100644 --- a/Lib/test/test_call.py +++ b/Lib/test/test_call.py @@ -11,6 +11,19 @@ import gc import contextlib +class BadStr(str): + def __eq__(self, other): + return True + def __hash__(self): + # Guaranteed different hash + return str.__hash__(self) ^ 3 + + def __eq__(self, other): + return False + def __hash__(self): + return str.__hash__(self) + + class FunctionCalls(unittest.TestCase): def test_kwargs_order(self): @@ -145,6 +158,18 @@ class CFunctionCallsErrorMessages(unittest.TestCase): self.assertRaisesRegex(TypeError, msg, print, 0, sep=1, end=2, file=3, flush=4, foo=5) + def test_varargs18_kw(self): + # _PyArg_UnpackKeywordsWithVararg() + msg = r"invalid keyword argument for print\(\)$" + with self.assertRaisesRegex(TypeError, msg): + print(0, 1, **{BadStr('foo'): ','}) + + def test_varargs19_kw(self): + # _PyArg_UnpackKeywords() + msg = r"invalid keyword argument for round\(\)$" + with self.assertRaisesRegex(TypeError, msg): + round(1.75, **{BadStr('foo'): 1}) + def test_oldargs0_1(self): msg = r"keys\(\) takes no arguments \(1 given\)" self.assertRaisesRegex(TypeError, msg, {}.keys, 0) |