diff options
Diffstat (limited to 'Lib/test/test_keywordonlyarg.py')
-rw-r--r-- | Lib/test/test_keywordonlyarg.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py index e10dfce2ad..d7f7541837 100644 --- a/Lib/test/test_keywordonlyarg.py +++ b/Lib/test/test_keywordonlyarg.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Unit tests for the keyword only argument specified in PEP 3102.""" @@ -73,6 +73,14 @@ class KeywordOnlyArgTestCase(unittest.TestCase): fundef3 += "lastarg):\n pass\n" compile(fundef3, "<test>", "single") + def testTooManyPositionalErrorMessage(self): + def f(a, b=None, *, c=None): + pass + with self.assertRaises(TypeError) as exc: + f(1, 2, 3) + expected = "f() takes at most 2 positional arguments (3 given)" + self.assertEqual(str(exc.exception), expected) + def testSyntaxErrorForFunctionCall(self): self.assertRaisesSyntaxError("f(p, k=1, p2)") self.assertRaisesSyntaxError("f(p, k1=50, *(1,2), k1=100)") |