1# test async with, escaped by a break 2 3class AContext: 4 async def __aenter__(self): 5 print('enter') 6 return 1 7 async def __aexit__(self, exc_type, exc, tb): 8 print('exit', exc_type, exc) 9 10async def f1(): 11 while 1: 12 async with AContext(): 13 print('body') 14 break 15 print('no 1') 16 print('no 2') 17 18o = f1() 19try: 20 print(o.send(None)) 21except StopIteration: 22 print('finished') 23 24async def f2(): 25 while 1: 26 try: 27 async with AContext(): 28 print('body') 29 break 30 print('no 1') 31 finally: 32 print('finally') 33 print('no 2') 34 35o = f2() 36try: 37 print(o.send(None)) 38except StopIteration: 39 print('finished') 40 41async def f3(): 42 while 1: 43 try: 44 try: 45 async with AContext(): 46 print('body') 47 break 48 print('no 1') 49 finally: 50 print('finally inner') 51 finally: 52 print('finally outer') 53 print('no 2') 54 55o = f3() 56try: 57 print(o.send(None)) 58except StopIteration: 59 print('finished') 60