Your IP : 216.73.216.85


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_coroutines.cpython-39.opt-1.pyc

a

XC?h���@s,ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZGdd�d�ZGdd�d�Z
dd	�Zd
d�Zejdd
��ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Ze	jGdd�dej��Zedk�r(e��dS)�N)�support��assert_python_okc@seZdZdd�Zdd�ZdS)�AsyncYieldFromcCs
||_dS�N��obj)�selfr�r
�9/opt/alt/python39/lib64/python3.9/test/test_coroutines.py�__init__szAsyncYieldFrom.__init__ccs|jEdHdSrr�r	r
r
r�	__await__szAsyncYieldFrom.__await__N��__name__�
__module__�__qualname__rrr
r
r
rr
src@seZdZdd�Zdd�ZdS)�
AsyncYieldcCs
||_dSr��value)r	rr
r
rrszAsyncYield.__init__ccs|jVdSrrr
r
r
rrszAsyncYield.__await__Nrr
r
r
rrsrc
Cslg}d}z|�|�d��Wqty`}z,|jr<|jdnd}WYd}~qdWYd}~qd}~00q||fS�Nr)�append�send�
StopIteration�args)�coro�buffer�result�exr
r
r�	run_asyncs$rc
Cs�|��}g}d}d}z4|dr.|�t|��n|�|�d��|d7}Wqty�}z,|jrh|jdnd}WYd}~q�WYd}~qd}~00q||fS)Nr��)rr�nextrrr)r�awrr�irr
r
r�run_async__await__+s$r%ccsDt���(t�d�dVt��Wd�n1s60YdS)N�ignore)�warnings�catch_warnings�simplefilterr�
gc_collectr
r
r
r�silence_coro_gc>s

r+c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�AsyncBadSyntaxTestc
Csxgd�}|D]f}|j|d��F|�t��t|dd�Wd�n1sJ0YWd�q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]
            z�async def foo():
                def bar():
                 [i for i in els
                    async for b in els]
            z�async def foo():
                def bar():
                 [i for i in els
                    for c in b
                    async for b in els]
            z�async def foo():
                def bar():
                 [i for i in els
                    async for b in els
                    for c in b]
            z�async def foo():
                def bar():
                 [i for i in els
                    for b in await els]
            z�async 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
            z�def foo():
                   def baz(): pass
                   # 456
                   async def bar(): pass
                   # 123
                   await a
            z�async def foo():
                   def baz(): pass
                   # 456
                   async def bar(): pass
                   # 123
                   await = 2
            z�def foo():

                   def baz(): pass

                   async def bar(): pass

                   await a
            z�async 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
            z�async def foo():
                   def bar():
                        def baz():
                            async = 1
            z�async def foo():
                   def bar():
                        def baz():
                            pass
                        async = 1
            z�def foo():
                   async def bar():

                        async def baz():
                            pass

                        def baz():
                            42

                        async = 1
            z�async def foo():
                   def bar():
                        def baz():
                            pass
await foo()
            z�def 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
            ��code�<test>�exec�ZsubTest�assertRaises�SyntaxError�compile�r	Zsamplesr.r
r
r�test_badsyntax_1Hs6z#AsyncBadSyntaxTest.test_badsyntax_1c
Csxgd�}|D]f}|j|d��F|�t��t|dd�Wd�n1sJ0YWd�q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_2�s"z#AsyncBadSyntaxTest.test_badsyntax_2cCs:|�t��tddd�Wd�n1s,0YdS)Nz	async = 1r/r0)r2r3r4r
r
r
r�test_badsyntax_3�sz#AsyncBadSyntaxTest.test_badsyntax_3c
Csxgd�}|D]f}|j|d��F|�t��t|dd�Wd�n1sJ0YWd�q1sh0YqdS)N)z�def foo(await):
                async def foo(): pass
                async def foo():
                    pass
                return await + 1
            z�def foo(await):
                async def foo(): pass
                async def foo(): pass
                return await + 1
            z�def foo(await):

                async def foo(): pass

                async def foo(): pass

                return await + 1
            z�def 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_4�s-z#AsyncBadSyntaxTest.test_badsyntax_4N)rrrr6r7r8r9r
r
r
rr,Fs;'r,c@seZdZdd�ZdS)�TokenizerRegrTestcCs�g}td�D]}|�dj|d��qd�|�}i}t|||�|�|d�d�|d7}i}t|||�|�|d�d�|�t�|d��dS)	Ni�zdef i{i}(): return {i}�r$�
Zi499i�z
async def foo():
    return�foo)	�ranger�format�joinr0�assertEqual�
assertTrue�inspectZiscoroutinefunction)r	Zbufr$�nsr
r
r�test_oneline_defs�s
z#TokenizerRegrTest.test_oneline_defsN)rrrrEr
r
r
rr:�sr:c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_d`�Z2dadb�Z3dcdd�Z4dedf�Z5dgdh�Z6didj�Z7dkdl�Z8dmdn�Z9dodp�Z:dqdr�Z;dsdt�Z<dudv�Z=dwdx�Z>dydz�Z?d{d|�Z@d}d~�ZAdd��ZBd�d��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�S)��
CoroutineTestcCsdd�}|�t|d��dS)Ncss
dVdSrr
r
r
r
r�gen��z%CoroutineTest.test_gen_1.<locals>.genr)�assertFalse�hasattr)r	rGr
r
r�
test_gen_1�szCoroutineTest.test_gen_1cCs�dd�}|�}|�|tj�|�t|jjtj@��|�	t|jjtj
@��|�t|jjtj@��|�	t|jjtj
@��|�t
|�gdf�|�t|��gdf�dd�}|�	t|jjtj@��dS)Nc�sdS�N�
r
r
r
r
rr=�sz&CoroutineTest.test_func_1.<locals>.foorMcSsdSrr
r
r
r
r�bar	rHz&CoroutineTest.test_func_1.<locals>.bar)�assertIsInstance�types�
CoroutineTyperB�bool�__code__�co_flagsrCZCO_COROUTINErIZCO_GENERATOR�cr_coderArr%)r	r=�frNr
r
r�test_func_1�szCoroutineTest.test_func_1cCsBdd�}|�td��t|��Wd�n1s40YdS)Nc�st�dSr�rr
r
r
rr=
sz&CoroutineTest.test_func_2.<locals>.foozcoroutine raised StopIteration)�assertRaisesRegex�RuntimeErrorr�r	r=r
r
r�test_func_2s
�zCoroutineTest.test_func_2cCs*dd�}|�}|�t|�d�|��dS)Nc�st�dSrrXr
r
r
rr=sz&CoroutineTest.test_func_3.<locals>.fooz^<coroutine object.* at 0x.*>$)�assertRegex�repr�close)r	r=rr
r
r�test_func_3szCoroutineTest.test_func_3csDdd�}|�}�fdd�}|��t|�Wd�n1s>0Y|��t|�Wd�n1sl0Y|��t|�Wd�n1s�0Y|��t|�Wd�n1s�0Y|��|D]}q�Wd�n1s�0Y|��dd�|D�Wd�n1�s.0Y|��dS)Nc�st�dSrrXr
r
r
rr=sz&CoroutineTest.test_func_4.<locals>.foocs��td�S�Nz"'coroutine' object is not iterable�rY�	TypeErrorr
r
r
r�<lambda>"s�z+CoroutineTest.test_func_4.<locals>.<lambda>cSsg|]}|�qSr
r
��.0r$r
r
r�
<listcomp>6rHz-CoroutineTest.test_func_4.<locals>.<listcomp>)�list�tuple�sum�iterr_)r	r=r�checkr$r
r
r�test_func_4s"&&&& .zCoroutineTest.test_func_4cs�tjdd����fdd�}�fdd�}|�}|��|D]}q8Wd�n1sR0Y|����D]}��|d�qj��dd	���D�dg���t���d
���tt����d�dS)Ncss
dVdS�Nr!r
r
r
r
rrN;sz&CoroutineTest.test_func_5.<locals>.barc�s��IdHdSrr
r
�rNr
rr=?sz&CoroutineTest.test_func_5.<locals>.foocs��td�Srarbr
r
r
rrdBs�z+CoroutineTest.test_func_5.<locals>.<lambda>r!cSsg|]}|�qSr
r
)rf�elr
r
rrgNrHz-CoroutineTest.test_func_5.<locals>.<listcomp>)r!)rP�	coroutiner_rArir"rk)r	r=rlrrpr
)rNr	r�test_func_5:s
 
