mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Added another test case for kwonly methods
This commit is contained in:
parent
0da5bd6ee1
commit
eda9e2b66a
2 changed files with 16 additions and 8 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue