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 Cs|jtjtjhvsJg}d}z||dWqtyv}z,|jrR|jdnd}WYd}~qzWYd}~qd}~00q||fSNr) __class__types GeneratorType CoroutineTypeappendsend StopIterationargs)corobufferresultexr r r run_asyncs$r#c Cs|jtjusJ|}g}d}d}z4|dr>|t|n||d|d7}Wq$ty}z,|jrx|jdnd}WYd}~qWYd}~q$d}~00q$||fS)Nr) rrrrrnextrrr)rawr r!ir"r 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 Zsamplesr2r 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)r1r3r4r5r9r r r test_badsyntax_2s"z#AsyncBadSyntaxTest.test_badsyntax_2cCs:|ttdddWdn1s,0YdS)Nz async = 1r3r4)r6r7r8r 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 r1r3r4r5r9r r r test_badsyntax_4s-z#AsyncBadSyntaxTest.test_badsyntax_4N)rrrr:r;r<r=r r r r r0Fs ;'r0c@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) rangerformatjoinr4 assertEqual assertTrueinspectZiscoroutinefunction)r bufr(nsr r r test_oneline_defss    z#TokenizerRegrTest.test_oneline_defsN)rrrrJr 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 rLr 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 rAsz&CoroutineTest.test_func_1..foorRcSsdSrr r r r r bar rMz&CoroutineTest.test_func_1..bar)assertIsInstancerrrFbool__code__co_flagsrGZ CO_COROUTINErNZ CO_GENERATORcr_coderEr#r))r rAfrSr r r test_func_1szCoroutineTest.test_func_1cCsBdd}|tdt|Wdn1s40YdS)NcstdSrrr r r r rA sz&CoroutineTest.test_func_2..foozcoroutine raised StopIteration)assertRaisesRegex RuntimeErrorr#r rAr r r test_func_2 s zCoroutineTest.test_func_2cCs*dd}|}|t|d|dS)NcstdSrr[r r r r rAsz&CoroutineTest.test_func_3..fooz^$) assertRegexreprclose)r rArr r r test_func_3szCoroutineTest.test_func_3csDdd}|}fdd}|t|Wdn1s>0Y|t|Wdn1sl0Y|t|Wdn1s0Y|t|Wdn1s0Y||D]}qWdn1s0Y|dd|DWdn1s.0Y|dS)NcstdSrr[r r r r rAsz&CoroutineTest.test_func_4..foocs tdSNz"'coroutine' object is not iterabler\ TypeErrorr r r r "sz+CoroutineTest.test_func_4..cSsg|]}|qSr r .0r(r r r 6rMz-CoroutineTest.test_func_4..)listtuplesumiterrb)r rArcheckr(r r r test_func_4s" &&&& .zCoroutineTest.test_func_4cstjddfdd}fdd}|}||D]}q8Wdn1sR0Y|D]}|dqjdd Ddgtd ttddS) Ncss dVdSNr%r r r r r rS;sz&CoroutineTest.test_func_5..barcsIdHdSrr r rSr r rA?sz&CoroutineTest.test_func_5..foocs tdSrdrer r r r rgBsz+CoroutineTest.test_func_5..r%cSsg|]}|qSr r )rielr r r rjNrMz-CoroutineTest.test_func_5..r%)r coroutinerbrErlr&rn)r rArorrsr )rSr r test_func_5:s     zCoroutineTest.test_func_5cs|tjddfdd}|}||dd||dd|t|dWdn1sn0YdS)NcssdVdVdSNr%r$r r r r r rSSsz&CoroutineTest.test_func_6..barcsIdHdSrr r rrr r rAXsz&CoroutineTest.test_func_6..foor%r$)rrurErr6r)r rArYr rrr test_func_6Rs   zCoroutineTest.test_func_6cs\dd}|fdd}|tdt|Wdn1sF0YdS)NcsdSrQr r r r r rSbsz&CoroutineTest.test_func_7..barc3sEdHdSrr r rr r rAfsz&CoroutineTest.test_func_7..foozCcannot 'yield from' a coroutine object in a non-coroutine generator)r\rfrkrbr rSrAr ryr test_func_7as (zCoroutineTest.test_func_7csBtjfdd}dd}||t|gdfdS)Nc3s EdHSrr r ryr r rSrsz&CoroutineTest.test_func_8..barcsdSNspamr r r r r rAvsz&CoroutineTest.test_func_8..foor})rrurEr#rbrzr ryr test_func_8qs zCoroutineTest.test_func_8c Csdd}|td|tWdn1s80Y|tdN|t|D]}qbWdn1s|0YtWdn1s0YdS)NcsdSrr r r r r rA~sz&CoroutineTest.test_func_9..fooz0coroutine '.*test_func_9.*foo' was never awaited)ZassertWarnsRegexRuntimeWarningrr.r6rf)r rA_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 rLs  z'CoroutineTest.test_func_10..gencsIdHdSrr r rLr r rAsz'CoroutineTest.test_func_10..foorRrr%f) rrurassertIsrnr&rErrbr6rthrow)r rArr'r )rrLr test_func_10s$    ,zCoroutineTest.test_func_10cCsRdd}|}|dt||dt||dt||dS)NcsdSrr r r r r funcrMz(CoroutineTest.test_func_11..funcr__iter__Zcoroutine_wrapper)assertIndirrrarb)r rrr r r test_func_11s zCoroutineTest.test_func_11csLfdd}||tddWdn1s>0YdS)Ncsd}tIdHdSr)rrAr?mer r gs z%CoroutineTest.test_func_12..gzcoroutine already executing)r\ 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 coroutiner})r\rfrrb)r rrr r r test_func_13s(zCoroutineTest.test_func_13csbtjddfdd}|}|d|td|Wdn1sT0YdS)Ncss dVdSrr r r r r rLsz'CoroutineTest.test_func_14..gencs4zIdHWnty.IdHYn0dSr GeneratorExitr rr r rs z(CoroutineTest.test_func_14..corozcoroutine ignored GeneratorExit)rrurr\r]rb)r rcr rr test_func_14s   zCoroutineTest.test_func_14cCsdd}dd}|}|td||dWdn1sF0Y|td||dWdn1s0YdS)NcsdSr|r r r r r spammersz+CoroutineTest.test_func_15..spammercs |IdHSrr ryr r r readersz*CoroutineTest.test_func_15..readerr}&cannot reuse already awaited coroutine)r\rrr])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..nopcsIdHdSr|r r rr r rs z(CoroutineTest.test_func_16..sendcsIdH|IdHSrr ryrr r reads z(CoroutineTest.test_func_16..readhamrwat)rrurr\ Exceptionrr])r rrrrr rr test_func_16s(     , (zCoroutineTest.test_func_16cCsdd}|}|td|dWdn1s:0Y|td|dWdn1sp0Y|td|tdWdn1s0Y||dS)NcsdSr|r r r r r rusz-CoroutineTest.test_func_17..coroutiner}rr)r\rrr]rrrb)r rurr r r test_func_17s((,zCoroutineTest.test_func_17cCsHdd}|}|}t|}|td|dWdn1sJ0Y|td|dWdn1s0Y|tdt|Wdn1s0Y|td|tdWdn1s0Y|td|tdWdn1s*0Y| | dS)NcsdSr|r r r r r ru.sz-CoroutineTest.test_func_18..coroutiner}rr) rrnr\rrr]r&rrrb)r rurZ await_iteritr r r test_func_18+s0((&,.zCoroutineTest.test_func_18csdtjfddfdd}|}|d|d|d||dtdD]}||dqddS)Nrc3s0dVz dVWnty*d7Yn0dSrqrr )CHKr r rAVs   z'CoroutineTest.test_func_19..foocsIdHdSrr r )rAr r ru_sz-CoroutineTest.test_func_19..coroutiner%)rrurrErbrB)r rurrr )rrAr test_func_19Ss      zCoroutineTest.test_func_19cCs&dd}t|}||gdfdS)NcsdS)NrRr r r r r rArsz7CoroutineTest.test_coro_wrapper_send_tuple..foor)r)rEr rAr!r r r test_coro_wrapper_send_tupleqs z*CoroutineTest.test_coro_wrapper_send_tuplecCs8dd}t|}||dt||djddS)NcstdSrQr[r r r r rAysz?CoroutineTest.test_coro_wrapper_send_stop_iterator..foor%rR)r)rTrrErrr r r $test_coro_wrapper_send_stop_iteratorxs z2CoroutineTest.test_coro_wrapper_send_stop_iteratorcstjfddfddfdd}|ttjjdttj jjj j d t dWdn1s0YttjjdS)Nc3sJttjjdVttjjdSr)rErGgetcoroutinestateZ 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)rrurErGrZ CORO_CREATEDrrrZCORO_SUSPENDEDgi_codeco_namer6rZ 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 coroutinerrrucsdSrr r r r r rYrMz(CoroutineTest.test_corotype_1..fzcoroutine object) rrrr__doc__rbr__dict__rErra)r ctrYrr r r test_corotype_1szCoroutineTest.test_corotype_1cCsBdd}|tdt|Wdn1s40YdS)NcsdIdHdSrqr r r r r rAsz'CoroutineTest.test_await_1..foozobject int can.t.*awaitr\rfr#r^r r r test_await_1szCoroutineTest.test_await_1cCsBdd}|tdt|Wdn1s40YdS)NcsgIdHdSrr r r r r rAsz'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 rAsz'CoroutineTest.test_await_3..foor)rEr#r)r^r r r test_await_3szCoroutineTest.test_await_3cs.ddfdd}|t|gdfdS)NcsdSN*r r r r r rSsz'CoroutineTest.test_await_4..barcs IdHSrr r rrr r rAsz'CoroutineTest.test_await_4..foorrEr#r^r rrr 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 rAsz'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)N4rnr r r r rsz7CoroutineTest.test_await_6..Awaitable.__await__Nrr r r r rsrcs IdHSrr r rr r rAsz'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 rAsz'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 rArMz'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 rrr r wrapsz(CoroutineTest.test_await_9..wrapcsdSrr r r r r rSsz'CoroutineTest.test_await_9..barcspdfddi}Gfddd}IdHIdH|dIdHIdHd|IdHS)NrcsSrr r rr r rgrMz9CoroutineTest.test_await_9..foo..cseZdZZdS)z3CoroutineTest.test_await_9..foo..DBN)rrrrr rr r DBsr)r)ZdbrrSrr r rAs,z'CoroutineTest.test_await_9..foocsIdH Srr r rrr r foo2sz(CoroutineTest.test_await_9..foo2iirr rArr 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 rSsz(CoroutineTest.test_await_10..barcsIdHIdHSrr r rrr r rAsz(CoroutineTest.test_await_10..foorrr^r )rSrr test_await_10 s  zCoroutineTest.test_await_10csDddddfdd}fdd}|t|gd fdS) NcSs|Srr valr r r identsz*CoroutineTest.test_await_11..identcsdSr|r r r r r rSsz(CoroutineTest.test_await_11..barcsIdHdS)Nrr r rSrr r rAsz(CoroutineTest.test_await_11..foocsIdHdfS)Nrr r rrr r r"sz)CoroutineTest.test_await_11..foo2)r}rrrr rr test_await_11s  zCoroutineTest.test_await_11csndd}|Gfdddfdd}|tdt|Wdn1sX0YdS)NcsdSr|r 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 rA0sz(CoroutineTest.test_await_12..fooz"__await__\(\) returned a coroutine)r\rfr#rb)r rrAr )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 rA>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|jtjusJ||_dSr)rrrr)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..coro2r})rrr\rr6rr)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 rumsz.CoroutineTest.test_await_15..coroutinecs|IdHdSrr ryr r r waiterpsz+CoroutineTest.test_await_15..waiterz"coroutine is being awaited already)rrurr\r])r rurrr rr test_await_15hs   zCoroutineTest.test_await_15cs2ddfdd}t|\}}||jdS)NcstSr)rr r r r rY}sz&CoroutineTest.test_await_16..fcs&ztWnIdHYS0dSr)KeyErrorr rYr r rsz&CoroutineTest.test_await_16..g)r#r __context__)r rrr!r 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 rAs$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 rAs$)r#rEr6r)r rArYr!rr 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 rAsz&CoroutineTest.test_with_2..foorFr\AttributeErrorr#rr^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 rAsz&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 rAsz&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 sJ4IdH"ddksJWdIdHqF1IdHs<0YdS)Nrtr%r r rr r rsz'CoroutineTest.test_with_5..func)r6AssertionErrorr#)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 rAsz&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 r r r r r sz/CoroutineTest.test_with_7..CM.__aexit__Nrr r r r rsrc sF4IdHddWdIdHqB1IdHs80YdSNr%rr r rr r rAsz&CoroutineTest.test_with_7..foorU'async with' received an object from __aexit__ that does not implement __await__: intz1invalid asynchronous context manager did not fail) r#rfr`rrFr isinstancerfailr rArr 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__cWsdSr r r r r r r'sz/CoroutineTest.test_with_8..CM.__aexit__Nrr r r r r#src sF4IdHd7WdIdHqB1IdHs80YdSrqr r rCNTr r rA+sz&CoroutineTest.test_with_8..foorr%c sjtdD]\}4IdH4d7WdIdHqfWdIdHq1IdHsZ0YqdSNr$r%rBr?rr r rA7s r$c shtdD]Z}4IdH2d7WdIdHqWdIdHq1IdHsX0YqdSrrr?rr r rAEs rc sH4IdH d7WdIdHdS1IdHs:0YdSrqr r rr r rASs)r\rfr#rEr^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 r r r r rgsz/CoroutineTest.test_with_9..CM.__aexit__Nrr r r r rcsrc sF4IdHd7WdIdHqB1IdHs80YdSrqr r rr r rAjsz&CoroutineTest.test_with_9..foor%r6rr#rEr^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 r r r r r{sz0CoroutineTest.test_with_10..CM.__aexit__Nrr r r r rwsrc s|4IdHT4IdHtWdIdHqN1IdHsD0YWdIdHqx1IdHsn0YdSrr]r rr r rA~sz'CoroutineTest.test_with_10..fooz*exception from __aexit__ did not propagate)r#rrFrrr]rrr 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 r r r r rsz0CoroutineTest.test_with_11..CM.__aexit__Nrr r r r rsrc sB4IdHtWdIdHq>1IdHs40YdSrrr rr r rAsz'CoroutineTest.test_with_11..fooz+exception from __aenter__ did not propagate)r#rrFrrrr 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 r r r r rsz0CoroutineTest.test_with_12..CM.__aexit__Nrr r r r rsrc sP4IdH(}|jtWdIdHqL1IdHsB0YdSr)rrr]cmrrr r r rAsz'CoroutineTest.test_with_12..foo)r#r^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 r r r r rsz0CoroutineTest.test_with_13..CM.__aexit__Nrr r r r rsrc sVd74IdHd7WdIdHqJ1IdHs@0Yd7dS)Nr%r'r r rr r rAs2z'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|Srqr r  aiter_callsr r __aiter__sz5CoroutineTest.test_for_1..AsyncIter.__aiter__csF|jd7_|jds,t|jdIdH|jdkr:t|j|jfS)Nr%rRr)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,r r r test1sz'CoroutineTest.test_for_1..test1r%cSsg|] }|dqSrr rhr r r rjrMz,CoroutineTest.test_for_1.. cSsg|] }|dqS)r$r rhr r r rjrMecsL2z*3dHW}|d|ddkrq>q6dddSNrwhat?endr-r?r.r r test2s   z'CoroutineTest.test_for_1..test2r$rcSsg|]}|qSr r rhr r r rjrMr6csJ2z(3dHW}|ddkr q|dq6dddSr3r-r?r.r r test3s   z'CoroutineTest.test_for_1..test3rcSsg|] }|dqSr0r rhr r r rjrMcSsg|]}|qSr r rhr r r rjrMr5)r#rErB)r r/yieldedrr7r:r )r,r'r r test_for_1s,   "  zCoroutineTest.test_for_1csfdt}fdd}|tdt|Wdn1sF0Y|t|dS)Nrcs 2z3dHW}tdq6dSNznever going to happenprintr?tupr r rAsz%CoroutineTest.test_for_2..fooz/async for' requires an object.*__aiter__.*tuplesys getrefcountr\rfr#rE)r refs_beforerAr 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#srHcs 2z3dHW}tdq6dSr=r>r?Zaiterr r rA*sz%CoroutineTest.test_for_3..fooz!that does not implement __anext__rBr rHrErAr rIr 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 rH7srHcs 2z3dHW}tdq6dSr=r>r?rIr r rAAsz%CoroutineTest.test_for_4..fooz7async for' received an invalid object.*__anext__.*tuplerBrJr rIr 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 rHr r rQsz4CoroutineTest.test_for_6..Manager.__aenter__cs d7dS)Nir rrMr r rUsz3CoroutineTest.test_for_6..Manager.__aexit__Nrr rMr 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_|jSNrRr%)r(r)r r r r r*`s z4CoroutineTest.test_for_6..Iterable.__anext__Nr+r r r r IterableYsrOc s`4IdH22z3dHW}d7q6WdIdHqT1IdHsJ0Yd7dSNr%rr r?)rHiterablemanagerr r mainms6z&CoroutineTest.test_for_6..mainerroric s4IdH42z3dHW}d7q6WdIdHqX1IdHsN0Yd74IdH42z3dHW}d7qv6WdIdHq1IdHs0Yd7dSrPr r?rHrOrr r rSs66ic s4IdHDd72z3dHW}d7q6d7WdIdHqh1IdHs^0Yd74IdHDd72z3dHW}d7q6d7WdIdHq1IdHs0Yd7dS)Nrr%irr r?rUr r rSs 4 4i9)rCrDr+r,r-r#rE)r Z mrefs_beforeZ irefs_beforerSr )rHrOrrQrRr 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__NrGr r r r AIsrWcs*2z3dHW}d7q6d7dSNr%rRr r?rWrr r rAs z%CoroutineTest.test_for_7..foorr^r rYr 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__NrGr r r r rWsrWcs*2z3dHW}d7q6d7dSrXr r?rYr r rAs z%CoroutineTest.test_for_8..foorT)r6rr+r,r-r#rEr^r rYr 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 Fsr\cs2z 3dHW}q6dSrr )rr\r r rSsz'CoroutineTest.test_for_11..mainz an invalid object from __anext__)r\rfr exceptionrT __cause__r)r rSrerrr 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 DonerMrbc@s eZdZdZddZddZdS)z+CoroutineTest.test_for_tuple..AIterrcSs|Srr r r r r r(sz5CoroutineTest.test_for_tuple..AIter.__aiter__cs.|jt|krt|jd7_||jdSrq)r(lenr)r r r r r*sz5CoroutineTest.test_for_tuple..AIter.__anext__Nrrrr(r(r*r r r r AItersrecs,dg2z3dHW}|q 6dSrr-r?rerbr!r r rAsz)CoroutineTest.test_for_tuple..foor)rrlr6rrEr^r rfr test_for_tuples  *zCoroutineTest.test_for_tuplecs|GdddtGdddtgfdd}||dWdn1s`0Y|dgdS)Nc@s eZdZdS)z3CoroutineTest.test_for_stop_iteration..DoneNrr r r r rbrMrbc@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_|jSrq)r(r)rr r r r r*sz>CoroutineTest.test_for_stop_iteration..AIter.__anext__Nrdr r r r resrecs*d2z3dHW}|q6dSrr-r?rfr r rAsz2CoroutineTest.test_for_stop_iteration..foor)rrr6rrEr^r rfr 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 rY sz$CoroutineTest.test_comp_1..fcs ddddfDIdHS)Ncsg|]}|IdHqSrr rirr r r rjrMz?CoroutineTest.test_comp_1..run_list..r%)r r rr r run_listsz+CoroutineTest.test_comp_1..run_listcs ddddfDIdHS)Ncsh|]}|IdHqSrr rir r r rMz=CoroutineTest.test_comp_1..run_set..r%rjr r rr r run_setsz*CoroutineTest.test_comp_1..run_setcs ddddfDIdHS)Ncsi|]}|IdHdqS)Nrr rir r r rMz@CoroutineTest.test_comp_1..run_dict1..r%rjr r rr r run_dict1sz,CoroutineTest.test_comp_1..run_dict1cs$ddtddgDIdHS)Ncsi|]\}}||IdHqSrr )rir(rr r r rnrMz@CoroutineTest.test_comp_1..run_dict2..r%rj) enumerater rr r run_dict2sz,CoroutineTest.test_comp_1..run_dict2r%rjr)r%rj)rr%r)r rkrmrorqr 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 rY!sz$CoroutineTest.test_comp_2..fcs0dddddddgfDIdHS)Ncs g|]}|IdHD]}|qqSrr rirsr r r rj%sz?CoroutineTest.test_comp_2..run_list..abcdefgr r rr r rk$sz+CoroutineTest.test_comp_2..run_list)rrrrwrxcs,ddddgdggfDIdHS)Ncs0h|](}|IdHD]}|IdHD]}|q qqSrr )rirrtdr r r rl-sz=CoroutineTest.test_comp_2..run_set..rRr4r r rr r rm,s  z*CoroutineTest.test_comp_2..run_set>rRr4rzcs&ddddgfDIdHS)Ncs&h|]}|IdHD]}|IdHqqSrr rsr r r rl8sz>CoroutineTest.test_comp_2..run_set2..rRr4r r rr r run_set27sz+CoroutineTest.test_comp_2..run_set2rRr4r)r rkrmr{r 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 rYAsz$CoroutineTest.test_comp_3..fcsddddg2IdHS)Ncsg|z3dHW}|dq6Srqr rhr r r rjFrMz?CoroutineTest.test_comp_3..run_list..rRr4r r rr r rkEsz+CoroutineTest.test_comp_3..run_listr1r9csddddg2IdHS)Ncsh|z3dHW}|dq6Srqr rhr r r rlLrMz=CoroutineTest.test_comp_3..run_set..rRr4r r rr r rmKsz*CoroutineTest.test_comp_3..run_setcsddddg2IdHS)Ncs$i|z3dHW}|d|dq6Srwr rhr r r rnRrMz?CoroutineTest.test_comp_3..run_dict..rRr4r r rr r run_dictQsz+CoroutineTest.test_comp_3..run_dict )r1r9cs*ddddg2}dd|2IdHS)NcSs |z3dHW}|dVq6dSrqr rhr r r XrMz=CoroutineTest.test_comp_3..run_gen..rRr4csg|z3dHW}|dq6SNrr rirr r r rjYrMz>CoroutineTest.test_comp_3..run_gen..r rrr r run_genWsz*CoroutineTest.test_comp_3..run_genoyrr rkrmr~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 rY_sz$CoroutineTest.test_comp_4..fcsddddg2IdHS)Ncs&g|z3dHW}|dkr|dq6SrNr rhr r r rjdrMz?CoroutineTest.test_comp_4..run_list..rRr4r r rr r rkcsz+CoroutineTest.test_comp_4..run_listr9csddddg2IdHS)Ncs&h|z3dHW}|dkr|dq6SrNr rhr r r rljrMz=CoroutineTest.test_comp_4..run_set..rRr4r r rr r rmisz*CoroutineTest.test_comp_4..run_setcsddddg2IdHS)Ncs,i|z"3dHW}|dkr|d|dq6S)NrRr%r$r rhr r r rnprMz?CoroutineTest.test_comp_4..run_dict..rRr4r r rr r r~osz+CoroutineTest.test_comp_4..run_dictrcs*ddddg2}dd|2IdHS)NcSs(|z3dHW}|dkr|dVq6dSrNr rhr r r rvrMz=CoroutineTest.test_comp_4..run_gen..rRr4csg|z3dHW}|dq6Srr rr r r rjwrMz>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 rY}sz&CoroutineTest.test_comp_4_2..fcsddtd2IdHS)Ncs6g|z,3dHW}d|kr$dkrnq|dq6SNrrrRr rhr r r rjrMzACoroutineTest.test_comp_4_2..run_list..rr rr r rksz-CoroutineTest.test_comp_4_2..run_list)r1r csddtd2IdHS)Ncs6h|z,3dHW}d|kr$dkrnq|dq6Srr rhr r r rlrMz?CoroutineTest.test_comp_4_2..run_set..rrr rr r rmsz,CoroutineTest.test_comp_4_2..run_set>r1rrcsddtd2IdHS)Ncs<i|z23dHW}d|kr$dkrnq|d|dq6S)NrrrRrr rhr r r rnrMzACoroutineTest.test_comp_4_2..run_dict..rrr rr r r~sz-CoroutineTest.test_comp_4_2..run_dictr2rgcs*ddtd2}dd|2IdHS)NcSs8|z.3dHW}d|kr"dkrnq|dVq6dSrr rhr r r rrMz?CoroutineTest.test_comp_4_2..run_gen..rcsg|z3dHW}|dq6Srr rr r r rjrMz@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 rYsz$CoroutineTest.test_comp_5..fcs$fddddgddgfDIdHS)Nc s@g|]8}|ddkr|2z3dHW}|dkr|dq6qS)rrRNrzr%r )riZpairr(rr r rjsz?CoroutineTest.test_comp_5..run_list..rRr4rz(r r rr r rksz+CoroutineTest.test_comp_5..run_listrjrr rkr rr test_comp_5s  zCoroutineTest.test_comp_5cs2ddfdd}|t|ggdfdS)NcSs|D] }|VqdSrr r}r r r rYsz$CoroutineTest.test_comp_6..fcsddddg2IdHS)Ncs(g|z3dHW}|D] }|dqq6Srqr )riseqr(r r r rjsz?CoroutineTest.test_comp_6..run_list..)rRr4)rzr r rr r rksz+CoroutineTest.test_comp_6..run_list)r1r9rrr rr test_comp_6s   zCoroutineTest.test_comp_6csNddfdd}|tdt|Wdn1s@0YdS)NcSsdVdVtddS)Nr%r$aaa)rr r r r rYsz$CoroutineTest.test_comp_7..fcsdd2IdHS)Ncsg|z3dHW}|q6Srr rhr r r rjrMz?CoroutineTest.test_comp_7..run_list..r r rr r rksz+CoroutineTest.test_comp_7..run_listr)r\rr#rr rr test_comp_7s zCoroutineTest.test_comp_7cCs&dd}|t|ggdfdS)NcsdddDS)NcSsg|]}|qSr r rhr r r rjrMz8CoroutineTest.test_comp_8..f..rr r r r r rYsz$CoroutineTest.test_comp_8..frrr rYr r r test_comp_8s  zCoroutineTest.test_comp_8cs2ddfdd}|t|gddgfdS)NcSsdVdVdSrwr r r r r rLsz&CoroutineTest.test_comp_9..gencs$dd2IdH}dd|DS)Ncsg|z3dHW}|q6Srr rhr r r rjrMz8CoroutineTest.test_comp_9..f..cSsg|]}|qSr r rhr r r rjrMr )lrr r rYsz$CoroutineTest.test_comp_9..fr%r$rrr rr test_comp_9s   zCoroutineTest.test_comp_9cCs*dd}|t|gddddfdS)NcsdddD}dd|DS)NcSsh|]}|qSr r rhr r r rlrMz8CoroutineTest.test_comp_10..f..rcSsi|] }||qSr r )rixr r r rnrMz9CoroutineTest.test_comp_10..f..r )xxr r r rYsz%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 rrMz%CoroutineTest.test_copy..func)r6rfcopyrrb)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 rrMz'CoroutineTest.test_pickle..funcr%) rBpickleHIGHEST_PROTOCOLr6rf PicklingErrordumpsrrb)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 rrMz3CoroutineTest.test_fatal_coro_warning..funcrTzwas never awaited) r+r,rcatch_unraisable_exceptionfilterwarningsrar.rstr unraisable exc_valuerEobject)r rr!r 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 dVdSrQr r r r r source szJCoroutineTest.test_for_assign_raising_stop_async_iteration..sourcecsXt*}2z3dHWd<q6Wdn1s:0Y|jjddS)Nrrr6r6r)rEr^rr r rtgtr r run_fors  "zKCoroutineTest.test_for_assign_raising_stop_async_iteration..run_forr6csXt*}fdd2IdHWdS1s:0Y|jjddS)Ncsg|z3dHWd<dq6Srr rirr r rjrMz`CoroutineTest.test_for_assign_raising_stop_async_iteration..run_list..rr6rr rr r rks 8zLCoroutineTest.test_for_assign_raising_stop_async_iteration..run_listcsxfdd2}|d}t}|IdHWdn1sH0Y|jjt|jjjddS)Ncs |z3dHWd<dVq6dSrr rrr r rrMz^CoroutineTest.test_for_assign_raising_stop_async_iteration..run_gen..rr6 asendr6r]rTr^r_r)rErrLrr!rr r rs  (zKCoroutineTest.test_for_assign_raising_stop_async_iteration..run_genr)r rrrkrr 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)Nrr6r)r!r(jrr r r r/s  "zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2..run_forr6csTt&}dd2IdHWdS1s60Y|jjddS)Ncsg|z3dHW\}}dq6Srr rir(rr r r rj9rMzbCoroutineTest.test_for_assign_raising_stop_async_iteration_2..run_list..rr6rr rr r rk7s 4zNCoroutineTest.test_for_assign_raising_stop_async_iteration_2..run_listcstdd2}|d}t}|IdHWdn1sD0Y|jjt|jjjddS)NcSs |z3dHW\}}dVq6dSrr rr r r r?rMz`CoroutineTest.test_for_assign_raising_stop_async_iteration_2..run_gen..rr6rrrr r r>s  (zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2..run_genr)r rrkrr )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 rr r 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)rrrrrrr r r rY`s.z/CoroAsyncIOCompatTest.test_asyncio_1..f)r%r$r) r import_modulerZnew_event_loopZset_event_loopZrun_until_completerbZset_event_loop_policyrE)r rYZloopr rr test_asyncio_1Ks       z$CoroAsyncIOCompatTest.test_asyncio_1N)rrrrr r r r rIsrc@s,eZdZddZddZddZddZd S) OriginTrackingTestcCsttj}|j|jfSr)rGZ 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) rC#get_coroutine_origin_tracking_depth#set_coroutine_origin_tracking_depthrE contextlibclosingr cr_originrrFrcr6r)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) rCrZ assertWarnsrrr.rErwarning)depthmsgr!)rr r r ros   &z>OriginTrackingTest.test_origin_tracking_warning..checkrz coroutine 'z' was never awaitedr%ruz' 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 )rrCrrrDr)r Z a1_filenameZ a1_linenoZ a2_filenameZ a2_linenororrr )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 ryr r r rgrMzNOriginTrackingTest.test_unawaited_warning_when_module_broken..zcoroutine .* was never awaited) r+_warn_unawaited_coroutinerrZcheck_warningsrrar.rErrrr)r rZorig_wucr!rrr r r )test_unawaited_warning_when_module_brokens,  L(z.foor%) _testcapirrErr^r rr test_tp_await_1 s  zCAPITest.test_tp_await_1cCs2ddlm}|tdg}|t|ddS)Nrrr%)rrrnrEr&r)r rrr r r test_tp_await_2 s zCAPITest.test_tp_await_2cs\ddlmfdd}|td$||ddWdn1sN0YdS)Nrrcsd}|IdHSrqr rrr r rA sz%CAPITest.test_tp_await_3..fooz.__await__.*returned non-iterator of type 'int'r%)rrr\rfrErr^r rr test_tp_await_3 s   zCAPITest.test_tp_await_3N)rrrrrrr r r r r s r__main__)rrrGrrCrZunittestr+testrZtest.support.script_helperrrrr#r)contextmanagerr/ZTestCaser0r>rKrrrZ cpython_onlyrrrSr r r r sP   `*