zCoroutineTest.test_func_5cs|tjdd����fdd�}|�}|�|�d�d�|�|�d�d�|�t��|�d�Wd�n1sn0YdS)NcssdVdVdS�Nr!r r
r
r
r
rrNSsz&CoroutineTest.test_func_6.<locals>.barc�s��IdHdSrr
r
ror
rr=Xsz&CoroutineTest.test_func_6.<locals>.foor!r )rPrqrArr2r)r	r=rVr
ror�test_func_6Rs
zCoroutineTest.test_func_6cs\dd�}|���fdd�}|�td��t|��Wd�n1sF0Y���dS)Nc�sdSrLr
r
r
r
rrNbsz&CoroutineTest.test_func_7.<locals>.barc3s�EdHdSrr
r
�rr
rr=fsz&CoroutineTest.test_func_7.<locals>.foozCcannot 'yield from' a coroutine object in a non-coroutine generator)rYrcrhr_�r	rNr=r
rur�test_func_7as�(zCoroutineTest.test_func_7csBtj�fdd��}dd�}|��|�t|��gdf����dS)Nc3s
�EdHSrr
r
rur
rrNrsz&CoroutineTest.test_func_8.<locals>.barc�sdS�N�spamr
r
r
r
rr=vsz&CoroutineTest.test_func_8.<locals>.foory)rPrqrArr_rvr
rur�test_func_8qszCoroutineTest.test_func_8c	Cs�dd�}|�td��|�t��Wd�n1s80Y|�td��N|�t��|�D]}qbWd�n1s|0Yt��Wd�n1s�0YdS)Nc�sdSrr
r
r
r
rr=~sz&CoroutineTest.test_func_9.<locals>.fooz0coroutine '.*test_func_9.*foo' was never awaited)ZassertWarnsRegex�RuntimeWarningrr*r2rc)r	r=�_r
r
r�test_func_9}s�&�
 zCoroutineTest.test_func_9cs�d�tj�fdd����fdd�}|�}|��}|�|t|��t|�|�|�d�d�|��d�|��|��d�|�}|��}t|�|�	t
��|�t
dd�Wd�n1s�0Y|��d	�dS)
Nrc3sNz>zdV}|dVWnty2�d7��Yn0W�d7�n
�d7�0dS)Nr �dr!��ZeroDivisionError��a)�Nr
rrG�s
z'CoroutineTest.test_func_10.<locals>.genc�s��IdHdSrr
r
�rGr
rr=�sz'CoroutineTest.test_func_10.<locals>.foorMr~r!�f)rPrqr�assertIsrkr"rArr_r2r��throw)r	r=rr#r
)r�rGr�test_func_10�s$,zCoroutineTest.test_func_10cCsRdd�}|�}|�dt|��|�dt|����|�dt|����|��dS)Nc�sdSrr
r
r
r
r�func�rHz(CoroutineTest.test_func_11.<locals>.funcr�__iter__Zcoroutine_wrapper)�assertIn�dirrr^r_)r	r�rr
r
r�test_func_11�szCoroutineTest.test_func_11csL�fdd�}|��|�td����d�Wd�n1s>0YdS)Nc�s��d�}tIdHdSr)rr=r;��mer
r�g�s
z%CoroutineTest.test_func_12.<locals>.gzcoroutine already executing)rY�
ValueErrorr)r	r�r
r�r�test_func_12�s�zCoroutineTest.test_func_12cCsPdd�}|�}|�td��|�d�Wd�n1s:0Y|��dS)Nc�sdSrr
r
r
r
rr��sz%CoroutineTest.test_func_13.<locals>.gz5can't send non-None value to a just-started coroutinery)rYrcrr_)r	r�rr
r
r�test_func_13�s�(zCoroutineTest.test_func_13csbtjdd����fdd�}|�}|�d�|�td��|��Wd�n1sT0YdS)Ncss
dVdSrr
r
r
r
rrG�sz'CoroutineTest.test_func_14.<locals>.genc�s4z��IdHWnty.��IdHYn0dSr��
GeneratorExitr
r�r
rr�sz(CoroutineTest.test_func_14.<locals>.corozcoroutine ignored GeneratorExit)rPrqrrYrZr_)r	r�cr
r�r�test_func_14�s

�zCoroutineTest.test_func_14cCs�dd�}dd�}|�}|�td��||��d�Wd�n1sF0Y|�td��||��d�Wd�n1s�0YdS)Nc�sdSrxr
r
r
r
r�spammer�sz+CoroutineTest.test_func_15.<locals>.spammerc�s
|IdHSrr
rur
r
r�reader�sz*CoroutineTest.test_func_15.<locals>.readerry�&cannot reuse already awaited coroutine)rYrrrZ)r	r�r�Zspammer_coror
r
r�test_func_15�s,�zCoroutineTest.test_func_15cstjdd����fdd�}�fdd�}|�}||�}|�d�|�d�|�td��|�td��Wd�n1sx0Y||�}|�d�|�td��|�d�Wd�n1s�0Y|�td��|�td	��Wd�n1s�0YdS)
Ncss
dVdSrr
r
r
r
r�nop�sz'CoroutineTest.test_func_16.<locals>.nopc�s��IdHdSrxr
r
�r�r
rr�sz(CoroutineTest.test_func_16.<locals>.sendc�s��IdH|IdHSrr
rur�r
r�read�sz(CoroutineTest.test_func_16.<locals>.read�hamr��wat)rPrqrrY�	Exceptionr�rZ)r	rr�r�r�r
r�r�test_func_16�s(


,
�(�zCoroutineTest.test_func_16cCs�dd�}|�}|�td��|�d�Wd�n1s:0Y|�td��|�d�Wd�n1sp0Y|�td��|�td��Wd�n1s�0Y|��|��dS)Nc�sdSrxr
r
r
r
rrqsz-CoroutineTest.test_func_17.<locals>.coroutineryr�r�)rYrrrZr�r�r_)r	rqrr
r
r�test_func_17s(�(�,zCoroutineTest.test_func_17cCsHdd�}|�}|��}t|�}|�td��|�d�Wd�n1sJ0Y|�td��|�d�Wd�n1s�0Y|�td��t|�Wd�n1s�0Y|�td��|�td��Wd�n1s�0Y|�td��|�td��Wd�n1�s*0Y|�	�|�	�dS)Nc�sdSrxr
r
r
r
rrq.sz-CoroutineTest.test_func_18.<locals>.coroutineryr�r�)
rrkrYrrrZr"r�r�r_)r	rqrZ
await_iter�itr
r
r�test_func_18+s0(�(�&�,�.zCoroutineTest.test_func_18cs�d�tj�fdd����fdd�}|�}|�d�|�d�|��d�|��|��d�td�D]}|��|��d�qddS)Nrc3s0dVz
dVWnty*�d7�Yn0dSrnr�r
)�CHKr
rr=Vs

z'CoroutineTest.test_func_19.<locals>.fooc�s��IdHdSrr
r
)r=r
rrq_sz-CoroutineTest.test_func_19.<locals>.coroutiner!�)rPrqrrAr_r>)r	rqrr|r
)r�r=r�test_func_19Ss

