summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_grammar.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2019-05-31 14:19:50 (GMT)
committerGitHub <noreply@github.com>2019-05-31 14:19:50 (GMT)
commita0c01bf1364f2996bb0186ddfc41d74350e01c39 (patch)
tree4f106cd74ed51b8e4a0fbb26acd4a76925ab0e6e /Lib/test/test_grammar.py
parent2f58a84104ef64f71deb71d264305bcd73e59c97 (diff)
downloadcpython-a0c01bf1364f2996bb0186ddfc41d74350e01c39.zip
cpython-a0c01bf1364f2996bb0186ddfc41d74350e01c39.tar.gz
cpython-a0c01bf1364f2996bb0186ddfc41d74350e01c39.tar.bz2
bpo-37115: Support annotations in positional-only arguments (GH-13698)
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r--Lib/test/test_grammar.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 6d7d554..2a3b71f 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -620,14 +620,22 @@ class GrammarTests(unittest.TestCase):
self.assertEqual(f.__annotations__, {'return': list})
def f(x: int): pass
self.assertEqual(f.__annotations__, {'x': int})
+ def f(x: int, /): pass
+ self.assertEqual(f.__annotations__, {'x': int})
+ def f(x: int = 34, /): pass
+ self.assertEqual(f.__annotations__, {'x': int})
def f(*x: str): pass
self.assertEqual(f.__annotations__, {'x': str})
def f(**x: float): pass
self.assertEqual(f.__annotations__, {'x': float})
def f(x, y: 1+2): pass
self.assertEqual(f.__annotations__, {'y': 3})
+ def f(x, y: 1+2, /): pass
+ self.assertEqual(f.__annotations__, {'y': 3})
def f(a, b: 1, c: 2, d): pass
self.assertEqual(f.__annotations__, {'b': 1, 'c': 2})
+ def f(a, b: 1, /, c: 2, d): pass
+ self.assertEqual(f.__annotations__, {'b': 1, 'c': 2})
def f(a, b: 1, c: 2, d, e: 3 = 4, f=5, *g: 6): pass
self.assertEqual(f.__annotations__,
{'b': 1, 'c': 2, 'e': 3, 'g': 6})
@@ -636,6 +644,11 @@ class GrammarTests(unittest.TestCase):
self.assertEqual(f.__annotations__,
{'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9,
'k': 11, 'return': 12})
+ def f(a, b: 1, c: 2, d, e: 3 = 4, f: int = 5, /, *g: 6, h: 7, i=8, j: 9 = 10,
+ **k: 11) -> 12: pass
+ self.assertEqual(f.__annotations__,
+ {'b': 1, 'c': 2, 'e': 3, 'f': int, 'g': 6, 'h': 7, 'j': 9,
+ 'k': 11, 'return': 12})
# Check for issue #20625 -- annotations mangling
class Spam:
def f(self, *, __kw: 1):