diff options
author | Christian Heimes <christian@cheimes.de> | 2007-12-08 22:32:47 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-12-08 22:32:47 (GMT) |
commit | eda9e2b66a793f9ca9dfca6eae5c1c239f4f51cb (patch) | |
tree | 1e11f0f3330b4fdc111aaa8606dfa1d19b0d9cc6 /Lib/test/test_keywordonlyarg.py | |
parent | 0da5bd6ee1b6a0e6f9397f43dab68ba098b04b58 (diff) | |
download | cpython-eda9e2b66a793f9ca9dfca6eae5c1c239f4f51cb.zip cpython-eda9e2b66a793f9ca9dfca6eae5c1c239f4f51cb.tar.gz cpython-eda9e2b66a793f9ca9dfca6eae5c1c239f4f51cb.tar.bz2 |
Added another test case for kwonly methods
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) |