diff options
Diffstat (limited to 'Lib/test/test_keywordonlyarg.py')
-rw-r--r-- | Lib/test/test_keywordonlyarg.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py index 124257e..eeda547 100644 --- a/Lib/test/test_keywordonlyarg.py +++ b/Lib/test/test_keywordonlyarg.py @@ -151,6 +151,15 @@ class KeywordOnlyArgTestCase(unittest.TestCase): self.assertEqual(f(), {}) self.assertEqual(f(k1=1, k2=2), {'k1' : 1, 'k2' : 2}) + def test_kwonly_methods(self): + class Example: + def f(self, *, k1=1, k2=2): + return k1, k2 + + self.assertEqual(Example().f(k1=1, k2=2), (1, 2)) + self.assertEqual(Example.f(Example(), k1=1, k2=2), (1, 2)) + self.assertRaises(TypeError, Example.f, k1=1, k2=2) + def test_main(): run_unittest(KeywordOnlyArgTestCase) |