a ze@s,ddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z GdddZ GdddZ dd Zd d Zejd d ZGdddejZGdddejZGdddejZGdddejZGdddejZGdddejZe jGdddejZedkr(edS)N)supportassert_python_okc@seZdZddZddZdS)AsyncYieldFromcCs ||_dSNobj)selfrr H/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_coroutines.py__init__szAsyncYieldFrom.__init__ccs|jEdHdSrrr r r r __await__szAsyncYieldFrom.__await__N__name__ __module__ __qualname__r rr r r r r src@seZdZddZddZdS) AsyncYieldcCs ||_dSrvalue)r rr r r r szAsyncYield.__init__ccs |jVdSrrr r r r rszAsyncYield.__await__Nrr r r r rsrc Cslg}d}z||dWqty`}z,|jr<|jdnd}WYd}~qdWYd}~qd}~00q||fSNr)appendsend StopIterationargs)corobufferresultexr r r run_asyncs$rc Cs|}g}d}d}z4|dr.|t|n||d|d7}Wqty}z,|jrh|jdnd}WYd}~qWYd}~qd}~00q||fS)Nr)rrnextrrr)rawrrirr r r run_async__await__+s $r%ccsDt(tddVtWdn1s60YdS)Nignore)warningscatch_warnings simplefilterr gc_collectr r r r silence_coro_gc>s  r+c@s,eZdZddZddZddZddZd S) AsyncBadSyntaxTestc Csxgd}|D]f}|j|dF|tt|ddWdn1sJ0YWdq 1sh0Yq dS)N);z9def foo(): await something() zawait something()z;async def foo(): yield from [] z=async def foo(): await await fut zEasync def foo(a=await something()): pass zEasync def foo(a:await something()): pass z`async def foo(): def bar(): [i async for i in els] z`async def foo(): def bar(): [await i for i in els] zasync def foo(): def bar(): [i for i in els async for b in els] zasync def foo(): def bar(): [i for i in els for c in b async for b in els] zasync def foo(): def bar(): [i for i in els async for b in els for c in b] zasync def foo(): def bar(): [i for i in els for b in await els] zasync def foo(): def bar(): [i for i in els for b in els if await b] z`async def foo(): def bar(): [i for i in await els] zeasync def foo(): def bar(): [i for i in els if await i] z?def bar(): [i async for i in els] zBdef bar(): {i: i async for i in els} z?def bar(): {i async for i in els} z?def bar(): [await i for i in els] z`def bar(): [i for i in els async for b in els] zdef bar(): [i for i in els for c in b async for b in els] zdef bar(): [i for i in els async for b in els for c in b] z`def bar(): [i for i in els for b in await els] z}def bar(): [i for i in els for b in els if await b] z?def bar(): [i for i in await els] zDdef bar(): [i for i in els if await i] z3async def foo(): await z]async def foo(): def bar(): pass await = 1 z^async def foo(): def bar(): pass await = 1 zzasync def foo(): def bar(): pass if 1: await = 1 zxdef foo(): async def bar(): pass if 1: await a z[def foo(): async def bar(): pass await a z~def foo(): def baz(): pass async def bar(): pass await a zdef foo(): def baz(): pass # 456 async def bar(): pass # 123 await a zasync def foo(): def baz(): pass # 456 async def bar(): pass # 123 await = 2 zdef foo(): def baz(): pass async def bar(): pass await a zasync def foo(): def baz(): pass async def bar(): pass await = 2 zBasync def foo(): def async(): pass zBasync def foo(): def await(): pass zXasync def foo(): def bar(): await zKasync def foo(): return lambda async: await zGasync def foo(): return lambda a: await z await a()z>async def foo(a=await b): pass z>async def foo(a:await b): pass z`def baz(): async def foo(a=await b): pass z:async def foo(async): pass zasync def foo(): def bar(): def baz(): async = 1 zasync def foo(): def bar(): def baz(): pass async = 1 zdef foo(): async def bar(): async def baz(): pass def baz(): 42 async = 1 zasync def foo(): def bar(): def baz(): pass await foo() zdef foo(): def bar(): async def baz(): pass await foo() z:async def foo(await): pass z]def foo(): async def bar(): pass await a z`def foo(): async def bar(): pass await a z`def foo(): async for i in arange(2): pass z[def foo(): async with resource: pass z9async with resource: pass z>async for i in arange(2): pass codeexecZsubTest assertRaises SyntaxErrorcompiler Zsamplesr.r r r test_badsyntax_1Hs 6z#AsyncBadSyntaxTest.test_badsyntax_1c Csxgd}|D]f}|j|dF|tt|ddWdn1sJ0YWdq 1sh0Yq dS)N) z1def foo(): await = 1 z9class Bar: def async(): pass z1class Bar: async = 1 z.class async: pass z.class await: pass zimport math as awaitz!def async(): passz2def foo(*, await=1): passasync = 1zprint(await=1)r-r/r0r1r5r r r test_badsyntax_2s"z#AsyncBadSyntaxTest.test_badsyntax_2cCs:|ttdddWdn1s,0YdS)Nz async = 1r/r0)r2r3r4r r r r test_badsyntax_3s z#AsyncBadSyntaxTest.test_badsyntax_3c Csxgd}|D]f}|j|dF|tt|ddWdn1sJ0YWdq 1sh0Yq dS)N)zdef foo(await): async def foo(): pass async def foo(): pass return await + 1 zdef foo(await): async def foo(): pass async def foo(): pass return await + 1 zdef foo(await): async def foo(): pass async def foo(): pass return await + 1 zdef foo(await): """spam""" async def foo(): pass # 123 async def foo(): pass # 456 return await + 1 a:def foo(await): def foo(): pass def foo(): pass async def bar(): return await_ await_ = await try: bar().send(None) except StopIteration as ex: return ex.args[0] + 1 r-r/r0r1r5r r r test_badsyntax_4s-z#AsyncBadSyntaxTest.test_badsyntax_4N)rrrr6r7r8r9r r r r r,Fs ;'r,c@seZdZddZdS)TokenizerRegrTestcCsg}tdD]}|dj|dq d|}i}t|||||dd|d7}i}t|||||dd|t|ddS) Nizdef i{i}(): return {i}r$ Zi499iz async def foo(): returnfoo) rangerformatjoinr0 assertEqual assertTrueinspectZiscoroutinefunction)r bufr$nsr r r test_oneline_defss    z#TokenizerRegrTest.test_oneline_defsN)rrrrFr r r r r:sr:c@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWdXZ.dYdZZ/d[d\Z0d]d^Z1d_d`Z2dadbZ3dcddZ4dedfZ5dgdhZ6didjZ7dkdlZ8dmdnZ9dodpZ:dqdrZ;dsdtZdydzZ?d{d|Z@d}d~ZAddZBddZCddZDddZEddZFddZGddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQdS) CoroutineTestcCsdd}|t|ddS)Ncss dVdSrr r r r r genz%CoroutineTest.test_gen_1..genr) assertFalsehasattr)r rHr r r test_gen_1szCoroutineTest.test_gen_1cCsdd}|}||tj|t|jjtj@| t|jjtj @|t|j jtj@| t|j jtj @| t |gdf| t|gdfdd}| t|jjtj@dS)NcsdSN r r r r r r=sz&CoroutineTest.test_func_1..foorNcSsdSrr r r r r bar rIz&CoroutineTest.test_func_1..bar)assertIsInstancetypes CoroutineTyperBbool__code__co_flagsrCZ CO_COROUTINErJZ CO_GENERATORcr_coderArr%)r r=frOr r r test_func_1szCoroutineTest.test_func_1cCsBdd}|tdt|Wdn1s40YdS)NcstdSrrr r r r r= sz&CoroutineTest.test_func_2..foozcoroutine raised StopIteration)assertRaisesRegex RuntimeErrorrr r=r r r test_func_2 s zCoroutineTest.test_func_2cCs*dd}|}|t|d|dS)NcstdSrrYr r r r r=sz&CoroutineTest.test_func_3..fooz^$) assertRegexreprclose)r r=rr r r test_func_3szCoroutineTest.test_func_3csDdd}|}fdd}|t|Wdn1s>0Y|t|Wdn1sl0Y|t|Wdn1s0Y|t|Wdn1s0Y||D]}qWdn1s0Y|dd|DWdn1s.0Y|dS)NcstdSrrYr r r r r=sz&CoroutineTest.test_func_4..foocs tdSNz"'coroutine' object is not iterablerZ TypeErrorr r r r "sz+CoroutineTest.test_func_4..cSsg|]}|qSr r .0r$r r r 6rIz-CoroutineTest.test_func_4..)listtuplesumiterr`)r r=rcheckr$r r r test_func_4s" &&&& .zCoroutineTest.test_func_4cstjddfdd}fdd}|}||D]}q8Wdn1sR0Y|D]}|dqjdd Ddgtd ttddS) Ncss dVdSNr!r r r r r rO;sz&CoroutineTest.test_func_5..barcsIdHdSrr r rOr r r=?sz&CoroutineTest.test_func_5..foocs tdSrbrcr r r r reBsz+CoroutineTest.test_func_5..r!cSsg|]}|qSr r )rgelr r r rhNrIz-CoroutineTest.test_func_5..)r!)rQ coroutiner`rArjr"rl)r r=rmrrqr )rOr r test_func_5:s     zCoroutineTest.test_func_5cs|tjddfdd}|}||dd||dd|t|dWdn1sn0YdS)NcssdVdVdSNr!r r r r r r rOSsz&CoroutineTest.test_func_6..barcsIdHdSrr r rpr r r=Xsz&CoroutineTest.test_func_6..foor!r )rQrrrArr2r)r r=rWr rpr test_func_6Rs   zCoroutineTest.test_func_6cs\dd}|fdd}|tdt|Wdn1sF0YdS)NcsdSrMr r r r r rObsz&CoroutineTest.test_func_7..barc3sEdHdSrr r rr r r=fsz&CoroutineTest.test_func_7..foozCcannot 'yield from' a coroutine object in a non-coroutine generator)rZrdrir`r rOr=r rvr test_func_7as (zCoroutineTest.test_func_7csBtjfdd}dd}||t|gdfdS)Nc3s EdHSrr r rvr r rOrsz&CoroutineTest.test_func_8..barcsdSNspamr r r r r r=vsz&CoroutineTest.test_func_8..foorz)rQrrrArr`rwr rvr test_func_8qs zCoroutineTest.test_func_8c Csdd}|td|tWdn1s80Y|tdN|t|D]}qbWdn1s|0YtWdn1s0YdS)NcsdSrr r r r r r=~sz&CoroutineTest.test_func_9..fooz0coroutine '.*test_func_9.*foo' was never awaited)ZassertWarnsRegexRuntimeWarningrr*r2rd)r r=_r r r test_func_9}s&   zCoroutineTest.test_func_9csdtjfddfdd}|}|}||t|t|||dd|d||d|}|}t|| t | t ddWdn1s0Y|d dS) Nrc3sNz>zdV}|dVWnty2d7Yn0Wd7n d70dS)Nr dr!ZeroDivisionErrora)Nr r rHs  z'CoroutineTest.test_func_10..gencsIdHdSrr r rHr r r=sz'CoroutineTest.test_func_10..foorNrr!f) rQrrrassertIsrlr"rArr`r2rthrow)r r=rr#r )rrHr test_func_10s$    ,zCoroutineTest.test_func_10cCsRdd}|}|dt||dt||dt||dS)NcsdSrr r r r r funcrIz(CoroutineTest.test_func_11..funcr__iter__Zcoroutine_wrapper)assertIndirrr_r`)r rrr r r test_func_11s zCoroutineTest.test_func_11csLfdd}||tddWdn1s>0YdS)Ncsd}tIdHdSr)rr=r;mer r gs z%CoroutineTest.test_func_12..gzcoroutine already executing)rZ ValueErrorr)r rr rr test_func_12s  zCoroutineTest.test_func_12cCsPdd}|}|td|dWdn1s:0Y|dS)NcsdSrr r r r r rsz%CoroutineTest.test_func_13..gz5can't send non-None value to a just-started coroutinerz)rZrdrr`)r rrr r r test_func_13s(zCoroutineTest.test_func_13csbtjddfdd}|}|d|td|Wdn1sT0YdS)Ncss dVdSrr r r r r rHsz'CoroutineTest.test_func_14..gencs4zIdHWnty.IdHYn0dSr GeneratorExitr rr r rs z(CoroutineTest.test_func_14..corozcoroutine ignored GeneratorExit)rQrrrrZr[r`)r rcr rr test_func_14s   zCoroutineTest.test_func_14cCsdd}dd}|}|td||dWdn1sF0Y|td||dWdn1s0YdS)NcsdSryr r r r r spammersz+CoroutineTest.test_func_15..spammercs |IdHSrr rvr r r readersz*CoroutineTest.test_func_15..readerrz&cannot reuse already awaited coroutine)rZrrr[)r rrZ spammer_coror r r test_func_15s,zCoroutineTest.test_func_15cstjddfdd}fdd}|}||}|d|d|td|tdWdn1sx0Y||}|d|td|dWdn1s0Y|td|td Wdn1s0YdS) Ncss dVdSrr r r r r nopsz'CoroutineTest.test_func_16..nopcsIdHdSryr r rr r rs z(CoroutineTest.test_func_16..sendcsIdH|IdHSrr rvrr r reads z(CoroutineTest.test_func_16..readhamrwat)rQrrrrZ Exceptionrr[)r rrrrr rr test_func_16s(     , (zCoroutineTest.test_func_16cCsdd}|}|td|dWdn1s:0Y|td|dWdn1sp0Y|td|tdWdn1s0Y||dS)NcsdSryr r r r r rrsz-CoroutineTest.test_func_17..coroutinerzrr)rZrrr[rrr`)r rrrr r r test_func_17s((,zCoroutineTest.test_func_17cCsHdd}|}|}t|}|td|dWdn1sJ0Y|td|dWdn1s0Y|tdt|Wdn1s0Y|td|tdWdn1s0Y|td|tdWdn1s*0Y| | dS)NcsdSryr r r r r rr.sz-CoroutineTest.test_func_18..coroutinerzrr) rrlrZrrr[r"rrr`)r rrrZ await_iteritr r r test_func_18+s0((&,.zCoroutineTest.test_func_18csdtjfddfdd}|}|d|d|d||dtdD]}||dqddS)Nrc3s0dVz dVWnty*d7Yn0dSrorr )CHKr r r=Vs   z'CoroutineTest.test_func_19..foocsIdHdSrr r )r=r r rr_sz-CoroutineTest.test_func_19..coroutiner!)rQrrrrAr`r>)r rrrr}r )rr=r test_func_19Ss      zCoroutineTest.test_func_19cCs&dd}t|}||gdfdS)NcsdS)NrNr r r r r r=rsz7CoroutineTest.test_coro_wrapper_send_tuple..foor)r%rAr r=rr r r test_coro_wrapper_send_tupleqs z*CoroutineTest.test_coro_wrapper_send_tuplecCs8dd}t|}||dt||djddS)NcstdSrMrYr r r r r=ysz?CoroutineTest.test_coro_wrapper_send_stop_iterator..foor!rN)r%rPrrArrr r r $test_coro_wrapper_send_stop_iteratorxs z2CoroutineTest.test_coro_wrapper_send_stop_iteratorcstjfddfddfdd}|ttjjdttj jjj j d t dWdn1s0YttjjdS)Nc3sJttjjdVttjjdSr)rArCgetcoroutinestateZ CORO_RUNNING assertIsNonecr_awaitr )coro_br r r rs  z&CoroutineTest.test_cr_await..acsIdHdSrr r rr r rsz&CoroutineTest.test_cr_await..ccs(jIdHjdSr)rrr )rrr r r bs  z&CoroutineTest.test_cr_await..br)rQrrrArCrZ CORO_CREATEDrrrZCORO_SUSPENDEDgi_codeco_namer2rZ CORO_CLOSED)r rr )rrrr r test_cr_awaits    (zCoroutineTest.test_cr_awaitcCstj}|d|jj|d|jj|d|jj|d|jdj|d|jdj||j ddd }|}|d t ||dS) Nzinto coroutinezinside coroutinez in coroutinezof the coroutinerrrrcsdSrr r r r r rWrIz(CoroutineTest.test_corotype_1..fzcoroutine object) rQrRrr__doc__r`r__dict__rArr_)r ctrWrr r r test_corotype_1szCoroutineTest.test_corotype_1cCsBdd}|tdt|Wdn1s40YdS)NcsdIdHdSror r r r r r=sz'CoroutineTest.test_await_1..foozobject int can.t.*awaitrZrdrr\r r r test_await_1szCoroutineTest.test_await_1cCsBdd}|tdt|Wdn1s40YdS)NcsgIdHdSrr r r r r r=sz'CoroutineTest.test_await_2..foozobject list can.t.*awaitrr\r r r test_await_2szCoroutineTest.test_await_2cCs@dd}|t|gddf|t|gddfdS)NcstgdIdHdS)Nr!r r)rr r r r r=sz'CoroutineTest.test_await_3..foor)rArr%r\r r r test_await_3szCoroutineTest.test_await_3cs.ddfdd}|t|gdfdS)NcsdSN*r r r r r rOsz'CoroutineTest.test_await_4..barcs IdHSrr r rpr r r=sz'CoroutineTest.test_await_4..foorrArr\r rpr test_await_4s zCoroutineTest.test_await_4csTGdddfdd}|tdt|Wdn1sF0YdS)Nc@seZdZddZdS)z-CoroutineTest.test_await_5..AwaitablecSsdSrr r r r r rsz7CoroutineTest.test_await_5..Awaitable.__await__Nrrrrr r r r Awaitablesrcs IdHSrr r rr r r=sz'CoroutineTest.test_await_5..foo(__await__.*returned non-iterator of typerr\r rr test_await_5s  zCoroutineTest.test_await_5cs6Gdddfdd}|t|dgdfdS)Nc@seZdZddZdS)z-CoroutineTest.test_await_6..AwaitablecSs tdgS)N4rlr r r r rsz7CoroutineTest.test_await_6..Awaitable.__await__Nrr r r r rsrcs IdHSrr r rr r r=sz'CoroutineTest.test_await_6..foorrr\r rr test_await_6s zCoroutineTest.test_await_6cs6Gdddfdd}|t|dgdfdS)Nc@seZdZddZdS)z-CoroutineTest.test_await_7..Awaitablecss dVdS)Nrrr r r r r rsz7CoroutineTest.test_await_7..Awaitable.__await__Nrr r r r rsrcs IdHSrr r rr r r=sz'CoroutineTest.test_await_7..foorrrr\r rr test_await_7s zCoroutineTest.test_await_7csTGdddfdd}|tdt|Wdn1sF0YdS)Nc@s eZdZdS)z-CoroutineTest.test_await_8..AwaitableNrrrr r r r rsrcs IdHSrr r rr r r=rIz'CoroutineTest.test_await_8..fooz4object Awaitable can't be used in 'await' expressionrr\r rr test_await_8s  zCoroutineTest.test_await_8cs^fddddfdd}fdd}|t|gd f|t|gd fdS) NcsSrr r rpr r wrapsz(CoroutineTest.test_await_9..wrapcsdSrr r r r r rOsz'CoroutineTest.test_await_9..barcspdfddi}Gfddd}IdHIdH|dIdHIdHd|IdHS)NrcsSrr r rr r rerIz9CoroutineTest.test_await_9..foo..cseZdZZdS)z3CoroutineTest.test_await_9..foo..DBN)rrrrr rr r DBsr)r)ZdbrrOrr r r=s,z'CoroutineTest.test_await_9..foocsIdH Srr r rpr r foo2sz(CoroutineTest.test_await_9..foo2iirr r=rr rr test_await_9s   zCoroutineTest.test_await_9cs:ddfddfdd}|t|gdfdS)NcsdSrr r r r r baz sz(CoroutineTest.test_await_10..bazcsSrr r )rr r rOsz(CoroutineTest.test_await_10..barcsIdHIdHSrr r rpr r r=sz(CoroutineTest.test_await_10..foorrr\r )rOrr test_await_10 s  zCoroutineTest.test_await_10csDddddfdd}fdd}|t|gd fdS) NcSs|Srr valr r r identsz*CoroutineTest.test_await_11..identcsdSryr r r r r rOsz(CoroutineTest.test_await_11..barcsIdHdS)Nrr r rOrr r r=sz(CoroutineTest.test_await_11..foocsIdHdfS)Nrr r rpr r r"sz)CoroutineTest.test_await_11..foo2)rzrrrr rr test_await_11s  zCoroutineTest.test_await_11csndd}|Gfdddfdd}|tdt|Wdn1sX0YdS)NcsdSryr r r r r r(sz)CoroutineTest.test_await_12..corocseZdZfddZdS)z.CoroutineTest.test_await_12..AwaitablecsSrr r rr r r-sz8CoroutineTest.test_await_12..Awaitable.__await__Nrr rr r r,srcs IdHSrr r rr r r=0sz(CoroutineTest.test_await_12..fooz"__await__\(\) returned a coroutine)rZrdrr`)r rr=r )rrr test_await_12's (zCoroutineTest.test_await_12csTGdddfdd}|tdt|Wdn1sF0YdS)Nc@seZdZddZdS)z.CoroutineTest.test_await_13..AwaitablecSs|Srr r r r r r;sz8CoroutineTest.test_await_13..Awaitable.__await__Nrr r r r r:srcs IdHSrr r rr r r=>sz(CoroutineTest.test_await_13..foorrr\r rr test_await_139s  zCoroutineTest.test_await_13csGdddGdddGdddtfddfd d }|}|d|td |d Wdn1s0Y|}|d||tWdn1s0YdS) Nc@seZdZddZddZdS)z,CoroutineTest.test_await_14..WrappercSs ||_dSrrv)r rr r r r Isz5CoroutineTest.test_await_14..Wrapper.__init__cSs |jSr)rrr r r r rLsz6CoroutineTest.test_await_14..Wrapper.__await__Nrr r r r WrapperGsrc@seZdZddZdS)z/CoroutineTest.test_await_14..FutureLikecssdVSrr r r r r rPsz9CoroutineTest.test_await_14..FutureLike.__await__Nrr r r r FutureLikeOsrc@s eZdZdS)z+CoroutineTest.test_await_14..MarkerNrr r r r MarkerSsrcs*zIdHWSty$Yn0dSrrr )rrr r coro1Vs z*CoroutineTest.test_await_14..coro1csIdHSrr r )rrr r coro2[sz*CoroutineTest.test_await_14..coro2rz)rrrZrr2rr)r rrr )rrrrr test_await_14Fs (  zCoroutineTest.test_await_14csptjddfdd}dd}|}|d|td||dWdn1sb0YdS)Ncss dVdSrr r r r r risz(CoroutineTest.test_await_15..nopcsIdHdSrr r rr r rrmsz.CoroutineTest.test_await_15..coroutinecs|IdHdSrr rvr r r waiterpsz+CoroutineTest.test_await_15..waiterz"coroutine is being awaited already)rQrrrrZr[)r rrrrr rr test_await_15hs   zCoroutineTest.test_await_15cs2ddfdd}t|\}}||jdS)NcstSr)rr r r r rW}sz&CoroutineTest.test_await_16..fcs&ztWnIdHYS0dSr)KeyErrorr rWr r rsz&CoroutineTest.test_await_16..g)rr __context__)r rr}rr rr test_await_16zs zCoroutineTest.test_await_16csGdddfdd}|}t|\}}||gdfdd}|tt|Wdn1sr0YdS)Nc@s$eZdZddZddZddZdS)z*CoroutineTest.test_with_1..ManagercSs ||_dSr)name)r rr r r r sz3CoroutineTest.test_with_1..Manager.__init__cs"td|jd|jgIdH|S)Nzenter-1-zenter-2-rrr r r r __aenter__s  z5CoroutineTest.test_with_1..Manager.__aenter__cs0td|jd|jgIdH|jdkr,dSdS)Nzexit-1-zexit-2-BTrr rr r r __aexit__s    z4CoroutineTest.test_with_1..Manager.__aexit__N)rrrr rrr r r r Managersrc sd4IdHt}d4IdH8}td|j|jfgIdHddWdIdHqp1IdHsf0YWdIdHq1IdHs0YdS)NArmanagersr!rr)rrrr r r=s$z&CoroutineTest.test_with_1..foo) z enter-1-Az enter-2-Az enter-1-Bz enter-2-B)rrrzexit-1-Bzexit-2-Bzexit-1-Azexit-2-Ac sd4IdHt}d4IdH8}td|j|jfgIdHddWdIdHqp1IdHsf0YWdIdHq1IdHs0YdS)NrCrr!rr)rrrr r r=s$)rrAr2r)r r=rWrr}r rr test_with_1s    zCoroutineTest.test_with_1csfGddddfdd}|tdt|Wdn1sL0Y|ddS)Nc@seZdZddZdS)z%CoroutineTest.test_with_2..CMcSsdSrr r r r r rsz0CoroutineTest.test_with_2..CM.__aenter__N)rrrrr r r r CMsrc sFd4IdHdWdIdHqB1IdHs80YdSNFTr r rZ body_executedr r r=sz&CoroutineTest.test_with_2..foorFrZAttributeErrorrrr\r rr test_with_2s (zCoroutineTest.test_with_2csfGddddfdd}|tdt|Wdn1sL0Y|ddS)Nc@seZdZddZdS)z%CoroutineTest.test_with_3..CMcSsdSrr r r r r rsz/CoroutineTest.test_with_3..CM.__aexit__N)rrrrr r r r rsrc sFd4IdHdWdIdHqB1IdHs80YdSrr r rr r r=sz&CoroutineTest.test_with_3..foorFrr\r rr test_with_3s (zCoroutineTest.test_with_3csfGddddfdd}|tdt|Wdn1sL0Y|ddS)Nc@s eZdZdS)z%CoroutineTest.test_with_4..CMNrr r r r rsrc sFd4IdHdWdIdHqB1IdHs80YdSrr r rr r r=sz&CoroutineTest.test_with_4..foorFrr\r rr test_with_4s (zCoroutineTest.test_with_4csRGdddfdd}|tt|Wdn1sD0YdS)Nc@seZdZddZddZdS)z%CoroutineTest.test_with_5..CMcs|Srr r r r r rsz0CoroutineTest.test_with_5..CM.__aenter__csdSrr )r excr r r rsz/CoroutineTest.test_with_5..CM.__aexit__Nrrrrrr r r r rsrc s>4IdHWdIdHq:1IdHs00YdSrr r rr r rsz'CoroutineTest.test_with_5..func)r2AssertionErrorr)r rr rr test_with_5s  zCoroutineTest.test_with_5csTGdddfdd}|tdt|Wdn1sF0YdS)Nc@seZdZddZddZdS)z%CoroutineTest.test_with_6..CMcSsdS)N{r r r r r rsz0CoroutineTest.test_with_6..CM.__aenter__cWsdSNir r er r r rsz/CoroutineTest.test_with_6..CM.__aexit__Nrr r r r rsrc s>4IdHWdIdHq:1IdHs00YdSrr r rr r r=sz&CoroutineTest.test_with_6..foozV'async with' received an object from __aenter__ that does not implement __await__: intrr\r rr test_with_6s zCoroutineTest.test_with_6c sGdddfdd}zt|WnXty}z@||jdd||jdu|t|jtWYd}~nd}~00|ddS)Nc@seZdZddZddZdS)z%CoroutineTest.test_with_7..CMcs|Srr r r r r rsz0CoroutineTest.test_with_7..CM.__aenter__cWsdS)Nir rr r r r sz/CoroutineTest.test_with_7..CM.__aexit__Nrr r r r rsrc sF4IdHddWdIdHqB1IdHs80YdSNr!rr r rr r r=sz&CoroutineTest.test_with_7..foorU'async with' received an object from __aexit__ that does not implement __await__: intz1invalid asynchronous context manager did not fail) rrdr^rrBr isinstancerfailr r=rr rr test_with_7s (zCoroutineTest.test_with_7csXdGdddfdd}|tdt|Wdn1sL0Y|dfdd}|tdt|Wdn1s0Y|d fd d}|tdt|Wdn1s0Y|d fd d}|tdt|Wdn1s>0Y|d dS)Nrc@seZdZddZddZdS)z%CoroutineTest.test_with_8..CMcs|Srr r r r r r$sz0CoroutineTest.test_with_8..CM.__aenter__cWsdSrr rr r r r'sz/CoroutineTest.test_with_8..CM.__aexit__Nrr r r r r#src sF4IdHd7WdIdHqB1IdHs80YdSror r rCNTr r r=+sz&CoroutineTest.test_with_8..foor r!c sjtdD]\}4IdH4d7WdIdHqfWdIdHq1IdHsZ0YqdSNr r!r>r;rr r r=7s r c shtdD]Z}4IdH2d7WdIdHqWdIdHq1IdHsX0YqdSrrr;rr r r=Es rc sH4IdH d7WdIdHdS1IdHs:0YdSror r rr r r=Ss)rZrdrrAr\r rr test_with_8 s<( ( ( *zCoroutineTest.test_with_8csddGdddfdd}|tt|Wdn1sJ0Y|ddS)Nrc@seZdZddZddZdS)z%CoroutineTest.test_with_9..CMcs|Srr r r r r rdsz0CoroutineTest.test_with_9..CM.__aenter__cs dddSr r rr r r rgsz/CoroutineTest.test_with_9..CM.__aexit__Nrr r r r rcsrc sF4IdHd7WdIdHqB1IdHs80YdSror r rr r r=jsz&CoroutineTest.test_with_9..foor!r2rrrAr\r rr test_with_9`s  (zCoroutineTest.test_with_9c sdGdddfdd}zt|WnZty}zB||jdu|t|jt|t|jjtWYd}~nd}~00|ddS)Nrc@seZdZddZddZdS)z&CoroutineTest.test_with_10..CMcs|Srr r r r r rxsz1CoroutineTest.test_with_10..CM.__aenter__cs dddSr r rr r r r{sz0CoroutineTest.test_with_10..CM.__aexit__Nrr r r r rwsrc s|4IdHT4IdHtWdIdHqN1IdHsD0YWdIdHqx1IdHsn0YdSrr[r rr r r=~sz'CoroutineTest.test_with_10..fooz*exception from __aexit__ did not propagate)rrrBrr r[r rr rr test_with_10ts zCoroutineTest.test_with_10c srdGdddfdd}zt|Wn4tyb}z||jduWYd}~nd}~00|ddS)Nrc@seZdZddZddZdS)z&CoroutineTest.test_with_11..CMcstdSr)NotImplementedErrorr r r r rsz1CoroutineTest.test_with_11..CM.__aenter__cs dddSr r rr r r rsz0CoroutineTest.test_with_11..CM.__aexit__Nrr r r r rsrc sB4IdHtWdIdHq>1IdHs40YdSrrr rr r r=sz'CoroutineTest.test_with_11..fooz+exception from __aenter__ did not propagate)rrrBrr rr rr test_with_11s&zCoroutineTest.test_with_11cs0dGdddfdd}t|dS)Nrc@seZdZddZddZdS)z&CoroutineTest.test_with_12..CMcs|Srr r r r r rsz1CoroutineTest.test_with_12..CM.__aenter__csdSNTr rr r r rsz0CoroutineTest.test_with_12..CM.__aexit__Nrr r r r rsrc sP4IdH(}|jtWdIdHqL1IdHsB0YdSr)r __class__r[cmrrr r r r=sz'CoroutineTest.test_with_12..foo)rr\r r r test_with_12szCoroutineTest.test_with_12csddGdddfdd}|tt|Wdn1sJ0Y|ddS)Nrc@seZdZddZddZdS)z&CoroutineTest.test_with_13..CMcs dddSr r r r r r rsz1CoroutineTest.test_with_13..CM.__aenter__csdSrr rr r r rsz0CoroutineTest.test_with_13..CM.__aexit__Nrr r r r rsrc sVd74IdHd7WdIdHqJ1IdHs@0Yd7dS)Nr!r'r r rr r r=s2z'CoroutineTest.test_with_13..foor!rr\r rr test_with_13s  (zCoroutineTest.test_with_13csHdGfdddgfdd}t|\}}|d||ddtdd D|d dtdd Dgfd d }t|\}}|d||ddg|ddtddDdggfdd}t|\}}|d||ddtdd D|ddtddDddgdS)Nrcs(eZdZddZfddZddZdS)z+CoroutineTest.test_for_1..AsyncItercSs d|_dSrr;r r r r r sz4CoroutineTest.test_for_1..AsyncIter.__init__cs d7|Sror r  aiter_callsr r __aiter__sz5CoroutineTest.test_for_1..AsyncIter.__aiter__csF|jd7_|jds,t|jdIdH|jdkr:t|j|jfS)Nr!rNr)r$rStopAsyncIterationr r r r __anext__s   z5CoroutineTest.test_for_1..AsyncIter.__anext__Nrrrr r&r(r r$r r AsyncIters r*cs,2z3dHW\}}||q6dSrr)Zi1Zi2r*rr r test1sz'CoroutineTest.test_for_1..test1r!cSsg|] }|dqSrr rfr r r rhrIz,CoroutineTest.test_for_1.. cSsg|] }|dqS)r r rfr r r rhrIecsL2z*3dHW}|d|ddkrq>q6dddSNrwhat?endr+r;r,r r test2s   z'CoroutineTest.test_for_1..test2r rcSsg|]}|qSr r rfr r r rhrIr4csJ2z(3dHW}|ddkr q|dq6dddSr1r+r;r,r r test3s   z'CoroutineTest.test_for_1..test3rcSsg|] }|dqSr.r rfr r r rhrIcSsg|]}|qSr r rfr r r rhrIr3)rrAr>)r r-yieldedr}r5r8r )r*r%rr test_for_1s,   "  zCoroutineTest.test_for_1csfdt}fdd}|tdt|Wdn1sF0Y|t|dS)Nrcs 2z3dHW}tdq6dSNznever going to happenprintr;tupr r r=sz%CoroutineTest.test_for_2..fooz/async for' requires an object.*__aiter__.*tuplesys getrefcountrZrdrrA)r refs_beforer=r r>r test_for_2s  (zCoroutineTest.test_for_2csvGddd}|t}fdd}|tdt|Wdn1sV0Y|t|dS)Nc@seZdZddZdS)z#CoroutineTest.test_for_3..IcSs|Srr r r r r r&$sz-CoroutineTest.test_for_3..I.__aiter__Nrrrr&r r r r I#srFcs 2z3dHW}tdq6dSr;r<r;Zaiterr r r=*sz%CoroutineTest.test_for_3..fooz!that does not implement __anext__r@r rFrCr=r rGr test_for_3"s  (zCoroutineTest.test_for_3csvGddd}|t}fdd}|tdt|Wdn1sV0Y|t|dS)Nc@seZdZddZddZdS)z#CoroutineTest.test_for_4..IcSs|Srr r r r r r&8sz-CoroutineTest.test_for_4..I.__aiter__cSsdS)Nr r r r r r r(;sz-CoroutineTest.test_for_4..I.__anext__N)rrrr&r(r r r r rF7srFcs 2z3dHW}tdq6dSr;r<r;rGr r r=Asz%CoroutineTest.test_for_4..fooz7async for' received an invalid object.*__anext__.*tupler@rHr rGr test_for_46s  (zCoroutineTest.test_for_4csdGfdddGdddt}t}fdd}t$tdt|Wdn1s0Y|d |t||t|fd d}t||d fd d}t||d dS)Nrcs$eZdZfddZfddZdS)z)CoroutineTest.test_for_6..Managercs d7dS)Nr"r r rFr r rQsz4CoroutineTest.test_for_6..Manager.__aenter__cs d7dS)Nir rrKr r rUsz3CoroutineTest.test_for_6..Manager.__aexit__Nrr rKr r rPs rc@s$eZdZddZddZddZdS)z*CoroutineTest.test_for_6..IterablecSs d|_dSrr;r r r r r Zsz3CoroutineTest.test_for_6..Iterable.__init__cSs|Srr r r r r r&]sz4CoroutineTest.test_for_6..Iterable.__aiter__cs"|jdkrt|jd7_|jSNrNr!)r$r'r r r r r(`s z4CoroutineTest.test_for_6..Iterable.__anext__Nr)r r r r IterableYsrMc s`4IdH22z3dHW}d7q6WdIdHqT1IdHsJ0Yd7dSNr!rr r;)rFiterablemanagerr r mainms6z&CoroutineTest.test_for_6..mainerroric s4IdH42z3dHW}d7q6WdIdHqX1IdHsN0Yd74IdH42z3dHW}d7qv6WdIdHq1IdHs0Yd7dSrNr r;rFrMrr r rQs66ic s4IdHDd72z3dHW}d7q6d7WdIdHqh1IdHs^0Yd74IdHDd72z3dHW}d7q6d7WdIdHq1IdHs0Yd7dS)Nrr!irr r;rSr r rQs 4 4i9)rArBr'r(r)rrA)r Z mrefs_beforeZ irefs_beforerQr )rFrMrrOrPr test_for_6Ms(     (    zCoroutineTest.test_for_6csddGdddfdd}|tt|Wdn1sJ0Y|ddS)Nrc@seZdZddZdS)z$CoroutineTest.test_for_7..AIcSs dddSr r r r r r r&sz.CoroutineTest.test_for_7..AI.__aiter__NrEr r r r AIsrUcs*2z3dHW}d7q6d7dSNr!rNr r;rUrr r r=s z%CoroutineTest.test_for_7..foorr\r rWr test_for_7s  (zCoroutineTest.test_for_7c sdGdddfdd}|tLt$tdt|Wdn1s^0YWdn1s|0Y|ddS)Nrc@seZdZddZdS)z$CoroutineTest.test_for_8..AIcSs dddSr r r r r r r&sz.CoroutineTest.test_for_8..AI.__aiter__NrEr r r r rUsrUcs*2z3dHW}d7q6d7dSrVr r;rWr r r=s z%CoroutineTest.test_for_8..foorR)r2rr'r(r)rrAr\r rWr test_for_8s   FzCoroutineTest.test_for_8csjGdddfdd}|td}|dWdn1sH0Y|j}||jtdS)Nc@s$eZdZddZddZddZdS)z$CoroutineTest.test_for_11..FcSs|Srr r r r r r&sz.CoroutineTest.test_for_11..F.__aiter__cSs|Srr r r r r r(sz.CoroutineTest.test_for_11..F.__anext__cSs dddSr r r r r r rsz.CoroutineTest.test_for_11..F.__await__N)rrrr&r(rr r r r FsrZcs2z 3dHW}q6dSrr )r}rZr r rQsz'CoroutineTest.test_for_11..mainz an invalid object from __anext__)rZrdr exceptionrP __cause__r)r rQrerrr r[r test_for_11s *zCoroutineTest.test_for_11cs|GdddtGdddtgfdd}||dWdn1s`0Y|dgdS)Nc@s eZdZdS)z*CoroutineTest.test_for_tuple..DoneNrr r r r DonerIr`c@s eZdZdZddZddZdS)z+CoroutineTest.test_for_tuple..AIterrcSs|Srr r r r r r&sz5CoroutineTest.test_for_tuple..AIter.__aiter__cs.|jt|krt|jd7_||jdSro)r$lenr'r r r r r(sz5CoroutineTest.test_for_tuple..AIter.__anext__Nrrrr$r&r(r r r r AItersrccs,dg2z3dHW}|q 6dSrr+r;rcr`rr r r=sz)CoroutineTest.test_for_tuple..foor)rrjr2rrAr\r rdr test_for_tuples  *zCoroutineTest.test_for_tuplecs|GdddtGdddtgfdd}||dWdn1s`0Y|dgdS)Nc@s eZdZdS)z3CoroutineTest.test_for_stop_iteration..DoneNrr r r r r`rIr`c@s eZdZdZddZddZdS)z4CoroutineTest.test_for_stop_iteration..AIterrcSs|Srr r r r r r&sz>CoroutineTest.test_for_stop_iteration..AIter.__aiter__cs|jr t|jd7_|jSro)r$r'rr r r r r(sz>CoroutineTest.test_for_stop_iteration..AIter.__anext__Nrbr r r r rcsrccs*d2z3dHW}|q6dSrr+r;rdr r r=sz2CoroutineTest.test_for_stop_iteration..foor)rrr2rrAr\r rdr test_for_stop_iterations  *z%CoroutineTest.test_for_stop_iterationcsddfdd}fdd}fdd}fd d }|t|gd d gf|t|gd d hf|t|gd d df|t|gd d dfdS)Ncs|Srr r;r r r rW sz$CoroutineTest.test_comp_1..fcs ddddfDIdHS)Ncsg|]}|IdHqSrr rgrr r r rhrIz?CoroutineTest.test_comp_1..run_list..r!)r r rr r run_listsz+CoroutineTest.test_comp_1..run_listcs ddddfDIdHS)Ncsh|]}|IdHqSrr rgr r r rIz=CoroutineTest.test_comp_1..run_set..r!rhr r rr r run_setsz*CoroutineTest.test_comp_1..run_setcs ddddfDIdHS)Ncsi|]}|IdHdqS)Nrr rgr r r rIz@CoroutineTest.test_comp_1..run_dict1..r!rhr r rr r run_dict1sz,CoroutineTest.test_comp_1..run_dict1cs$ddtddgDIdHS)Ncsi|]\}}||IdHqSrr )rgr$rr r r rlrIz@CoroutineTest.test_comp_1..run_dict2..r!rh) enumerater rr r run_dict2sz,CoroutineTest.test_comp_1..run_dict2r!rhr)r!rh)rr!r)r rirkrmror rr test_comp_1 s    zCoroutineTest.test_comp_1cs~ddfdd}|t|ggdffdd}|t|ghdffd d }|t|gd d hfdS) Ncs|Srr r;r r r rW!sz$CoroutineTest.test_comp_2..fcs0dddddddgfDIdHS)Ncs g|]}|IdHD]}|qqSrr rgrsr r r rh%sz?CoroutineTest.test_comp_2..run_list..abcdefgr r rr r ri$sz+CoroutineTest.test_comp_2..run_list)rrrrurvcs,ddddgdggfDIdHS)Ncs0h|](}|IdHD]}|IdHD]}|q qqSrr )rgrrrdr r r rj-sz=CoroutineTest.test_comp_2..run_set..rNr2r r rr r rk,s  z*CoroutineTest.test_comp_2..run_set>rNr2rxcs&ddddgfDIdHS)Ncs&h|]}|IdHD]}|IdHqqSrr rqr r r rj8sz>CoroutineTest.test_comp_2..run_set2..rNr2r r rr r run_set27sz+CoroutineTest.test_comp_2..run_set2rNr2r)r rirkryr rr test_comp_2 s       zCoroutineTest.test_comp_2csddfdd}|t|gddgffdd}|t|gddhffd d }|t|gd d d ffdd}|t|gddgfdS)NcSs|D] }|VqdSrr rr$r r r rWAsz$CoroutineTest.test_comp_3..fcsddddg2IdHS)Ncsg|z3dHW}|dq6Sror rfr r r rhFrIz?CoroutineTest.test_comp_3..run_list..rNr2r r rr r riEsz+CoroutineTest.test_comp_3..run_listr/r7csddddg2IdHS)Ncsh|z3dHW}|dq6Sror rfr r r rjLrIz=CoroutineTest.test_comp_3..run_set..rNr2r r rr r rkKsz*CoroutineTest.test_comp_3..run_setcsddddg2IdHS)Ncs$i|z3dHW}|d|dq6Srtr rfr r r rlRrIz?CoroutineTest.test_comp_3..run_dict..rNr2r r rr r run_dictQsz+CoroutineTest.test_comp_3..run_dict )r/r7cs*ddddg2}dd|2IdHS)NcSs |z3dHW}|dVq6dSror rfr r r XrIz=CoroutineTest.test_comp_3..run_gen..rNr2csg|z3dHW}|dq6SNrr rgrr r r rhYrIz>CoroutineTest.test_comp_3..run_gen..r rrr r run_genWsz*CoroutineTest.test_comp_3..run_genoyrr rirkr|rr rr test_comp_3@s*        zCoroutineTest.test_comp_3csddfdd}|t|gdgffdd}|t|gdhffdd }|t|gdd iffd d }|t|gd gfdS)NcSs|D] }|VqdSrr r{r r r rW_sz$CoroutineTest.test_comp_4..fcsddddg2IdHS)Ncs&g|z3dHW}|dkr|dq6SrLr rfr r r rhdrIz?CoroutineTest.test_comp_4..run_list..rNr2r r rr r ricsz+CoroutineTest.test_comp_4..run_listr7csddddg2IdHS)Ncs&h|z3dHW}|dkr|dq6SrLr rfr r r rjjrIz=CoroutineTest.test_comp_4..run_set..rNr2r r rr r rkisz*CoroutineTest.test_comp_4..run_setcsddddg2IdHS)Ncs,i|z"3dHW}|dkr|d|dq6S)NrNr!r r rfr r r rlprIz?CoroutineTest.test_comp_4..run_dict..rNr2r r rr r r|osz+CoroutineTest.test_comp_4..run_dictr~cs*ddddg2}dd|2IdHS)NcSs(|z3dHW}|dkr|dVq6dSrLr rfr r r rvrIz=CoroutineTest.test_comp_4..run_gen..rNr2csg|z3dHW}|dq6Srr rr r r rhwrIz>CoroutineTest.test_comp_4..run_gen..r rrr r rusz*CoroutineTest.test_comp_4..run_genrrrr rr test_comp_4^s*     zCoroutineTest.test_comp_4csddfdd}|t|ggdffdd}|t|ghdffd d }|t|gd d d dffdd}|t|ggdfdS)NcSs|D] }|VqdSrr r{r r r rW}sz&CoroutineTest.test_comp_4_2..fcsddtd2IdHS)Ncs6g|z,3dHW}d|kr$dkrnq|dq6SNrrrNr rfr r r rhrIzACoroutineTest.test_comp_4_2..run_list..rr rr r risz-CoroutineTest.test_comp_4_2..run_list)r/r} csddtd2IdHS)Ncs6h|z,3dHW}d|kr$dkrnq|dq6Srr rfr r r rjrIz?CoroutineTest.test_comp_4_2..run_set..rrr rr r rksz,CoroutineTest.test_comp_4_2..run_set>r/r}rcsddtd2IdHS)Ncs<i|z23dHW}d|kr$dkrnq|d|dq6S)NrrrNrr rfr r r rlrIzACoroutineTest.test_comp_4_2..run_dict..rrr rr r r|sz-CoroutineTest.test_comp_4_2..run_dictr0rgcs*ddtd2}dd|2IdHS)NcSs8|z.3dHW}d|kr"dkrnq|dVq6dSrr rfr r r rrIz?CoroutineTest.test_comp_4_2..run_gen..rcsg|z3dHW}|dq6Srr rr r r rhrIz@CoroutineTest.test_comp_4_2..run_gen..rrrr r rsz,CoroutineTest.test_comp_4_2..run_gen)rpqrrr rr test_comp_4_2|s*       zCoroutineTest.test_comp_4_2cs0ddfdd}|t|gdgfdS)NcSs|D] }|VqdSrr r{r r r rWsz$CoroutineTest.test_comp_5..fcs$fddddgddgfDIdHS)Nc s@g|]8}|ddkr|2z3dHW}|dkr|dq6qS)rrNNrxr!r )rgZpairr$rr r rhsz?CoroutineTest.test_comp_5..run_list..rNr2rx(r r rr r risz+CoroutineTest.test_comp_5..run_listrhrr rir rr test_comp_5s  zCoroutineTest.test_comp_5cs2ddfdd}|t|ggdfdS)NcSs|D] }|VqdSrr r{r r r rWsz$CoroutineTest.test_comp_6..fcsddddg2IdHS)Ncs(g|z3dHW}|D] }|dqq6Sror )rgseqr$r r r rhsz?CoroutineTest.test_comp_6..run_list..)rNr2)rxr r rr r risz+CoroutineTest.test_comp_6..run_list)r/r7rrr rr test_comp_6s   zCoroutineTest.test_comp_6csNddfdd}|tdt|Wdn1s@0YdS)NcSsdVdVtddS)Nr!r aaa)rr r r r rWsz$CoroutineTest.test_comp_7..fcsdd2IdHS)Ncsg|z3dHW}|q6Srr rfr r r rhrIz?CoroutineTest.test_comp_7..run_list..r r rr r risz+CoroutineTest.test_comp_7..run_listr)rZrrrr rr test_comp_7s zCoroutineTest.test_comp_7cCs&dd}|t|ggdfdS)NcsdddDS)NcSsg|]}|qSr r rfr r r rhrIz8CoroutineTest.test_comp_8..f..rr r r r r rWsz$CoroutineTest.test_comp_8..frrr rWr r r test_comp_8s  zCoroutineTest.test_comp_8cs2ddfdd}|t|gddgfdS)NcSsdVdVdSrtr r r r r rHsz&CoroutineTest.test_comp_9..gencs$dd2IdH}dd|DS)Ncsg|z3dHW}|q6Srr rfr r r rhrIz8CoroutineTest.test_comp_9..f..cSsg|]}|qSr r rfr r r rhrIr )lrr r rWsz$CoroutineTest.test_comp_9..fr!r rrr rr test_comp_9s   zCoroutineTest.test_comp_9cCs*dd}|t|gddddfdS)NcsdddD}dd|DS)NcSsh|]}|qSr r rfr r r rjrIz8CoroutineTest.test_comp_10..f..rcSsi|] }||qSr r )rgxr r r rlrIz9CoroutineTest.test_comp_10..f..r )xxr r r rWsz%CoroutineTest.test_comp_10..fr!r rrrrr r r test_comp_10s zCoroutineTest.test_comp_10cCsdd}|}|tt|Wdn1s80Y|}z@|tt|Wdn1sv0YW|n |0dS)NcsdSrr r r r r rrIz%CoroutineTest.test_copy..func)r2rdcopyrr`)r rrr#r r r test_copys ( *zCoroutineTest.test_copyc Csdd}|}ttjdD]@}|ttjft||Wdq1sR0Yq|}z\ttjdD]@}|ttjft||Wdqv1s0YqvW|n |0dS)NcsdSrr r r r r rrIz'CoroutineTest.test_pickle..funcr!) r>pickleHIGHEST_PROTOCOLr2rd PicklingErrordumpsrr`)r rrprotor#r r r test_pickles,.zCoroutineTest.test_picklec Csdd}tt\}td|}t|}d}t|dt|j j | t|j j |Wdn1s|0YWdn1s0YdS)NcsdSrr r r r r rrIz3CoroutineTest.test_fatal_coro_warning..funcrRzwas never awaited) r'r(rcatch_unraisable_exceptionfilterwarningsr_r*rstr unraisable exc_valuerAobject)r rrr coro_reprr r r test_fatal_coro_warnings  z%CoroutineTest.test_fatal_coro_warningcsGddd}|ddfdd}t|gdffdd }t|gdffd d }t|gdfdS) Nc@seZdZddZdS)zMCoroutineTest.test_for_assign_raising_stop_async_iteration..BadTargetcSs tddSrr')r keyrr r r __setitem__ szYCoroutineTest.test_for_assign_raising_stop_async_iteration..BadTarget.__setitem__N)rrrrr r r r BadTargetsrcSs dVdSrMr r r r r source szJCoroutineTest.test_for_assign_raising_stop_async_iteration..sourcecsXt*}2z3dHWd<q6Wdn1s:0Y|jjddS)Nrrr4r2r'rAr\rrr rtgtr r run_fors  "zKCoroutineTest.test_for_assign_raising_stop_async_iteration..run_forr4csXt*}fdd2IdHWdS1s:0Y|jjddS)Ncsg|z3dHWd<dq6Srr rgrr r rhrIz`CoroutineTest.test_for_assign_raising_stop_async_iteration..run_list..rr4rrrr r ris 8zLCoroutineTest.test_for_assign_raising_stop_async_iteration..run_listcsxfdd2}|d}t}|IdHWdn1sH0Y|jjt|jjjddS)Ncs |z3dHWd<dVq6dSrr rrr r rrIz^CoroutineTest.test_for_assign_raising_stop_async_iteration..run_gen..rr4 asendr2r[rPr\r]r'rArrHrrrr r rs  (zKCoroutineTest.test_for_assign_raising_stop_async_iteration..run_genr)r rrrirr rr ,test_for_assign_raising_stop_async_iterationsz:CoroutineTest.test_for_assign_raising_stop_async_iterationcsGdddfddfdd}t|gdffdd }t|gdffd d }t|gdfdS) Nc@seZdZddZdS)zQCoroutineTest.test_for_assign_raising_stop_async_iteration_2..BadIterablecSs tddSrrr r r r r*szZCoroutineTest.test_for_assign_raising_stop_async_iteration_2..BadIterable.__iter__N)rrrrr r r r BadIterable)srcs VdSrr r )rr r badpairs,szNCoroutineTest.test_for_assign_raising_stop_async_iteration_2..badpairscsXt*}2z3dHW\}}q6Wdn1s:0Y|jjddS)Nrr4r)rr$jrr r r r/s  "zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2..run_forr4csTt&}dd2IdHWdS1s60Y|jjddS)Ncsg|z3dHW\}}dq6Srr rgr$rr r r rh9rIzbCoroutineTest.test_for_assign_raising_stop_async_iteration_2..run_list..rr4rrrr r ri7s 4zNCoroutineTest.test_for_assign_raising_stop_async_iteration_2..run_listcstdd2}|d}t}|IdHWdn1sD0Y|jjt|jjjddS)NcSs |z3dHW\}}dVq6dSrr rr r r r?rIz`CoroutineTest.test_for_assign_raising_stop_async_iteration_2..run_gen..rr4rrrr r r>s  (zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2..run_genr)r rrirr )rrr r .test_for_assign_raising_stop_async_iteration_2(s z.MyExceptionNrr r r r MyExceptionPsrcs(eZdZfddZfddZdS)z0CoroAsyncIOCompatTest.test_asyncio_1..CMcs(ddIdHd|S)Nr!{Gz?r )rsleepr rrr r rVs  z;CoroAsyncIOCompatTest.test_asyncio_1..CM.__aenter__cs dIdH|jdS)Nr)rrr)r exc_typeexc_valexc_tbrr r r\sz:CoroAsyncIOCompatTest.test_asyncio_1..CM.__aexit__Nrr rr r rUsrc s\4IdH*}dIdHWdIdHqN1IdHsD0YddS)NrZ unreachable)rrrrrrrr r rW`s.z/CoroAsyncIOCompatTest.test_asyncio_1..f)r!r r) r import_modulerZnew_event_loopZset_event_loopZrun_until_completer`Zset_event_loop_policyrA)r rWZloopr rr test_asyncio_1Ks       z$CoroAsyncIOCompatTest.test_asyncio_1N)rrrrr r r r rIsrc@s,eZdZddZddZddZddZd S) OriginTrackingTestcCsttj}|j|jfSr)rCZ getframeinfo currentframef_backfilenamelineno)r infor r r heretszOriginTrackingTest.herec s$t}zddtdtdt}|jWdn1s\0Ytdtd\}}t*}|j||ddffWdn1s0Ytdtdfdd}\}}|\\}}}t|2|j||d f||ddffWdn1sX0Ytd t6} dt |jkod knWdn1s0Y t td Wdn1s0Ytd Wt|n t|0dS) NcsdSrr r r r r corofn{sz7OriginTrackingTest.test_origin_tracking..corofnrr!test_origin_trackingr csfSr)rr rr r r nestedsz7OriginTrackingTest.test_origin_tracking..nestedrr) rA#get_coroutine_origin_tracking_depth#set_coroutine_origin_tracking_depthrA contextlibclosingr cr_originrrBrar2r)r orig_depthrZfnamerrZ nested_fnameZ nested_linenor rr rxs@ *  "    $ F *z'OriginTrackingTest.test_origin_trackingc sdd\}}fdd|d7}\}}fdd|d7}fdd }t}z|d d jd }|d dd jddd|d|ddg|ddd jddd|d|ddd|d|ddgWt|n t|0dS)NcsdSrr r r r r rsz?OriginTrackingTest.test_origin_tracking_warning..corofncsSrr r )rr r a1sz;OriginTrackingTest.test_origin_tracking_warning..a1r csSrr r )rr r a2sz;OriginTrackingTest.test_origin_tracking_warning..a2csXt|t}tWdn1s80Y|t|jdSr) rArZ assertWarnsr|rr*rArwarning)depthmsgr)rr r r rms   &z>OriginTrackingTest.test_origin_tracking_warning..checkrz coroutine 'z' was never awaitedr!rsz' was never awaited z-Coroutine created at (most recent call last) z File "z", line z, in a1 z$ return corofn() # comment in a1z, in a2 z! return a1() # comment in a2 )rrArrr@r)r Z a1_filenameZ a1_linenoZ a2_filenameZ a2_linenormrrr )rrrr r test_origin_tracking_warnings4       z/OriginTrackingTest.test_origin_tracking_warningc Csdd}tj}zddt_tz}tdtfL|}t|}~t|t|j j |||j j t Wdn1s0YWdn1s0Yt`tdtf|tWdn1s0YW|t_n|t_0dS)NcsdSrr r r r r rszLOriginTrackingTest.test_unawaited_warning_when_module_broken..corofncSsddSr r rvr r r rerIzNOriginTrackingTest.test_unawaited_warning_when_module_broken..zcoroutine .* was never awaited) r'_warn_unawaited_coroutinerrZcheck_warningsr|r_r*rArrrr)r rZorig_wucrrrr r r )test_unawaited_warning_when_module_brokens,  L(z.foor!) _testcapirrArr\r rr test_tp_await_1 s  zCAPITest.test_tp_await_1cCs2ddlm}|tdg}|t|ddS)Nrrr!)rrrlrAr"r)r rrr r r test_tp_await_2 s zCAPITest.test_tp_await_2cs\ddlmfdd}|td$||ddWdn1sN0YdS)Nrrcsd}|IdHSror rrr r r= sz%CAPITest.test_tp_await_3..fooz.__await__.*returned non-iterator of type 'int'r!)rrrZrdrArr\r rr test_tp_await_3 s   zCAPITest.test_tp_await_3N)rrrrrrr r r r r s r__main__)rrrCrrArQZunittestr'testrZtest.support.script_helperrrrrr%contextmanagerr+ZTestCaser,r:rGrrrZ cpython_onlyrrrQr r r r sP   `*