zCoroutineTest.test_func_19cCs&dd�}t|��}|�|gdf�dS)Nc�sdS)N�rMr
r
r
r
rr=rsz7CoroutineTest.test_coro_wrapper_send_tuple.<locals>.foor�)r%rA�r	r=rr
r
r�test_coro_wrapper_send_tupleqs
z*CoroutineTest.test_coro_wrapper_send_tuplecCs8dd�}t|��}|�|dt�|�|djd�dS)Nc�std�SrLrXr
r
r
rr=ysz?CoroutineTest.test_coro_wrapper_send_stop_iterator.<locals>.foor!rM)r%rOrrArr�r
r
r�$test_coro_wrapper_send_stop_iteratorxs
z2CoroutineTest.test_coro_wrapper_send_stop_iteratorcs�tj��fdd����fdd�����fdd�}|����t���tj����j���d���t���tj	����jjj
jd���t
����d�Wd�n1s�0Y��t���tj����j�dS)Nc3sJ��t���tj����j�dV��t���tj����j�dSr)rArC�getcoroutinestateZCORO_RUNNING�assertIsNone�cr_awaitr
)�coro_br	r
rr��s
z&CoroutineTest.test_cr_await.<locals>.ac�s��IdHdSrr
r
r�r
rr��sz&CoroutineTest.test_cr_await.<locals>.cc�s(���j���IdH���j�dSr)r�r�r
)r�r�r	r
r�b�sz&CoroutineTest.test_cr_await.<locals>.br�)rPrqrArCr�ZCORO_CREATEDr�r�rZCORO_SUSPENDED�gi_code�co_namer2rZCORO_CLOSED)r	r�r
)r�r�r�r	r�
test_cr_await�s
(zCoroutineTest.test_cr_awaitcCs�tj}|�d|jj�|�d|jj�|�d|jj�|�d|jdj�|�d|jdj�|�|j	d�dd	�}|�}|�d
t
|��|��dS)Nzinto coroutinezinside coroutinezin coroutinezof the coroutinerrrqc�sdSrr
r
r
r
rrV�rHz(CoroutineTest.test_corotype_1.<locals>.fzcoroutine object)rPrQr�r�__doc__r_r��__dict__rArr^)r	ZctrVr�r
r
r�test_corotype_1�szCoroutineTest.test_corotype_1cCsBdd�}|�td��t|��Wd�n1s40YdS)Nc�sdIdHdSrnr
r
r
r
rr=�sz'CoroutineTest.test_await_1.<locals>.foozobject int can.t.*await�rYrcrr[r
r
r�test_await_1�szCoroutineTest.test_await_1cCsBdd�}|�td��t|��Wd�n1s40YdS)Nc�sgIdHdSrr
r
r
r
rr=�sz'CoroutineTest.test_await_2.<locals>.foozobject list can.t.*awaitr�r[r
r
r�test_await_2�szCoroutineTest.test_await_2cCs@dd�}|�t|��gd�df�|�t|��gd�df�dS)Nc�stgd��IdHdS)N�r!r r�)rr
r
r
rr=�sz'CoroutineTest.test_await_3.<locals>.foor�)rArr%r[r
r
r�test_await_3�szCoroutineTest.test_await_3cs.dd���fdd�}|�t|��gdf�dS)Nc�sdS�N�*r
r
r
r
rrN�sz'CoroutineTest.test_await_4.<locals>.barc�s��IdHSrr
r
ror
rr=�sz'CoroutineTest.test_await_4.<locals>.foor��rArr[r
ror�test_await_4�szCoroutineTest.test_await_4csTGdd�d���fdd�}|�td��t|��Wd�n1sF0YdS)Nc@seZdZdd�ZdS)z-CoroutineTest.test_await_5.<locals>.AwaitablecSsdSrr
r
r
r
rr�sz7CoroutineTest.test_await_5.<locals>.Awaitable.__await__N�rrrrr
r
r
r�	Awaitable�sr�c�s��IdHSrr
r
�r�r
rr=�sz'CoroutineTest.test_await_5.<locals>.foo�(__await__.*returned non-iterator of typer�r[r
r�r�test_await_5�s�zCoroutineTest.test_await_5cs6Gdd�d���fdd�}|�t|��dgdf�dS)Nc@seZdZdd�ZdS)z-CoroutineTest.test_await_6.<locals>.AwaitablecSs
tdg�S)N�4�rkr
r
r
rr�sz7CoroutineTest.test_await_6.<locals>.Awaitable.__await__Nr�r
r
r
rr��sr�c�s��IdHSrr
r
r�r
rr=�sz'CoroutineTest.test_await_6.<locals>.foor�r�r[r
r�r�test_await_6�szCoroutineTest.test_await_6cs6Gdd�d���fdd�}|�t|��dgdf�dS)Nc@seZdZdd�ZdS)z-CoroutineTest.test_await_7.<locals>.Awaitablecss
dVdS)Nr�r~r
r
r
r
rr�sz7CoroutineTest.test_await_7.<locals>.Awaitable.__await__Nr�r
r
r
rr��sr�c�s��IdHSrr
r
r�r
rr=�sz'CoroutineTest.test_await_7.<locals>.foor�r~r�r[r
r�r�test_await_7�szCoroutineTest.test_await_7csTGdd�d���fdd�}|�td��t|��Wd�n1sF0YdS)Nc@seZdZdS)z-CoroutineTest.test_await_8.<locals>.AwaitableN�rrrr
r
r
rr��sr�c�s��IdHSrr
r
r�r
rr=�rHz'CoroutineTest.test_await_8.<locals>.fooz4object Awaitable can't be used in 'await' expressionr�r[r
r�r�test_await_8�s�zCoroutineTest.test_await_8cs^�fdd��dd����fdd�}�fdd�}|�t|��gd	f�|�t|��gd
f�dS)Ncs�Srr
r
ror
r�wrap�sz(CoroutineTest.test_await_9.<locals>.wrapc�sdSr�r
r
r
r
rrN�sz'CoroutineTest.test_await_9.<locals>.barc�spd�fdd�i}G�fdd�d�}��IdH���IdH|d���IdH��IdHd|���IdHS)Nr�cs�Srr
r
�r�r
rrd�rHz9CoroutineTest.test_await_9.<locals>.foo.<locals>.<lambda>cseZdZ�ZdS)z3CoroutineTest.test_await_9.<locals>.foo.<locals>.DBN)rrrr�r
r�r
r�DBsr���)r�)Zdbr��rNr�r
rr=�s,��z'CoroutineTest.test_await_9.<locals>.fooc�s��IdHSrr
r
ror
r�foo2sz(CoroutineTest.test_await_9.<locals>.foo2i��i���r��r	r=r�r
r�r�test_await_9�s	zCoroutineTest.test_await_9cs:dd���fdd���fdd�}|�t|��gdf�dS)Nc�sdSr�r
r
r
r
r�baz
sz(CoroutineTest.test_await_10.<locals>.bazc�s��Srr
r
)r�r
rrNsz(CoroutineTest.test_await_10.<locals>.barc�s��IdHIdHSrr
r
ror
rr=sz(CoroutineTest.test_await_10.<locals>.foor�r�r[r
)rNr�r�
test_await_10szCoroutineTest.test_await_10csDdd��dd����fdd�}�fdd�}|�t|��gd	f�dS)
NcSs|Srr
��valr
r
r�identsz*CoroutineTest.test_await_11.<locals>.identc�sdSrxr
r
r
r
rrNsz(CoroutineTest.test_await_11.<locals>.barc�s���IdHd�S)Nr�r
r
�rNr�r
rr=sz(CoroutineTest.test_await_11.<locals>.fooc�s��IdHdfS)Nr�r
r
ror
rr�"sz)CoroutineTest.test_await_11.<locals>.foo2)ryr�r�r�r
r�r�
test_await_11s
zCoroutineTest.test_await_11csndd�}|��G�fdd�d���fdd�}|�td��t|��Wd�n1sX0Y���dS)Nc�sdSrxr
r
r
r
rr(sz)CoroutineTest.test_await_12.<locals>.corocseZdZ�fdd�ZdS)z.CoroutineTest.test_await_12.<locals>.Awaitablecs�Srr
r
�r�r
rr-sz8CoroutineTest.test_await_12.<locals>.Awaitable.__await__Nr�r
r�r
rr�,sr�c�s��IdHSrr
r
r�r
rr=0sz(CoroutineTest.test_await_12.<locals>.fooz"__await__\(\) returned a coroutine)rYrcrr_)r	rr=r
)r�r�r�
test_await_12's�(zCoroutineTest.test_await_12csTGdd�d���fdd�}|�td��t|��Wd�n1sF0YdS)Nc@seZdZdd�ZdS)z.CoroutineTest.test_await_13.<locals>.AwaitablecSs|Srr
r
r
r
rr;sz8CoroutineTest.test_await_13.<locals>.Awaitable.__await__Nr�r
r
r
rr�:sr�c�s��IdHSrr
r
r�r
rr=>sz(CoroutineTest.test_await_13.<locals>.foor�r�r[r
r�r�
test_await_139s�zCoroutineTest.test_await_13cs�Gdd�d��Gdd�d��Gdd�dt����fdd����fd	d
�}|�}|�d�|�td��|�d�Wd�n1s�0Y|�}|�d�|����|�t�Wd�n1s�0YdS)Nc@seZdZdd�Zdd�ZdS)z,CoroutineTest.test_await_14.<locals>.WrappercSs
||_dSrru)r	rr
r
rrIsz5CoroutineTest.test_await_14.<locals>.Wrapper.__init__cSs
|j��Sr)rrr
r
r
rrLsz6CoroutineTest.test_await_14.<locals>.Wrapper.__await__Nrr
r
r
r�WrapperGsr�c@seZdZdd�ZdS)z/CoroutineTest.test_await_14.<locals>.FutureLikecssdVSrr
r
r
r
rrPsz9CoroutineTest.test_await_14.<locals>.FutureLike.__await__Nr�r
r
r
r�
FutureLikeOsr�c@seZdZdS)z+CoroutineTest.test_await_14.<locals>.MarkerNr�r
r
r
r�MarkerSsr�c�s*z��IdHWSty$��Yn0dSrrr
)r�r�r
r�coro1Vsz*CoroutineTest.test_await_14.<locals>.coro1c�s����IdHSrr
r
)r�r�r
r�coro2[sz*CoroutineTest.test_await_14.<locals>.coro2ry)r�rrYrr2r�r�)r	r�r�r
)r�r�r�r�r�
test_await_14Fs
(
zCoroutineTest.test_await_14csptjdd����fdd�}dd�}|�}|�d�|�td��||��d�Wd�n1sb0YdS)Ncss
dVdSrr
r
r
r
rr�isz(CoroutineTest.test_await_15.<locals>.nopc�s��IdHdSrr
r
r�r
rrqmsz.CoroutineTest.test_await_15.<locals>.coroutinec�s|IdHdSrr
rur
r
r�waiterpsz+CoroutineTest.test_await_15.<locals>.waiterz"coroutine is being awaited already)rPrqrrYrZ)r	rqr�rr
r�r�
test_await_15hs

�zCoroutineTest.test_await_15cs2dd���fdd�}t|��\}}|�|j�dS)Nc�st�Sr)r�r
r
r
rrV}sz&CoroutineTest.test_await_16.<locals>.fc�s&zt�Wn��IdHYS0dSr)�KeyErrorr
�rVr
rr��sz&CoroutineTest.test_await_16.<locals>.g)rr��__context__)r	r�r|rr
r�r�
test_await_16zszCoroutineTest.test_await_16cs�Gdd�d���fdd�}|�}t|�\}}|�|gd���fdd�}|�t��t|��Wd�n1sr0YdS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)z*CoroutineTest.test_with_1.<locals>.ManagercSs
||_dSr)�name)r	r�r
r
rr�sz3CoroutineTest.test_with_1.<locals>.Manager.__init__c�s"td|jd|jg�IdH|S)Nzenter-1-zenter-2-�rr�r
r
r
r�
__aenter__�s
�z5CoroutineTest.test_with_1.<locals>.Manager.__aenter__c�s0td|jd|jg�IdH|jdkr,dSdS)Nzexit-1-zexit-2-�BTr��r	rr
r
r�	__aexit__�s

