diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2012-04-29 18:34:40 +0100 |
---|---|---|
committer | Mark Dickinson <mdickinson@enthought.com> | 2012-04-29 18:34:40 +0100 |
commit | d52375cc7c3dd531d12bfd3c7c98ff4adcd3b4fb (patch) | |
tree | d19f3326d748cd04bc6aa5d9fbb6116a2c437b7d /Lib/test/test_parser.py | |
parent | 20f5fba8efce3c35e851c3e4395ed18224b9aefe (diff) | |
download | cpython-d52375cc7c3dd531d12bfd3c7c98ff4adcd3b4fb.tar.gz |
Issue #9154: Fix parser module to understand function annotations.
Diffstat (limited to 'Lib/test/test_parser.py')
-rw-r--r-- | Lib/test/test_parser.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index 020acd500f..833d3178d6 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -146,6 +146,27 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase): self.check_suite("@funcattrs()\n" "def f(): pass") + # keyword-only arguments + self.check_suite("def f(*, a): pass") + self.check_suite("def f(*, a = 5): pass") + self.check_suite("def f(*, a = 5, b): pass") + self.check_suite("def f(*, a, b = 5): pass") + self.check_suite("def f(*, a, b = 5, **kwds): pass") + self.check_suite("def f(*args, a): pass") + self.check_suite("def f(*args, a = 5): pass") + self.check_suite("def f(*args, a = 5, b): pass") + self.check_suite("def f(*args, a, b = 5): pass") + self.check_suite("def f(*args, a, b = 5, **kwds): pass") + + # function annotations + self.check_suite("def f(a: int): pass") + self.check_suite("def f(a: int = 5): pass") + self.check_suite("def f(*args: list): pass") + self.check_suite("def f(**kwds: dict): pass") + self.check_suite("def f(*, a: int): pass") + self.check_suite("def f(*, a: int = 5): pass") + self.check_suite("def f() -> int: pass") + def test_class_defs(self): self.check_suite("class foo():pass") self.check_suite("class foo(object):pass") |