Closes #23182: Merge with 3.5

This commit is contained in:
Zachary Ware 2015-08-01 22:00:17 -05:00
commit 9dd6ddc787
1 changed files with 12 additions and 12 deletions

View File

@ -308,27 +308,27 @@ class GrammarTests(unittest.TestCase):
# argument annotation tests # argument annotation tests
def f(x) -> list: pass def f(x) -> list: pass
self.assertEqual(f.__annotations__, {'return': list}) self.assertEqual(f.__annotations__, {'return': list})
def f(x:int): pass def f(x: int): pass
self.assertEqual(f.__annotations__, {'x': int}) self.assertEqual(f.__annotations__, {'x': int})
def f(*x:str): pass def f(*x: str): pass
self.assertEqual(f.__annotations__, {'x': str}) self.assertEqual(f.__annotations__, {'x': str})
def f(**x:float): pass def f(**x: float): pass
self.assertEqual(f.__annotations__, {'x': float}) self.assertEqual(f.__annotations__, {'x': float})
def f(x, y:1+2): pass def f(x, y: 1+2): pass
self.assertEqual(f.__annotations__, {'y': 3}) self.assertEqual(f.__annotations__, {'y': 3})
def f(a, b:1, c:2, d): pass def f(a, b: 1, c: 2, d): pass
self.assertEqual(f.__annotations__, {'b': 1, 'c': 2}) self.assertEqual(f.__annotations__, {'b': 1, 'c': 2})
def f(a, b:1, c:2, d, e:3=4, f=5, *g:6): pass def f(a, b: 1, c: 2, d, e: 3 = 4, f=5, *g: 6): pass
self.assertEqual(f.__annotations__, self.assertEqual(f.__annotations__,
{'b': 1, 'c': 2, 'e': 3, 'g': 6}) {'b': 1, 'c': 2, 'e': 3, 'g': 6})
def f(a, b:1, c:2, d, e:3=4, f=5, *g:6, h:7, i=8, j:9=10, def f(a, b: 1, c: 2, d, e: 3 = 4, f=5, *g: 6, h: 7, i=8, j: 9 = 10,
**k:11) -> 12: pass **k: 11) -> 12: pass
self.assertEqual(f.__annotations__, self.assertEqual(f.__annotations__,
{'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9, {'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9,
'k': 11, 'return': 12}) 'k': 11, 'return': 12})
# Check for issue #20625 -- annotations mangling # Check for issue #20625 -- annotations mangling
class Spam: class Spam:
def f(self, *, __kw:1): def f(self, *, __kw: 1):
pass pass
class Ham(Spam): pass class Ham(Spam): pass
self.assertEqual(Spam.f.__annotations__, {'_Spam__kw': 1}) self.assertEqual(Spam.f.__annotations__, {'_Spam__kw': 1})