�
z4CoroutineTest.test_with_1.<locals>.Manager.__aexit__N)rrrrr�r�r
r
r
r�Manager�sr�c
�s��d�4IdH�t}�d�4IdH�8}td|j|jfg�IdHddWd�IdHqp1IdHsf0YWd�IdHq�1IdHs�0YdS)N�Ar��managersr!rr�)r�r��r�r
rr=�s$z&CoroutineTest.test_with_1.<locals>.foo)	z	enter-1-Az	enter-2-Az	enter-1-Bz	enter-2-B)r�r�r�zexit-1-Bzexit-2-Bzexit-1-Azexit-2-Ac
�s��d�4IdH�t}�d�4IdH�8}td|j|jfg�IdHddWd�IdHqp1IdHsf0YWd�IdHq�1IdHs�0YdS)Nr��Cr�r!rr�)r�r�r�r
rr=�s$)rrAr2r�)r	r=rVrr|r
r�r�test_with_1�s�zCoroutineTest.test_with_1csfGdd�d��d���fdd�}|�td��t|��Wd�n1sL0Y|��d�dS)Nc@seZdZdd�ZdS)z%CoroutineTest.test_with_2.<locals>.CMcSsdSrr
r
r
r
rr��sz0CoroutineTest.test_with_2.<locals>.CM.__aenter__N)rrrr�r
r
r
r�CM�sr�c	�sFd���4IdH�d�Wd�IdHqB1IdHs80YdS�NFTr
r
�r�Z
body_executedr
rr=�sz&CoroutineTest.test_with_2.<locals>.foor�F�rY�AttributeErrorrr�r[r
r�r�test_with_2�s(zCoroutineTest.test_with_2csfGdd�d��d���fdd�}|�td��t|��Wd�n1sL0Y|��d�dS)Nc@seZdZdd�ZdS)z%CoroutineTest.test_with_3.<locals>.CMcSsdSrr
r
r
r
rr��sz/CoroutineTest.test_with_3.<locals>.CM.__aexit__N)rrrr�r
r
r
rr��sr�c	�sFd���4IdH�d�Wd�IdHqB1IdHs80YdSr�r
r
r�r
rr=�sz&CoroutineTest.test_with_3.<locals>.foor�Fr�r[r
r�r�test_with_3�s(zCoroutineTest.test_with_3csfGdd�d��d���fdd�}|�td��t|��Wd�n1sL0Y|��d�dS)Nc@seZdZdS)z%CoroutineTest.test_with_4.<locals>.CMNr�r
r
r
rr��sr�c	�sFd���4IdH�d�Wd�IdHqB1IdHs80YdSr�r
r
r�r
rr=�sz&CoroutineTest.test_with_4.<locals>.foor�Fr�r[r
r�r�test_with_4�s(zCoroutineTest.test_with_4csRGdd�d���fdd�}|�t��t|��Wd�n1sD0YdS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_5.<locals>.CMc�s|Srr
r
r
r
rr��sz0CoroutineTest.test_with_5.<locals>.CM.__aenter__c�sdSrr
)r	�excr
r
rr��sz/CoroutineTest.test_with_5.<locals>.CM.__aexit__N�rrrr�r�r
r
r
rr��sr�c	�s>��4IdH�Wd�IdHq:1IdHs00YdSrr
r
�r�r
rr��sz'CoroutineTest.test_with_5.<locals>.func)r2�AssertionErrorr)r	r�r
rr�test_with_5�szCoroutineTest.test_with_5csTGdd�d���fdd�}|�td��t|��Wd�n1sF0YdS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_6.<locals>.CMcSsdS)N�{r
r
r
r
rr��sz0CoroutineTest.test_with_6.<locals>.CM.__aenter__cWsdS�Ni�r
�r	�er
r
rr��sz/CoroutineTest.test_with_6.<locals>.CM.__aexit__Nr�r
r
r
rr��sr�c	�s>��4IdH�Wd�IdHq:1IdHs00YdSrr
r
rr
rr=�sz&CoroutineTest.test_with_6.<locals>.foozV'async with' received an object from __aenter__ that does not implement __await__: intr�r[r
rr�test_with_6�s�zCoroutineTest.test_with_6c
s�Gdd�d���fdd�}zt|��WnXty�}z@|�|jdd�|�|jdu�|�t|jt��WYd}~nd}~00|�d�dS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_7.<locals>.CMc�s|Srr
r
r
r
rr�sz0CoroutineTest.test_with_7.<locals>.CM.__aenter__cWsdS)Ni�r
rr
r
rr�sz/CoroutineTest.test_with_7.<locals>.CM.__aexit__Nr�r
r
r
rr�sr�c	�sF��4IdH�ddWd�IdHqB1IdHs80YdS�Nr!rr
r
rr
rr=sz&CoroutineTest.test_with_7.<locals>.foor�U'async with' received an object from __aexit__ that does not implement __await__: intz1invalid asynchronous context manager did not fail)	rrcr]rrBr��
isinstancer��fail�r	r=r�r
rr�test_with_7s�(zCoroutineTest.test_with_7csXd�Gdd�d����fdd�}|�td��t|��Wd�n1sL0Y|��d���fdd�}|�td��t|��Wd�n1s�0Y|��d	���fd
d�}|�td��t|��Wd�n1s�0Y|��d���fdd�}|�td��t|��Wd�n1�s>0Y|��d
�dS)Nrc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_8.<locals>.CMc�s|Srr
r
r
r
rr�$sz0CoroutineTest.test_with_8.<locals>.CM.__aenter__cWsdSrr
rr
r
rr�'sz/CoroutineTest.test_with_8.<locals>.CM.__aexit__Nr�r
r
r
rr�#sr�c	�sF��4IdH��d7�Wd�IdHqB1IdHs80YdSrnr
r
�r��CNTr
rr=+sz&CoroutineTest.test_with_8.<locals>.foor	r!c
�sjtd�D]\}��4IdH�4�d7�Wd�IdHqfWd�IdHq1IdHsZ0YqdS�Nr r!�r>r;rr
rr=7sr c
�shtd�D]Z}��4IdH�2�d7�Wd�IdHqWd�IdHq1IdHsX0YqdSrrr;rr
rr=Esr�c	�sH��4IdH� �d7�Wd�IdHdS1IdHs:0YdSrnr
r
rr
rr=Ss�)rYrcrrAr[r
rr�test_with_8 s<�(�(�(�*zCoroutineTest.test_with_8csdd�Gdd�d����fdd�}|�t��t|��Wd�n1sJ0Y|��d�dS)Nrc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_9.<locals>.CMc�s|Srr
r
r
r
rr�dsz0CoroutineTest.test_with_9.<locals>.CM.__aenter__c�sdddSrr
rr
r
rr�gsz/CoroutineTest.test_with_9.<locals>.CM.__aexit__Nr�r
r
r
rr�csr�c	�sF��4IdH��d7�Wd�IdHqB1IdHs80YdSrnr
r
rr
rr=jsz&CoroutineTest.test_with_9.<locals>.foor!�r2r�rrAr[r
rr�test_with_9`s(zCoroutineTest.test_with_9c
s�d�Gdd�d����fdd�}zt|��WnZty�}zB|�|jdu�|�t|jt��|�t|jjt��WYd}~nd}~00|�d�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_10.<locals>.CMc�s|Srr
r
r
r
rr�xsz1CoroutineTest.test_with_10.<locals>.CM.__aenter__c�sdddSrr
rr
r
rr�{sz0CoroutineTest.test_with_10.<locals>.CM.__aexit__Nr�r
r
r
rr�wsr�c
�s|��4IdH�T��4IdH�t�Wd�IdHqN1IdHsD0YWd�IdHqx1IdHsn0YdSr�rZr
rr
rr=~sz'CoroutineTest.test_with_10.<locals>.fooz*exception from __aexit__ did not propagate)rr�rBr�r
rZrrr
rr�test_with_10ts�zCoroutineTest.test_with_10c
srd�Gdd�d����fdd�}zt|��Wn4tyb}z|�|jdu�WYd}~nd}~00|�d�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_11.<locals>.CMc�st�dSr)�NotImplementedErrorr
r
r
rr��sz1CoroutineTest.test_with_11.<locals>.CM.__aenter__c�sdddSrr
rr
r
rr��sz0CoroutineTest.test_with_11.<locals>.CM.__aexit__Nr�r
r
r
rr��sr�c	�sB��4IdH�t�Wd�IdHq>1IdHs40YdSrrr
rr
rr=�sz'CoroutineTest.test_with_11.<locals>.fooz+exception from __aenter__ did not propagate)rrrBr�rrr
rr�test_with_11�s&zCoroutineTest.test_with_11cs0d�Gdd�d�����fdd�}t|��dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_12.<locals>.CMc�s|Srr
r
r
r
rr��sz1CoroutineTest.test_with_12.<locals>.CM.__aenter__c�sdS�NTr
rr
r
rr��sz0CoroutineTest.test_with_12.<locals>.CM.__aexit__Nr�r
r
r
rr��sr�c	�sP��4IdH�(}��|j��t�Wd�IdHqL1IdHsB0YdSr)r��	__class__rZ��cm�r�rr	r
rr=�sz'CoroutineTest.test_with_12.<locals>.foo)rr[r
rr�test_with_12�szCoroutineTest.test_with_12csdd�Gdd�d����fdd�}|�t��t|��Wd�n1sJ0Y|��d�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_13.<locals>.CMc�sdddSrr
r
r
r
rr��sz1CoroutineTest.test_with_13.<locals>.CM.__aenter__c�sdSrr
rr
r
rr��sz0CoroutineTest.test_with_13.<locals>.CM.__aexit__Nr�r
r
r
rr��sr�c	�sV�d7���4IdH��d7�Wd�IdHqJ1IdHs@0Y�d7�dS)Nr!r��'r
r
rr
rr=�s2z'CoroutineTest.test_with_13.<locals>.foor!rr[r
rr�test_with_13�s(zCoroutineTest.test_with_13csHd�G�fdd�d��g���fdd�}t|��\}}|��d�|�|dd�tdd	�D��|��d
d�tdd�D��g���fdd
�}t|��\}}|��d�|�|ddg�|��dd�tdd�D�dg�g���fdd�}t|��\}}|��d�|�|dd�tdd	�D��|��dd�tdd�D�ddg�dS)Nrcs(eZdZdd�Z�fdd�Zdd�ZdS)z+CoroutineTest.test_for_1.<locals>.AsyncItercSs
d|_dSrr;r
r
r
rr�sz4CoroutineTest.test_for_1.<locals>.AsyncIter.__init__cs�d7�|Srnr
r
��aiter_callsr
r�	__aiter__�sz5CoroutineTest.test_for_1.<locals>.AsyncIter.__aiter__c�sF|jd7_|jds,t|jd�IdH|jdkr:t�|j|jfS)Nr!rMr~)r$r�StopAsyncIterationr
r
r
r�	__anext__�s

z5CoroutineTest.test_for_1.<locals>.AsyncIter.__anext__N�rrrrr$r&r
r"r
r�	AsyncIter�sr(c�s,��2z3dHW\}}��||�q6dSr�r)Zi1Zi2�r(rr
r�test1�sz'CoroutineTest.test_for_1.<locals>.test1r!cSsg|]}|d�qS�r~r
rer
r
rrg�rHz,CoroutineTest.test_for_1.<locals>.<listcomp>�cSsg|]}|d�qS)r r
rer
r
rrg�rH�ec�sL��2z*3dHW}��|d�|ddkrq>q6��d���d�dS�Nr��what?�endr)r;r*r
r�test2�sz'CoroutineTest.test_for_1.<locals>.test2r r~��cSsg|]}|�qSr
r
rer
r
rrg�rH�r2c�sJ��2z(3dHW}|ddkr q��|d�q6��d���d�dSr/r)r;r*r
r�test3sz'CoroutineTest.test_for_1.<locals>.test3r�cSsg|]}|d�qSr,r
rer
r
rrgrHcSsg|]}|�qSr
r
rer
r
rrgrHr1)rrAr>)r	r+Zyieldedr|r3r6r
)r(r#rr�
test_for_1�s,
"
�zCoroutineTest.test_for_1csfd�t���}�fdd�}|�td��t|��Wd�n1sF0Y|�t���|�dS)Nr�c�s �2z3dHW}td�q6dS�Nznever going to happen��printr;��tupr
rr=sz%CoroutineTest.test_for_2.<locals>.fooz/async for' requires an object.*__aiter__.*tuple��sys�getrefcountrYrcrrA)r	�refs_beforer=r
r;r�
test_for_2s
�(zCoroutineTest.test_for_2csvGdd�d�}|��t���}�fdd�}|�td��t|��Wd�n1sV0Y|�t���|�dS)Nc@seZdZdd�ZdS)z#CoroutineTest.test_for_3.<locals>.IcSs|Srr
r
r
r
rr$$sz-CoroutineTest.test_for_3.<locals>.I.__aiter__N�rrrr$r
r
r
r�I#srCc�s �2z3dHW}td�q6dSr8r9r;�Zaiterr
rr=*sz%CoroutineTest.test_for_3.<locals>.fooz!that does not implement __anext__r=�r	rCr@r=r
rDr�
test_for_3"s
�(zCoroutineTest.test_for_3csvGdd�d�}|��t���}�fdd�}|�td��t|��Wd�n1sV0Y|�t���|�dS)Nc@seZdZdd�Zdd�ZdS)z#CoroutineTest.test_for_4.<locals>.IcSs|Srr
r
r
r
rr$8sz-CoroutineTest.test_for_4.<locals>.I.__aiter__cSsdS)Nr
r
r
r
r
rr&;sz-CoroutineTest.test_for_4.<locals>.I.__anext__N)rrrr$r&r
r
r
rrC7srCc�s �2z3dHW}td�q6dSr8r9r;rDr
rr=Asz%CoroutineTest.test_for_4.<locals>.fooz7async for' received an invalid object.*__anext__.*tupler=rEr
rDr�
test_for_46s
�(zCoroutineTest.test_for_4csd�G�fdd�d��Gdd�d��������t���}t���}���fdd�}t���$t�d�t|��Wd�n1s�0Y|��d	�|�t���|�|�t���|����fd
d�}t|��|��d����fdd�}t|��|��d
�dS)Nrcs$eZdZ�fdd�Z�fdd�ZdS)z)CoroutineTest.test_for_6.<locals>.Managerc�s�d7�dS)Nr r
r
�rCr
rr�Qsz4CoroutineTest.test_for_6.<locals>.Manager.__aenter__c�s�d7�dS)Ni��r
r�rHr
rr�Usz3CoroutineTest.test_for_6.<locals>.Manager.__aexit__Nr�r
rHr
rr�Psr�c@s$eZdZdd�Zdd�Zdd�ZdS)z*CoroutineTest.test_for_6.<locals>.IterablecSs
d|_dSrr;r
r
r
rrZsz3CoroutineTest.test_for_6.<locals>.Iterable.__init__cSs|Srr
r
r
r
rr$]sz4CoroutineTest.test_for_6.<locals>.Iterable.__aiter__c�s"|jdkrt�|jd7_|jS�NrMr!)r$r%r
r
r
rr&`s
z4CoroutineTest.test_for_6.<locals>.Iterable.__anext__Nr'r
r
r
r�IterableYsrJc	�s`�4IdH�2�2z3dHW}�d7�q6Wd�IdHqT1IdHsJ0Y�d7�dS�Nr!r�r
r;)rC�iterable�managerr
r�mainms6z&CoroutineTest.test_for_6.<locals>.main�errori��c	�s���4IdH�4��2z3dHW}�d7�q6Wd�IdHqX1IdHsN0Y�d7���4IdH�4��2z3dHW}�d7�qv6Wd�IdHq�1IdHs�0Y�d7�dSrKr
r;�rCrJr�r
rrN�s66i�c	�s���4IdH�D�d7���2z3dHW}�d7�q6�d7�Wd�IdHqh1IdHs^0Y�d7���4IdH�D�d7���2z3dHW}�d7�q�6�d7�Wd�IdHq�1IdHs�0Y�d7�dS)Nr~r!i���r�r
r;rPr
rrN�s
4
4i��9)r>r?r'r(r)rrA)r	Zmrefs_beforeZirefs_beforerNr
)rCrJr�rLrMr�
test_for_6Ms(	



(

zCoroutineTest.test_for_6csdd�Gdd�d����fdd�}|�t��t|��Wd�n1sJ0Y|��d�dS)Nrc@seZdZdd�ZdS)z$CoroutineTest.test_for_7.<locals>.AIcSsdddSrr
r
r
r
rr$�sz.CoroutineTest.test_for_7.<locals>.AI.__aiter__NrBr
r
r
r�AI�srRc�s*��2z3dHW}�d7�q6�d7�dS�Nr!rMr
r;�rRrr
rr=�sz%CoroutineTest.test_for_7.<locals>.foorr[r
rTr�
test_for_7�s(zCoroutineTest.test_for_7c	s�d�Gdd�d����fdd�}|�t��Lt���$t�d�t|��Wd�n1s^0YWd�n1s|0Y|��d�dS)Nrc@seZdZdd�ZdS)z$CoroutineTest.test_for_8.<locals>.AIcSsdddSrr
r
r
r
rr$�sz.CoroutineTest.test_for_8.<locals>.AI.__aiter__NrBr
r
r
rrR�srRc�s*��2z3dHW}�d7�q6�d7�dSrSr
r;rTr
rr=�sz%CoroutineTest.test_for_8.<locals>.foorO)r2r�r'r(r)rrAr[r
rTr�
test_for_8�s

FzCoroutineTest.test_for_8csjGdd�d���fdd�}|�td��}|��d�Wd�n1sH0Y|j}|�|jt�dS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)z$CoroutineTest.test_for_11.<locals>.FcSs|Srr
r
r
r
rr$�sz.CoroutineTest.test_for_11.<locals>.F.__aiter__cSs|Srr
r
r
r
rr&�sz.CoroutineTest.test_for_11.<locals>.F.__anext__cSsdddSrr
r
r
r
rr�sz.CoroutineTest.test_for_11.<locals>.F.__await__N)rrrr$r&rr
r
r
r�F�srWc�s��2z3dHW}q6dSrr
)r|�rWr
rrN�sz'CoroutineTest.test_for_11.<locals>.mainz an invalid object from __anext__)rYrcr�	exceptionrO�	__cause__r�)r	rNr��errr
rXr�test_for_11�s�*zCoroutineTest.test_for_11cs|Gdd�dt��Gdd�dt��g����fdd�}|����|��d�Wd�n1s`0Y|��dg�dS)Nc@seZdZdS)z*CoroutineTest.test_for_tuple.<locals>.DoneNr�r
r
r
r�Done�rHr]c@s eZdZdZdd�Zdd�ZdS)z+CoroutineTest.test_for_tuple.<locals>.AIterrcSs|Srr
r
r
r
rr$�sz5CoroutineTest.test_for_tuple.<locals>.AIter.__aiter__c�s.|jt|�krt�|jd7_||jdSrn)r$�lenr%r
r
r
rr&�sz5CoroutineTest.test_for_tuple.<locals>.AIter.__anext__N�rrrr$r$r&r
r
r
r�AIter�sr`c�s,�dg�2z3dHW}��|�q
6��dSr�r)r;�r`r]rr
rr=�sz)CoroutineTest.test_for_tuple.<locals>.foor�)r�rir2rrAr[r
rar�test_for_tuple�s
*zCoroutineTest.test_for_tuplecs|Gdd�dt��Gdd�dt��g����fdd�}|����|��d�Wd�n1s`0Y|��dg�dS)Nc@seZdZdS)z3CoroutineTest.test_for_stop_iteration.<locals>.DoneNr�r
r
r
rr]�rHr]c@s eZdZdZdd�Zdd�ZdS)z4CoroutineTest.test_for_stop_iteration.<locals>.AIterrcSs|Srr
r
r
r
rr$�sz>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__aiter__c�s|jr
t�|jd7_|jSrn)r$r%rr
r
r
rr&�sz>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__anext__Nr_r
r
r
rr`�sr`c�s*�d�2z3dHW}��|�q6��dSr�r)r;rar
rr=sz2CoroutineTest.test_for_stop_iteration.<locals>.foor�)r�rr2rrAr[r
rar�test_for_stop_iteration�s
*z%CoroutineTest.test_for_stop_iterationcs�dd���fdd�}�fdd�}�fdd�}�fd	d
�}|�t|��gddgf�|�t|��gddhf�|�t|��gd
d
d�f�|�t|��gddd�f�dS)Nc�s|Srr
r;r
r
rrVsz$CoroutineTest.test_comp_1.<locals>.fc�s dd��d��d�fD�IdHS)Nc�sg|]}|IdH�qSrr
�rfr�r
r
rrgrHz?CoroutineTest.test_comp_1.<locals>.run_list.<locals>.<listcomp>r!�)r
r
r�r
r�run_listsz+CoroutineTest.test_comp_1.<locals>.run_listc�s dd��d��d�fD�IdHS)Nc�sh|]}|IdH�qSrr
rdr
r
r�	<setcomp>rHz=CoroutineTest.test_comp_1.<locals>.run_set.<locals>.<setcomp>r!rer
r
r�r
r�run_setsz*CoroutineTest.test_comp_1.<locals>.run_setc�s dd��d��d�fD�IdHS)Nc�si|]}|IdHd�qS)Nr�r
rdr
r
r�
<dictcomp>rHz@CoroutineTest.test_comp_1.<locals>.run_dict1.<locals>.<dictcomp>r!rer
r
r�r
r�	run_dict1sz,CoroutineTest.test_comp_1.<locals>.run_dict1c�s$dd�t�d��d�g�D�IdHS)Nc�si|]\}}||IdH�qSrr
)rfr$r�r
r
rrirHz@CoroutineTest.test_comp_1.<locals>.run_dict2.<locals>.<dictcomp>r!re)�	enumerater
r�r
r�	run_dict2sz,CoroutineTest.test_comp_1.<locals>.run_dict2r!rer�)r!re)rr!r�)r	rfrhrjrlr
r�r�test_comp_1szCoroutineTest.test_comp_1cs~dd���fdd�}|�t|��ggd�f��fdd�}|�t|��ghd�f��fd	d
�}|�t|��gddhf�dS)
Nc�s|Srr
r;r
r
rrV!sz$CoroutineTest.test_comp_2.<locals>.fc�s0dd��d��d��d��ddg�fD�IdHS)Nc�s g|]}|IdHD]}|�qqSrr
�rfr��sr
r
rrg%s�z?CoroutineTest.test_comp_2.<locals>.run_list.<locals>.<listcomp>��abc�de�fgr
r
r�r
rrf$sz+CoroutineTest.test_comp_2.<locals>.run_list)r�r�r�rrrsc�s,dd���ddg��dg�g�fD�IdHS)Nc�s0h|](}|IdHD]}|IdHD]}|�q qqSrr
)rfr�ro�dr
r
rrg-s�z=CoroutineTest.test_comp_2.<locals>.run_set.<locals>.<setcomp>rM�r0r
r
r�r
rrh,s
��z*CoroutineTest.test_comp_2.<locals>.run_set>rMr0ruc�s&dd���d��d�g�fD�IdHS)Nc�s&h|]}|IdHD]}|IdH�qqSrr
rnr
r
rrg8s�z>CoroutineTest.test_comp_2.<locals>.run_set2.<locals>.<setcomp>rMr0r
r
r�r
r�run_set27s�z+CoroutineTest.test_comp_2.<locals>.run_set2rMr0r�)r	rfrhrvr
r�r�test_comp_2 s 
�
�
�zCoroutineTest.test_comp_2cs�dd���fdd�}|�t|��gddgf��fdd�}|�t|��gddhf��fd	d
�}|�t|��gddd
�f��fdd�}|�t|��gddgf�dS)NcSs|D]
}|VqdSrr
�r�r$r
r
rrVAsz$CoroutineTest.test_comp_3.<locals>.fc�sdd��ddg�2�IdHS)Nc�sg|z3dHW}|d�q6Srnr
rer
r
rrgFrHz?CoroutineTest.test_comp_3.<locals>.run_list.<locals>.<listcomp>rMr0r
r
r�r
rrfEsz+CoroutineTest.test_comp_3.<locals>.run_listr-r5c�sdd��ddg�2�IdHS)Nc�sh|z3dHW}|d�q6Srnr
rer
r
rrgLrHz=CoroutineTest.test_comp_3.<locals>.run_set.<locals>.<setcomp>rMr0r
r
r�r
rrhKsz*CoroutineTest.test_comp_3.<locals>.run_setc�sdd��ddg�2�IdHS)Nc�s$i|z3dHW}|d|d�q6Srsr
rer
r
rriRrHz?CoroutineTest.test_comp_3.<locals>.run_dict.<locals>.<dictcomp>rMr0r
r
r�r
r�run_dictQsz+CoroutineTest.test_comp_3.<locals>.run_dict��)r-r5c�s*dd��ddg�2�}dd�|2�IdHS)NcSs |z3dHW}|dVq6dSrnr
rer
r
r�	<genexpr>XrHz=CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<genexpr>rMr0c�sg|z3dHW}|d�q6S�Nr~r
�rfr�r
r
rrgYrHz>CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<listcomp>r
r�r�r
r�run_genWsz*CoroutineTest.test_comp_3.<locals>.run_gen�o�yr��r	rfrhryrr
r�r�test_comp_3@s*
�
��
�zCoroutineTest.test_comp_3cs�dd���fdd�}|�t|��gdgf��fdd�}|�t|��gdhf��fdd	�}|�t|��gdd
if��fdd�}|�t|��gd
gf�dS)NcSs|D]
}|VqdSrr
rxr
r
rrV_sz$CoroutineTest.test_comp_4.<locals>.fc�sdd��ddg�2�IdHS)Nc�s&g|z3dHW}|dkr|d�q6SrIr
rer
r
rrgdrHz?CoroutineTest.test_comp_4.<locals>.run_list.<locals>.<listcomp>rMr0r
r
r�r
rrfcsz+CoroutineTest.test_comp_4.<locals>.run_listr5c�sdd��ddg�2�IdHS)Nc�s&h|z3dHW}|dkr|d�q6SrIr
rer
r
rrgjrHz=CoroutineTest.test_comp_4.<locals>.run_set.<locals>.<setcomp>rMr0r
r
r�r
rrhisz*CoroutineTest.test_comp_4.<locals>.run_setc�sdd��ddg�2�IdHS)Nc�s,i|z"3dHW}|dkr|d|d�q6S)NrMr!r r
rer
r
rriprHz?CoroutineTest.test_comp_4.<locals>.run_dict.<locals>.<dictcomp>rMr0r
r
r�r
rryosz+CoroutineTest.test_comp_4.<locals>.run_dictr{c�s*dd��ddg�2�}dd�|2�IdHS)NcSs(|z3dHW}|dkr|dVq6dSrIr
rer
r
rr|vrHz=CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<genexpr>rMr0c�sg|z3dHW}|d�q6Sr}r
r~r
r
rrgwrHz>CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<listcomp>r
r�r�r
rrusz*CoroutineTest.test_comp_4.<locals>.run_genr�r�r�r
r�r�test_comp_4^s*��
��zCoroutineTest.test_comp_4cs�dd���fdd�}|�t|��ggd�f��fdd�}|�t|��ghd�f��fd	d
�}|�t|��gddd
d�f��fdd�}|�t|��ggd�f�dS)NcSs|D]
}|VqdSrr
rxr
r
rrV}sz&CoroutineTest.test_comp_4_2.<locals>.fc�sdd��td��2�IdHS)Nc�s6g|z,3dHW}d|kr$dkrnq|d�q6S�NrrrMr
rer
r
rrg�rHzACoroutineTest.test_comp_4_2.<locals>.run_list.<locals>.<listcomp>�rr
r�r
rrf�sz-CoroutineTest.test_comp_4_2.<locals>.run_list)r-rz�
c�sdd��td��2�IdHS)Nc�s6h|z,3dHW}d|kr$dkrnq|d�q6Sr�r
rer
r
rrg�rHz?CoroutineTest.test_comp_4_2.<locals>.run_set.<locals>.<setcomp>r�rr
r�r
rrh�sz,CoroutineTest.test_comp_4_2.<locals>.run_set>r-rzr�c�sdd��td��2�IdHS)Nc�s<i|z23dHW}d|kr$dkrnq|d|d�q6S)NrrrMr~r
rer
r
rri�rHzACoroutineTest.test_comp_4_2.<locals>.run_dict.<locals>.<dictcomp>r�rr
r�r
rry�sz-CoroutineTest.test_comp_4_2.<locals>.run_dictr.r��gc�s*dd��td��2�}dd�|2�IdHS)NcSs8|z.3dHW}d|kr"dkrnq|dVq6dSr�r
rer
r
rr|�rHz?CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<genexpr>r�c�sg|z3dHW}|d�q6Sr}r
r~r
r
rrg�rHz@CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<listcomp>rr�r�r
rr�sz,CoroutineTest.test_comp_4_2.<locals>.run_gen)r��p�qr�r�r
r�r�
test_comp_4_2|s*
�
��
�zCoroutineTest.test_comp_4_2cs0dd���fdd�}|�t|��gdgf�dS)NcSs|D]
}|VqdSrr
rxr
r
rrV�sz$CoroutineTest.test_comp_5.<locals>.fc�s$�fdd�ddgddgfD�IdHS)Nc	�s@g|]8}|ddkr�|�2z3dHW}|dkr|d�q6qS)rrMNrur!r
)rfZpairr$r�r
rrg�s�z?CoroutineTest.test_comp_5.<locals>.run_list.<locals>.<listcomp>rMr0ru�(r
r
r�r
rrf�sz+CoroutineTest.test_comp_5.<locals>.run_listrer��r	rfr
r�r�test_comp_5�s�zCoroutineTest.test_comp_5cs2dd���fdd�}|�t|��ggd�f�dS)NcSs|D]
}|VqdSrr
rxr
r
rrV�sz$CoroutineTest.test_comp_6.<locals>.fc�sdd��ddg�2�IdHS)Nc�s(g|z3dHW}|D]}|d�qq6Srnr
)rf�seqr$r
r
rrg�s�z?CoroutineTest.test_comp_6.<locals>.run_list.<locals>.<listcomp>)rMr0)rur
r
r�r
rrf�sz+CoroutineTest.test_comp_6.<locals>.run_list)r-r5�r�r�r
r�r�test_comp_6�s
�zCoroutineTest.test_comp_6csNdd���fdd�}|�td��t|��Wd�n1s@0YdS)NcSsdVdVtd��dS)Nr!r �aaa)r�r
r
r
rrV�sz$CoroutineTest.test_comp_7.<locals>.fc�sdd���2�IdHS)Nc�sg|z3dHW}|�q6Srr
rer
r
rrg�rHz?CoroutineTest.test_comp_7.<locals>.run_list.<locals>.<listcomp>r
r
r�r
rrf�sz+CoroutineTest.test_comp_7.<locals>.run_listr�)rYr�rr�r
r�r�test_comp_7�szCoroutineTest.test_comp_7cCs&dd�}|�t|��ggd�f�dS)Nc�sdd�dD�S)NcSsg|]}|�qSr
r
rer
r
rrg�rHz8CoroutineTest.test_comp_8.<locals>.f.<locals>.<listcomp>r�r
r
r
r
rrV�sz$CoroutineTest.test_comp_8.<locals>.fr�r��r	rVr
r
r�test_comp_8�s

�zCoroutineTest.test_comp_8cs2dd���fdd�}|�t|��gddgf�dS)NcSsdVdVdSrsr
r
r
r
rrG�sz&CoroutineTest.test_comp_9.<locals>.genc�s$dd���2�IdH}dd�|D�S)Nc�sg|z3dHW}|�q6Srr
rer
r
rrg�rHz8CoroutineTest.test_comp_9.<locals>.f.<locals>.<listcomp>cSsg|]}|�qSr
r
rer
r
rrg�rHr
)�lr�r
rrV�sz$CoroutineTest.test_comp_9.<locals>.fr!r r�r�r
r�r�test_comp_9�s
�zCoroutineTest.test_comp_9cCs*dd�}|�t|��gdddd�f�dS)Nc�sdd�dD�}dd�|D�S)NcSsh|]}|�qSr
r
rer
r
rrg�rHz8CoroutineTest.test_comp_10.<locals>.f.<locals>.<setcomp>r�cSsi|]
}||�qSr
r
)rf�xr
r
rri�rHz9CoroutineTest.test_comp_10.<locals>.f.<locals>.<dictcomp>r
)Zxxr
r
rrV�sz%CoroutineTest.test_comp_10.<locals>.fr!r r�r�r�r�r
r
r�test_comp_10�s
�zCoroutineTest.test_comp_10cCs�dd�}|�}|�t��t�|�Wd�n1s80Y|��}z@|�t��t�|�Wd�n1sv0YW|��n
|��0dS)Nc�sdSrr
r
r
r
rr��rHz%CoroutineTest.test_copy.<locals>.func)r2rc�copyrr_)r	r�rr#r
r
r�	test_copy�s(*zCoroutineTest.test_copyc	Cs�dd�}|�}ttjd�D]@}|�ttjf��t�||�Wd�q1sR0Yq|��}z\ttjd�D]@}|�ttjf��t�||�Wd�qv1s�0YqvW|��n
|��0dS)Nc�sdSrr
r
r
r
rr��rHz'CoroutineTest.test_pickle.<locals>.funcr!)	r>�pickleZHIGHEST_PROTOCOLr2rcZ
PicklingError�dumpsrr_)r	r�r�protor#r
r
r�test_pickle�s,.zCoroutineTest.test_picklec	Cs�dd�}t����t���\}t�d�|�}t|�}d}t��|�dt|j	j
��|�t|j	j�|�Wd�n1s|0YWd�n1s�0YdS)Nc�sdSrr
r
r
r
rr��rHz3CoroutineTest.test_fatal_coro_warning.<locals>.funcrOzwas never awaited)
r'r(r�catch_unraisable_exception�filterwarningsr^r*r��str�
unraisable�	exc_valuerA�object)r	r�rr�	coro_reprr
r
r�test_fatal_coro_warning�s
�
z%CoroutineTest.test_fatal_coro_warningcs�Gdd�d�}|��dd�����fdd�}��t|��gdf����fdd	�}��t|��gdf����fd
d�}��t|��gdf�dS)Nc@seZdZdd�ZdS)zMCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.BadTargetcSstd��dSr��r%)r	�keyrr
r
r�__setitem__	szYCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.BadTarget.__setitem__N)rrrr�r
r
r
r�	BadTargetsr�cSs
dVdSrLr
r
r
r
r�sourceszJCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.sourcec�sX��t��*}��2z3dHW�d<q6Wd�n1s:0Y��|jjd�dS)Nr�r�r2�r2r%rArYrr�r	r��tgtr
r�run_fors
"zKCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_forr2c�sX��t��*}�fdd���2�IdHWd�S1s:0Y��|jjd�dS)Nc�sg|z3dHW�d<d�q6Srr
�rf�r�r
rrgrHz`CoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_list.<locals>.<listcomp>r�r2r�rr�r
rrfs8zLCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_listc�sx�fdd���2�}|�d�}��t��}|IdHWd�n1sH0Y��|jjt���|jjjd�dS)Ncs |z3dHW�d<dVq6dSrr
r�r�r
rr|rHz^CoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_gen.<locals>.<genexpr>r�r2�	�asendr2rZrOrYrZr%rAr�rGr�rr�r
rrs
(zKCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_genr�)r	r�r�rfrr
r�r�,test_for_assign_raising_stop_async_iterationsz:CoroutineTest.test_for_assign_raising_stop_async_iterationcs�Gdd�d���fdd����fdd�}��t|��gdf���fdd	�}��t|��gdf���fd
d�}��t|��gdf�dS)Nc@seZdZdd�ZdS)zQCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.BadIterablecSstd��dSr�r�r
r
r
rr�*szZCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.BadIterable.__iter__N)rrrr�r
r
r
r�BadIterable)sr�cs��VdSrr
r
)r�r
r�badpairs,szNCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.badpairsc�sX��t��*}��2z3dHW\}}q6Wd�n1s:0Y��|jjd�dS)Nr�r2r�)rr$�j�r�r	r
rr�/s
"zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_forr2c�sT��t��&}dd���2�IdHWd�S1s60Y��|jjd�dS)Nc�sg|z3dHW\}}d�q6Srr
�rfr$r�r
r
rrg9rHzbCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_list.<locals>.<listcomp>r�r2r�rr�r
rrf7s4zNCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_listc�stdd���2�}|�d�}��t��}|IdHWd�n1sD0Y��|jjt���|jjjd�dS)NcSs |z3dHW\}}dVq6dSrr
r�r
r
rr|?rHz`CoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_gen.<locals>.<genexpr>r�r2r�r�r�r
rr>s
(zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_genr�)r	r�rfrr
)r�r�r	r�.test_for_assign_raising_stop_async_iteration_2(sz<CoroutineTest.test_for_assign_raising_stop_async_iteration_2N)RrrrrKrWr\r`rmrrrtrwrzr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
rrrrrr!r7rArFrGrQrUrVr\rbrcrmrwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rrF�s�	#
	(	


"(@H\ 
	
!rFc@seZdZdd�ZdS)�CoroAsyncIOCompatTestc	s�t�d��Gdd�dt��g�G��fdd�d������fdd�}���}��|�z:z|�|��Wn�yzYn0W|����d�n|����d�0|��gd��dS)	N�asyncioc@seZdZdS)z9CoroAsyncIOCompatTest.test_asyncio_1.<locals>.MyExceptionNr�r
r
r
r�MyExceptionPsr�cs(eZdZ��fdd�Z��fdd�ZdS)z0CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CMc�s(��d���d�IdH��d�|S)Nr!�{�G�z�?r )r�sleepr
�r�rr
rr�Vs

