Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(34536)

Delta Between Two Patch Sets: Lib/test/test_grammar.py

Issue 27095: Simplify MAKE_FUNCTION
Left Patch Set: Created 3 years, 4 months ago
Right Patch Set: Created 3 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 # Python test set -- part 1, grammar. 1 # Python test set -- part 1, grammar.
2 # This just tests whether the parser accepts them all. 2 # This just tests whether the parser accepts them all.
3 3
4 from test.support import check_syntax_error 4 from test.support import check_syntax_error
5 import inspect 5 import inspect
6 import unittest 6 import unittest
7 import sys 7 import sys
8 # testing import * 8 # testing import *
9 from sys import * 9 from sys import *
10 10
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 pass 338 pass
339 class Ham(Spam): pass 339 class Ham(Spam): pass
340 self.assertEqual(Spam.f.__annotations__, {'_Spam__kw': 1}) 340 self.assertEqual(Spam.f.__annotations__, {'_Spam__kw': 1})
341 self.assertEqual(Ham.f.__annotations__, {'_Spam__kw': 1}) 341 self.assertEqual(Ham.f.__annotations__, {'_Spam__kw': 1})
342 # Check for SF Bug #1697248 - mixing decorators and a return annotation 342 # Check for SF Bug #1697248 - mixing decorators and a return annotation
343 def null(x): return x 343 def null(x): return x
344 @null 344 @null
345 def f(x) -> list: pass 345 def f(x) -> list: pass
346 self.assertEqual(f.__annotations__, {'return': list}) 346 self.assertEqual(f.__annotations__, {'return': list})
347 347
348 # test MAKE_FUNCTION with a variety of oparg's 348 # test MAKE_FUNCTION with a variety of opargs
349 closure = 1 349 closure = 1
350 def f(): return closure 350 def f(): return closure
351 def f(x=1): return closure 351 def f(x=1): return closure
352 def f(*, k=1): return closure 352 def f(*, k=1): return closure
353 def f() -> int: return closure 353 def f() -> int: return closure
354 354
355 # Check ast errors in *args and *kwargs 355 # Check ast errors in *args and *kwargs
356 check_syntax_error(self, "f(*g(1=2))") 356 check_syntax_error(self, "f(*g(1=2))")
357 check_syntax_error(self, "f(**g(1=2))") 357 check_syntax_error(self, "f(**g(1=2))")
358 358
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 async def test2(): 1107 async def test2():
1108 return 22 1108 return 22
1109 self.assertTrue(test2._marked) 1109 self.assertTrue(test2._marked)
1110 self.assertEqual(test2.__name__, 'test2') 1110 self.assertEqual(test2.__name__, 'test2')
1111 self.assertTrue(bool(test2.__code__.co_flags & inspect.CO_COROUTINE)) 1111 self.assertTrue(bool(test2.__code__.co_flags & inspect.CO_COROUTINE))
1112 1112
1113 def test_async_for(self): 1113 def test_async_for(self):
1114 class Done(Exception): pass 1114 class Done(Exception): pass
1115 1115
1116 class AIter: 1116 class AIter:
1117 async def __aiter__(self): 1117 def __aiter__(self):
1118 return self 1118 return self
1119 async def __anext__(self): 1119 async def __anext__(self):
1120 raise StopAsyncIteration 1120 raise StopAsyncIteration
1121 1121
1122 async def foo(): 1122 async def foo():
1123 async for i in AIter(): 1123 async for i in AIter():
1124 pass 1124 pass
1125 async for i, j in AIter(): 1125 async for i, j in AIter():
1126 pass 1126 pass
1127 async for i in AIter(): 1127 async for i in AIter():
(...skipping 28 matching lines...) Expand all
1156 async with manager() as x, manager(): 1156 async with manager() as x, manager():
1157 pass 1157 pass
1158 raise Done 1158 raise Done
1159 1159
1160 with self.assertRaises(Done): 1160 with self.assertRaises(Done):
1161 foo().send(None) 1161 foo().send(None)
1162 1162
1163 1163
1164 if __name__ == '__main__': 1164 if __name__ == '__main__':
1165 unittest.main() 1165 unittest.main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+