z;CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aenter__c�s ��d�IdH��|j�dS)Nr�)r�rr)r	�exc_typeZexc_valZexc_tbr�r
rr�\sz:CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aexit__Nr�r
r�r
rr�Usr�c	�s\��4IdH�*}��d�IdH��Wd�IdHqN1IdHsD0Y��d�dS)Nr�Zunreachable)r�rr��r�r�r�rr
rrV`s.z/CoroAsyncIOCompatTest.test_asyncio_1.<locals>.f)r!r r�)	r�
import_moduler�Znew_event_loopZset_event_loopZrun_until_completer_Zset_event_loop_policyrA)r	rVZloopr
r�r�test_asyncio_1Ks 

�z$CoroAsyncIOCompatTest.test_asyncio_1N)rrrr�r
r
r
rr�Isr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�OriginTrackingTestcCst�t��j�}|j|jfSr)rCZgetframeinfoZcurrentframe�f_back�filename�lineno)r	�infor
r
r�heretszOriginTrackingTest.herec	s$t��}�zdd��t�d���t��d�t�����}��|j�Wd�n1s\0Yt�d���t��d����\}}t�����*}��|j||ddff�Wd�n1s�0Yt�d���t��d���fdd�}���\}}|�\\}}}t�|��2��|j||d	f||ddff�Wd�n1�sX0Yt�d
�t�����6}��	dt
|j�k�o�d
kn�Wd�n1�s�0Y��t��t�d�Wd�n1�s�0Y��t��d
�Wt�|�nt�|�0dS)Nc�sdSrr
r
r
r
r�corofn{sz7OriginTrackingTest.test_origin_tracking.<locals>.corofnrr!�test_origin_trackingr cs�����fSr)r�r
�r�r	r
r�nested�sz7OriginTrackingTest.test_origin_tracking.<locals>.nestedr�r����)
r>�#get_coroutine_origin_tracking_depth�#set_coroutine_origin_tracking_depthrA�
contextlib�closingr��	cr_originr�rBr^r2r�)r	�
orig_depthrZfnamer�r�Znested_fnameZ
nested_linenor
r�rr�xs@
*
�"
��$
F*z'OriginTrackingTest.test_origin_trackingc
sdd�����\}}�fdd��|d7}���\}}�fdd��|d7}��fdd	�}t��}z�|d
d�j�d��}|d
d�d�j�d�dd|�d|�d�dg��|dd�d�j�d�dd|�d|�d�dd|�d|�d�dg��Wt�|�nt�|�0dS)Nc�sdSrr
r
r
r
rr��sz?OriginTrackingTest.test_origin_tracking_warning.<locals>.corofncs��Srr
r
)r�r
r�a1�sz;OriginTrackingTest.test_origin_tracking_warning.<locals>.a1r cs��Srr
r
)r�r
r�a2�sz;OriginTrackingTest.test_origin_tracking_warning.<locals>.a2csXt�|���t��}��t��Wd�n1s80Y��|t|j��dSr)	r>r�ZassertWarnsr{rr*rAr�Zwarning)Zdepth�msgr)r�r	r
rrl�s

&z>OriginTrackingTest.test_origin_tracking_warning.<locals>.checkrzcoroutine 'z' was never awaitedr!rpz' 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
)r�r>r�rr@r�)r	Za1_filenameZ	a1_linenoZa2_filenameZ	a2_linenorlr�r�r
)r�r�r�r	r�test_origin_tracking_warning�s4��

z/OriginTrackingTest.test_origin_tracking_warningc	Csdd�}tj}z�dd�t_t���z}t�dtf��L|�}t|�}~t��|�t|j	j
�|�|�|j	jt�Wd�n1s�0YWd�n1s�0Yt`t�dtf��|�t��Wd�n1s�0YW|t_n|t_0dS)Nc�sdSrr
r
r
r
rr��szLOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.corofncSsddSrr
rur
r
rrd�rHzNOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.<lambda>zcoroutine .* was never awaited)
r'�_warn_unawaited_coroutinerr�Zcheck_warningsr{r^r*rAr�r�r�r�)r	r�Zorig_wucrrr�r
r
r�)test_unawaited_warning_when_module_broken�s,

��L�(z<OriginTrackingTest.test_unawaited_warning_when_module_brokenN)rrrr�r�r�r�r
r
r
rr�ss.*r�c@seZdZdd�ZdS)�"UnawaitedWarningDuringShutdownTestcCs.d}td|�d}td|�d}td|�dS)Nz7import asyncio
async def f(): pass
asyncio.gather(f())
z-cz.import sys
async def f(): pass
sys.coro = f()
zYimport sys
async def f(): pass
sys.corocycle = [f()]
sys.corocycle.append(sys.corocycle)
r)r	r.r
r
r�&test_unawaited_warning_during_shutdown�s

zIUnawaitedWarningDuringShutdownTest.test_unawaited_warning_during_shutdownN)rrrr�r
r
r
rr��sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�CAPITestcs0ddlm��fdd�}|�|��d�d�dS)Nr��	awaitTypec�s�tdg��}|IdHSrnr���future��atr
rr=	sz%CAPITest.test_tp_await_1.<locals>.foor!)�	_testcapir�rArr[r
r�r�test_tp_await_1		szCAPITest.test_tp_await_1cCs2ddlm}|tdg��}|�t|���d�dS)Nrr�r!)r�r�rkrAr"r)r	r�r�r
r
r�test_tp_await_2	szCAPITest.test_tp_await_2cs\ddlm��fdd�}|�td��$|�|��d�d�Wd�n1sN0YdS)Nrr�c�s�d�}|IdHSrnr
r�r�r
rr=	sz%CAPITest.test_tp_await_3.<locals>.fooz.__await__.*returned non-iterator of type 'int'r!)r�r�rYrcrArr[r
r�r�test_tp_await_3	s�zCAPITest.test_tp_await_3N)rrrr�r�r�r
r
r
rr�	s	r��__main__)r�r�rCr�r>rPZunittestr'�testrZtest.support.script_helperrrrrr%�contextmanagerr+ZTestCaser,r:rFr�r�r�Zcpython_onlyr�rrNr
r
r
r�<module>sP
`*