HEX
Server: LiteSpeed
System: Linux server.nevid-deploma.com 4.18.0-553.111.1.lve.el8.x86_64 #1 SMP Fri Mar 13 13:42:17 UTC 2026 x86_64
User: smilepac (1037)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cppython/lib/python3.8/test/__pycache__/test_coroutines.cpython-38.opt-1.pyc
U

.D�g��@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
�3/opt/cppython/lib/python3.8/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
Csfg}d}z|�|�d��Wqtk
rZ}z |jr>|jdnd}WY�q^W5d}~XYqXq||fS�Nr)�append�send�
StopIteration�args)�coro�buffer�result�exr
r
r�	run_asyncsrc
Cs�|��}g}d}d}z4|dr.|�t|��n|�|�d��|d7}Wqtk
r�}z |jrj|jdnd}WY�q�W5d}~XYqXq||fS)Nr��)rr�nextrrr)r�awrr�irr
r
r�run_async__await__+sr%c	cs0t���t�d�dVt��W5QRXdS)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;Cs�ddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;g;}|D]>}|j|d<��(|�t��t|d=d>�W5QRXW5QRXq~dS)?Nz9def 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_1cCs^ddddddddd	g	}|D]>}|j|d
��(|�t��t|dd�W5QRXW5QRXqdS)
Nz1def 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_2c	Cs&|�t��tddd�W5QRXdS)Nz	async = 1r/r0)r2r3r4r
r
r
r�test_badsyntax_3�sz#AsyncBadSyntaxTest.test_badsyntax_3cCsVdddddg}|D]>}|j|d��(|�t��t|dd�W5QRXW5QRXqdS)	Nz�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	�bufr$�nsr
r
r�test_oneline_defs�s
z#TokenizerRegrTest.test_oneline_defsN)rrrrFr
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	rHr
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>.foorNcSsdSrr
r
r
r
r�bar	rIz&CoroutineTest.test_func_1.<locals>.bar)�assertIsInstance�types�
CoroutineTyperB�bool�__code__�co_flagsrCZCO_COROUTINErJZCO_GENERATOR�cr_coderArr%)r	r=�frOr
r
r�test_func_1�szCoroutineTest.test_func_1c	Cs.dd�}|�td��t|��W5QRXdS)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�dSrrYr
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_3c	s�dd�}|�}�fdd�}|��t|�W5QRX|��t|�W5QRX|��t|�W5QRX|��t|�W5QRX|��|D]}q�W5QRX|��dd�|D�W5QRX|��dS)Nc�st�dSrrYr
r
r
rr=sz&CoroutineTest.test_func_4.<locals>.foocs��td�S�Nz"'coroutine' object is not iterable�rZ�	TypeErrorr
r
r
r�<lambda>"s�z+CoroutineTest.test_func_4.<locals>.<lambda>cSsg|]}|�qSr
r
��.0r$r
r
r�
<listcomp>6sz-CoroutineTest.test_func_4.<locals>.<listcomp>)�list�tuple�sum�iterr`)r	r=r�checkr$r
r
r�test_func_4s"zCoroutineTest.test_func_4c	s�tjdd����fdd�}�fdd�}|�}|��|D]}q8W5QRX|����D]}��|d�qV��dd	���D�dg���t���d
���tt����d�dS)Ncss
dVdS�Nr!r
r
r
r
rrO;sz&CoroutineTest.test_func_5.<locals>.barc�s��IdHdSrr
r
�rOr
rr=?sz&CoroutineTest.test_func_5.<locals>.foocs��td�Srbrcr
r
r
rreBs�z+CoroutineTest.test_func_5.<locals>.<lambda>r!cSsg|]}|�qSr
r
)rg�elr
r
rrhNsz-CoroutineTest.test_func_5.<locals>.<listcomp>)r!)rQ�	coroutiner`rArjr"rl)r	r=rmrrqr
)rOr	r�test_func_5:s

zCoroutineTest.test_func_5c	shtjdd����fdd�}|�}|�|�d�d�|�|�d�d�|�t��|�d�W5QRXdS)NcssdVdVdS�Nr!r r
r
r
r
rrOSsz&CoroutineTest.test_func_6.<locals>.barc�s��IdHdSrr
r
rpr
rr=Xsz&CoroutineTest.test_func_6.<locals>.foor!r )rQrrrArr2r)r	r=rWr
rpr�test_func_6Rs
zCoroutineTest.test_func_6c	sHdd�}|���fdd�}|�td��t|��W5QRX���dS)Nc�sdSrMr
r
r
r
rrObsz&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)rZrdrir`�r	rOr=r
rvr�test_func_7as�zCoroutineTest.test_func_7csBtj�fdd��}dd�}|��|�t|��gdf����dS)Nc3s
�EdHSrr
r
rvr
rrOrsz&CoroutineTest.test_func_8.<locals>.barc�sdS�N�spamr
r
r
r
rr=vsz&CoroutineTest.test_func_8.<locals>.foorz)rQrrrArr`rwr
rvr�test_func_8qszCoroutineTest.test_func_8c
Cstdd�}|�td��|�t��W5QRX|�td��0|�t��|�D]}qNW5QRXt��W5QRXdS)Nc�sdSrr
r
r
r
rr=~sz&CoroutineTest.test_func_9.<locals>.fooz0coroutine '.*test_func_9.*foo' was never awaited)ZassertWarnsRegex�RuntimeWarningrr*r2rd)r	r=�_r
r
r�test_func_9}s��
zCoroutineTest.test_func_9c	s�d�tj�fdd����fdd�}|�}|��}|�|t|��t|�|�|�d�d�|��d�|��|��d�|�}|��}t|�|�	t
��|�t
dd�W5QRX|��d	�dS)
Nrc3sHz8zdV}|dVWntk
r4�d7��YnXW5�d7�XdS)Nr!r �d��ZeroDivisionError��a)�Nr
rrH�sz'CoroutineTest.test_func_10.<locals>.genc�s��IdHdSrr
r
�rHr
rr=�sz'CoroutineTest.test_func_10.<locals>.foorNrr!�f)rQrrr�assertIsrlr"rArr`r2r��throw)r	r=rr#r
)r�rHr�test_func_10�s$zCoroutineTest.test_func_10cCsRdd�}|�}|�dt|��|�dt|����|�dt|����|��dS)Nc�sdSrr
r
r
r
r�func�rIz(CoroutineTest.test_func_11.<locals>.funcr�__iter__Zcoroutine_wrapper)�assertIn�dirrr_r`)r	r�rr
r
r�test_func_11�szCoroutineTest.test_func_11c	s8�fdd�}|��|�td����d�W5QRXdS)Nc�s��d�}tIdHdSr)rr=r;��mer
r�g�s
z%CoroutineTest.test_func_12.<locals>.gzcoroutine already executing)rZ�
ValueErrorr)r	r�r
r�r�test_func_12�s�zCoroutineTest.test_func_12c	Cs<dd�}|�}|�td��|�d�W5QRX|��dS)Nc�sdSrr
r
r
r
rr��sz%CoroutineTest.test_func_13.<locals>.gz5can't send non-None value to a just-started coroutinerz)rZrdrr`)r	r�rr
r
r�test_func_13�s�zCoroutineTest.test_func_13c	sNtjdd����fdd�}|�}|�d�|�td��|��W5QRXdS)Ncss
dVdSrr
r
r
r
rrH�sz'CoroutineTest.test_func_14.<locals>.genc�s6z��IdHWn tk
r0��IdHYnXdSr��
GeneratorExitr
r�r
rr�sz(CoroutineTest.test_func_14.<locals>.corozcoroutine ignored GeneratorExit)rQrrrrZr[r`)r	r�cr
r�r�test_func_14�s

�zCoroutineTest.test_func_14c	Csfdd�}dd�}|�}|�td��||��d�W5QRX|�td��||��d�W5QRXdS)Nc�sdSryr
r
r
r
r�spammer�sz+CoroutineTest.test_func_15.<locals>.spammerc�s
|IdHSrr
rvr
r
r�reader�sz*CoroutineTest.test_func_15.<locals>.readerrz�&cannot reuse already awaited coroutine)rZrrr[)r	r�r�Zspammer_coror
r
r�test_func_15�s�zCoroutineTest.test_func_15c	s�tjdd����fdd�}�fdd�}|�}||�}|�d�|�d�|�td��|�td��W5QRX||�}|�d�|�td��|�d�W5QRX|�td��|�td	��W5QRXdS)
Ncss
dVdSrr
r
r
r
r�nop�sz'CoroutineTest.test_func_16.<locals>.nopc�s��IdHdSryr
r
�r�r
rr�sz(CoroutineTest.test_func_16.<locals>.sendc�s��IdH|IdHSrr
rvr�r
r�read�sz(CoroutineTest.test_func_16.<locals>.read�hamr��wat)rQrrrrZ�	Exceptionr�r[)r	rr�r�r�r
r�r�test_func_16�s(



��zCoroutineTest.test_func_16c	Cs�dd�}|�}|�td��|�d�W5QRX|�td��|�d�W5QRX|�td��|�td��W5QRX|��|��dS)Nc�sdSryr
r
r
r
rrrsz-CoroutineTest.test_func_17.<locals>.coroutinerzr�r�)rZrrr[r�r�r`)r	rrrr
r
r�test_func_17s��zCoroutineTest.test_func_17c	Cs�dd�}|�}|��}t|�}|�td��|�d�W5QRX|�td��|�d�W5QRX|�td��t|�W5QRX|�td��|�td��W5QRX|�td��|�td��W5QRX|�	�|�	�dS)Nc�sdSryr
r
r
r
rrr.sz-CoroutineTest.test_func_18.<locals>.coroutinerzr�r�)
rrlrZrrr[r"r�r�r`)r	rrrZ
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)Nrc3s2dVz
dVWntk
r,�d7�YnXdSror�r
)�CHKr
rr=Vs

z'CoroutineTest.test_func_19.<locals>.fooc�s��IdHdSrr
r
)r=r
rrr_sz-CoroutineTest.test_func_19.<locals>.coroutiner!�)rQrrrrAr`r>)r	rrrr}r
)r�r=r�test_func_19Ss

zCoroutineTest.test_func_19cCs&dd�}t|��}|�|gdf�dS)Nc�sdS)N�rNr
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�SrMrYr
r
r
rr=ysz?CoroutineTest.test_coro_wrapper_send_stop_iterator.<locals>.foor!rN)r%rPrrArr�r
r
r�$test_coro_wrapper_send_stop_iteratorxs
z2CoroutineTest.test_coro_wrapper_send_stop_iteratorc	s�tj��fdd����fdd�����fdd�}|����t���tj����j���d���t���tj	����jjj
jd���t
����d�W5QRX��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�)rQrrrArCr�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 coroutinerrrrc�sdSrr
r
r
r
rrW�rIz(CoroutineTest.test_corotype_1.<locals>.fzcoroutine object)rQrRr�r�__doc__r`r��__dict__rArr_)r	�ctrWr�r
r
r�test_corotype_1�szCoroutineTest.test_corotype_1c	Cs.dd�}|�td��t|��W5QRXdS)Nc�sdIdHdSror
r
r
r
rr=�sz'CoroutineTest.test_await_1.<locals>.foozobject int can.t.*await�rZrdrr\r
r
r�test_await_1�szCoroutineTest.test_await_1c	Cs.dd�}|�td��t|��W5QRXdS)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_2cCsDdd�}|�t|��dddgdf�|�t|��dddgdf�dS)Nc�stdddg�IdHdS)Nr!r r�)rr
r
r
rr=�sz'CoroutineTest.test_await_3.<locals>.foor!r r�)rArr%r\r
r
r�test_await_3�szCoroutineTest.test_await_3cs.dd���fdd�}|�t|��gdf�dS)Nc�sdS�N�*r
r
r
r
rrO�sz'CoroutineTest.test_await_4.<locals>.barc�s��IdHSrr
r
rpr
rr=�sz'CoroutineTest.test_await_4.<locals>.foor��rArr\r
rpr�test_await_4�szCoroutineTest.test_await_4c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)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�rlr
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�rr
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�rr�r\r
r�r�test_await_7�szCoroutineTest.test_await_7c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)Nc@seZdZdS)z-CoroutineTest.test_await_8.<locals>.AwaitableN�rrrr
r
r
rr��sr�c�s��IdHSrr
r
r�r
rr=�rIz'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
rpr
r�wrap�sz(CoroutineTest.test_await_9.<locals>.wrapc�sdSr�r
r
r
r
rrO�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
rre�rIz9CoroutineTest.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��rOr�r
rr=�s,��z'CoroutineTest.test_await_9.<locals>.fooc�s��IdHSrr
r
rpr
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
rrOsz(CoroutineTest.test_await_10.<locals>.barc�s��IdHIdHSrr
r
rpr
rr=sz(CoroutineTest.test_await_10.<locals>.foor�r�r\r
)rOr�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�sdSryr
r
r
r
rrOsz(CoroutineTest.test_await_11.<locals>.barc�s���IdHd�S)Nr�r
r
�rOr�r
rr=sz(CoroutineTest.test_await_11.<locals>.fooc�s��IdHdfS)Nr�r
r
rpr
rr�"sz)CoroutineTest.test_await_11.<locals>.foo2)rzr�r�r�r
r�r�
test_await_11s
zCoroutineTest.test_await_11c	sZdd�}|��G�fdd�d���fdd�}|�td��t|��W5QRX���dS)Nc�sdSryr
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)rZrdrr`)r	rr=r
)r�r�r�
test_await_12's�zCoroutineTest.test_await_12c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)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_13c	s�Gdd�d��Gdd�d��Gdd�dt����fdd����fd	d
�}|�}|�d�|�td��|�d�W5QRX|�}|�d�|����|�t�W5QRXdS)Nc@seZdZdd�Zdd�ZdS)z,CoroutineTest.test_await_14.<locals>.WrappercSs
||_dSrrv)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��IdHWStk
r&��YnXdSrr�r
)r�r�r
r�coro1Vsz*CoroutineTest.test_await_14.<locals>.coro1c�s����IdHSrr
r
)r�r�r
r�coro2[sz*CoroutineTest.test_await_14.<locals>.coro2rz)r�rrZrr2r�r�)r	r�r�r
)r�r�r�r�r�
test_await_14Fs

zCoroutineTest.test_await_14c	s\tjdd����fdd�}dd�}|�}|�d�|�td��||��d�W5QRXdS)Ncss
dVdSrr
r
r
r
rr�isz(CoroutineTest.test_await_15.<locals>.nopc�s��IdHdSrr
r
r�r
rrrmsz.CoroutineTest.test_await_15.<locals>.coroutinec�s|IdHdSrr
rvr
r
r�waiterpsz+CoroutineTest.test_await_15.<locals>.waiterz"coroutine is being awaited already)rQrrrrZr[)r	rrr�rr
r�r�
test_await_15hs

�zCoroutineTest.test_await_15cs2dd���fdd�}t|��\}}|�|j�dS)Nc�st�Sr)r�r
r
r
rrW}sz&CoroutineTest.test_await_16.<locals>.fc�s&zt�Wn��IdHYSXdSr)�KeyErrorr
�rWr
rr��sz&CoroutineTest.test_await_16.<locals>.g)rr��__context__)r	r�r}rr
r�r�
test_await_16zszCoroutineTest.test_await_16cszGdd�d���fdd�}|�}t|�\}}|�|ddddd	d
ddd
g	��fdd�}|�t��t|��W5QRXdS)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�sj�d�4IdH�J}�d�4IdH�(}td|j|jfg�IdHddW5QIdHRXW5QIdHRXdS)N�Ar��managersr!rr�)r�r��r�r
rr=�s$z&CoroutineTest.test_with_1.<locals>.fooz	enter-1-Az	enter-2-Az	enter-1-Bz	enter-2-B)r�r�r�zexit-1-Bzexit-2-Bzexit-1-Azexit-2-Ac�sj�d�4IdH�J}�d�4IdH�(}td|j|jfg�IdHddW5QIdHRXW5QIdHRXdS)Nr��Cr�r!rr�)r�r�r�r
rr=�s$)rrAr2r�)r	r=rWrr}r
r�r�test_with_1�s"��zCoroutineTest.test_with_1c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)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
�s$��4IdH�W5QIdHRXdSrr
r
�r�r
rr=�sz&CoroutineTest.test_with_2.<locals>.foor��rZ�AttributeErrorrr\r
r�r�test_with_2�szCoroutineTest.test_with_2c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)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
�s$��4IdH�W5QIdHRXdSrr
r
r�r
rr=�sz&CoroutineTest.test_with_3.<locals>.foor�r�r\r
r�r�test_with_3�szCoroutineTest.test_with_3c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_4.<locals>.CMcSsdSrr
r
r
r
r�	__enter__�sz/CoroutineTest.test_with_4.<locals>.CM.__enter__cSsdSrr
r
r
r
r�__exit__�sz.CoroutineTest.test_with_4.<locals>.CM.__exit__N)rrrr�r�r
r
r
rr��sr�c
�s$��4IdH�W5QIdHRXdSrr
r
r�r
rr=�sz&CoroutineTest.test_with_4.<locals>.foor�r�r\r
r�r�test_with_4�szCoroutineTest.test_with_4c	s>Gdd�d���fdd�}|�t��t|��W5QRXdS)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�W5QIdHRXdSrr
r
r�r
rr��sz'CoroutineTest.test_with_5.<locals>.func)r2�AssertionErrorr)r	r�r
r�r�test_with_5�szCoroutineTest.test_with_5c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)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__Nrr
r
r
rr��sr�c
�s$��4IdH�W5QIdHRXdSrr
r
r�r
rr=�sz&CoroutineTest.test_with_6.<locals>.foozV'async with' received an object from __aenter__ that does not implement __await__: intr�r\r
r�r�test_with_6�s�zCoroutineTest.test_with_6c
s�Gdd�d���fdd�}zt|��WnVtk
r~}z8|�|jdd�|�|jdk	�|�t|jt��W5d}~XYnX|�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__Nrr
r
r
rr��sr�c
�s,��4IdH�ddW5QIdHRXdS�Nr!rr
r
r�r
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)	rrdr^rrBr��
isinstancer��fail�r	r=rr
r�r�test_with_7�s�$zCoroutineTest.test_with_7c	sd�Gdd�d����fdd�}|�td��t|��W5QRX|��d���fdd�}|�td��t|��W5QRX|��d	���fd
d�}|�td��t|��W5QRX|��d���fdd�}|�td��t|��W5QRX|��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__Nrr
r
r
rr�sr�c
�s,��4IdH��d7�W5QIdHRXdSror
r
�r��CNTr
rr=#sz&CoroutineTest.test_with_8.<locals>.foor
r!c�sNtd�D]@}��4IdH�"�d7�W5QIdHR�qJW5QIdHRXqdS�Nr r!�r>r;rr
rr=/sr c�sLtd�D]>}��4IdH� �d7�W5QIdHR�qW5QIdHRXqdSrrr;rr
rr==sr�c
�s<��4IdH��d7�W5QIdHR�dSQIdHRXdSror
r
rr
rr=Ks�)rZrdrrAr\r
rr�test_with_8s<����zCoroutineTest.test_with_8c	sPd�Gdd�d����fdd�}|�t��t|��W5QRX|��d�dS)Nrc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_9.<locals>.CMc�s|Srr
r
r
r
rr�\sz0CoroutineTest.test_with_9.<locals>.CM.__aenter__c�sdddSr	r
rr
r
rr�_sz/CoroutineTest.test_with_9.<locals>.CM.__aexit__Nrr
r
r
rr�[sr�c
�s,��4IdH��d7�W5QIdHRXdSror
r
rr
rr=bsz&CoroutineTest.test_with_9.<locals>.foor!�r2r�rrAr\r
rr�test_with_9XszCoroutineTest.test_with_9c
s�d�Gdd�d����fdd�}zt|��WnXtk
r�}z:|�|jdk	�|�t|jt��|�t|jjt��W5d}~XYnX|�d�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_10.<locals>.CMc�s|Srr
r
r
r
rr�psz1CoroutineTest.test_with_10.<locals>.CM.__aenter__c�sdddSr	r
rr
r
rr�ssz0CoroutineTest.test_with_10.<locals>.CM.__aexit__Nrr
r
r
rr�osr�c�sH��4IdH�*��4IdH�
t�W5QIdHRXW5QIdHRXdSr�r[r
rr
rr=vsz'CoroutineTest.test_with_10.<locals>.fooz*exception from __aexit__ did not propagate)rr�rBr�rr[rr
r
rr�test_with_10ls�zCoroutineTest.test_with_10c
spd�Gdd�d����fdd�}zt|��Wn2tk
r`}z|�|jdk�W5d}~XYnX|�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dddSr	r
rr
r
rr��sz0CoroutineTest.test_with_11.<locals>.CM.__aexit__Nrr
r
r
rr��sr�c
�s(��4IdH�
t�W5QIdHRXdSrrr
rr
rr=�sz'CoroutineTest.test_with_11.<locals>.fooz+exception from __aenter__ did not propagate)rrrBr�rr
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__Nrr
r
r
rr��sr�c
�s6��4IdH�}��|j��t�W5QIdHRXdSr)r��	__class__r[��cm�r�rr	r
rr=�sz'CoroutineTest.test_with_12.<locals>.foo)rr\r
rr�test_with_12�szCoroutineTest.test_with_12c	sPd�Gdd�d����fdd�}|�t��t|��W5QRX|��d�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_13.<locals>.CMc�sdddSr	r
r
r
r
rr��sz1CoroutineTest.test_with_13.<locals>.CM.__aenter__c�sdSrr
rr
r
rr��sz0CoroutineTest.test_with_13.<locals>.CM.__aexit__Nrr
r
r
rr��sr�c
�s<�d7���4IdH��d7�W5QIdHRX�d7�dS)Nr!r��'r
r
rr
rr=�sz'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�|Sror
r
��aiter_callsr
r�	__aiter__�sz5CoroutineTest.test_for_1.<locals>.AsyncIter.__aiter__c�sF|jd7_|jds,t|jd�IdH|jdkr:t�|j|jfS)Nr!rNr)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�rr
rfr
r
rrh�sz,CoroutineTest.test_for_1.<locals>.<listcomp>�cSsg|]}|d�qS)r r
rfr
r
rrh�s�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
rfr
r
rrh�s�r3c�sJ��2z(3dHW}|ddkr q��|d�q6��d���d�dSr0r*r;r+r
r�test3�s
z'CoroutineTest.test_for_1.<locals>.test3r�cSsg|]}|d�qSr-r
rfr
r
rrhscSsg|]}|�qSr
r
rfr
r
rrhsr2)rrAr>)r	r,Zyieldedr}r4r7r
)r)r$rr�
test_for_1�s,
"
�zCoroutineTest.test_for_1c	sRd�t���}�fdd�}|�td��t|��W5QRX|�t���|�dS)N�r!r r�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�getrefcountrZrdrrA)r	�refs_beforer=r
r=r�
test_for_2s
�zCoroutineTest.test_for_2c	sbGdd�d�}|��t���}�fdd�}|�td��t|��W5QRX|�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�IsrEc�s �2z3dHW}td�q6dSr:r;r;�Zaiterr
rr="sz%CoroutineTest.test_for_3.<locals>.fooz!that does not implement __anext__r?�r	rErBr=r
rFr�
test_for_3s
�zCoroutineTest.test_for_3c	sbGdd�d�}|��t���}�fdd�}|�td��t|��W5QRX|�t���|�dS)Nc@seZdZdd�Zdd�ZdS)z#CoroutineTest.test_for_4.<locals>.IcSs|Srr
r
r
r
rr%0sz-CoroutineTest.test_for_4.<locals>.I.__aiter__cSsdS)Nr
r
r
r
r
rr'3sz-CoroutineTest.test_for_4.<locals>.I.__anext__N)rrrr%r'r
r
r
rrE/srEc�s �2z3dHW}td�q6dSr:r;r;rFr
rr=9sz%CoroutineTest.test_for_4.<locals>.fooz7async for' received an invalid object.*__anext__.*tupler?rGr
rFr�
test_for_4.s
�zCoroutineTest.test_for_4c	s�d�G�fdd�d��Gdd�d��������t���}t���}���fdd�}t���t�d�t|��W5QRX|��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
�rEr
rr�Isz4CoroutineTest.test_for_6.<locals>.Manager.__aenter__c�s�d7�dS)Ni��r
r�rJr
rr�Msz3CoroutineTest.test_for_6.<locals>.Manager.__aexit__Nrr
rJr
rr�Hsr�c@s$eZdZdd�Zdd�Zdd�ZdS)z*CoroutineTest.test_for_6.<locals>.IterablecSs
d|_dSrr;r
r
r
rrRsz3CoroutineTest.test_for_6.<locals>.Iterable.__init__cSs|Srr
r
r
r
rr%Usz4CoroutineTest.test_for_6.<locals>.Iterable.__aiter__c�s"|jdkrt�|jd7_|jS�NrNr!)r$r&r
r
r
rr'Xs
z4CoroutineTest.test_for_6.<locals>.Iterable.__anext__Nr(r
r
r
r�IterableQsrLc
�sF�4IdH�"�2z3dHW}�d7�q6W5QIdHRX�d7�dS�Nr!r�r
r;)rE�iterable�managerr
r�mainesz&CoroutineTest.test_for_6.<locals>.main�errori��c
�s���4IdH�$��2z3dHW}�d7�q6W5QIdHRX�d7���4IdH�$��2z3dHW}�d7�q\6W5QIdHRX�d7�dSrMr
r;�rErLr�r
rrPysi�c
�s���4IdH�4�d7���2z3dHW}�d7�q6�d7�W5QIdHRX�d7���4IdH�4�d7���2z3dHW}�d7�qt6�d7�W5QIdHRX�d7�dS)Nrr!i���r�r
r;rRr
rrP�si��9)r@rAr'r(r)rrA)r	Zmrefs_beforeZirefs_beforerPr
)rErLr�rNrOr�
test_for_6Es(	





zCoroutineTest.test_for_6c	sPd�Gdd�d����fdd�}|�t��t|��W5QRX|��d�dS)Nrc@seZdZdd�ZdS)z$CoroutineTest.test_for_7.<locals>.AIcSsdddSr	r
r
r
r
rr%�sz.CoroutineTest.test_for_7.<locals>.AI.__aiter__NrDr
r
r
r�AI�srTc�s*��2z3dHW}�d7�q6�d7�dS�Nr!rNr
r;�rTrr
rr=�sz%CoroutineTest.test_for_7.<locals>.foorr\r
rVr�
test_for_7�szCoroutineTest.test_for_7c
snd�Gdd�d����fdd�}|�t��.t���t�d�t|��W5QRXW5QRX|��d�dS)Nrc@seZdZdd�ZdS)z$CoroutineTest.test_for_8.<locals>.AIcSsdddSr	r
r
r
r
rr%�sz.CoroutineTest.test_for_8.<locals>.AI.__aiter__NrDr
r
r
rrT�srTc�s*��2z3dHW}�d7�q6�d7�dSrUr
r;rVr
rr=�sz%CoroutineTest.test_for_8.<locals>.foorQ)r2r�r'r(r)rrAr\r
rVr�
test_for_8�s

zCoroutineTest.test_for_8c	sVGdd�d���fdd�}|�td��}|��d�W5QRX|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dddSr	r
r
r
r
rr�sz.CoroutineTest.test_for_11.<locals>.F.__await__N)rrrr%r'rr
r
r
r�F�srYc�s��2z3dHW}q6dSrr
)r}�rYr
rrP�sz'CoroutineTest.test_for_11.<locals>.mainz an invalid object from __anext__)rZrdr�	exceptionrP�	__cause__r�)r	rPr��errr
rZr�test_for_11�s�zCoroutineTest.test_for_11c	shGdd�dt��Gdd�dt��g����fdd�}|����|��d�W5QRX|��dg�dS)Nc@seZdZdS)z*CoroutineTest.test_for_tuple.<locals>.DoneNr�r
r
r
r�Done�sr_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_||jdSro)r$�lenr&r
r
r
rr'�sz5CoroutineTest.test_for_tuple.<locals>.AIter.__anext__N�rrrr$r%r'r
r
r
r�AIter�srbc�s,�dg�2z3dHW}��|�q
6��dSr�r*r;�rbr_rr
rr=�sz)CoroutineTest.test_for_tuple.<locals>.foor�)r�rjr2rrAr\r
rcr�test_for_tuple�s
zCoroutineTest.test_for_tuplec	shGdd�dt��Gdd�dt��g����fdd�}|����|��d�W5QRX|��dg�dS)Nc@seZdZdS)z3CoroutineTest.test_for_stop_iteration.<locals>.DoneNr�r
r
r
rr_�sr_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_|jSro)r$r&rr
r
r
rr'�sz>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__anext__Nrar
r
r
rrb�srbc�s*�d�2z3dHW}��|�q6��dSr�r*r;rcr
rr=�sz2CoroutineTest.test_for_stop_iteration.<locals>.foor�)r�rr2rrAr\r
rcr�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
rrWsz$CoroutineTest.test_comp_1.<locals>.fc�s dd��d��d�fD�IdHS)Nc�sg|]}|IdH�qSrr
�rgr�r
r
rrhsz?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
rfr
r
r�	<setcomp>sz=CoroutineTest.test_comp_1.<locals>.run_set.<locals>.<setcomp>r!rgr
r
r�r
r�run_set
sz*CoroutineTest.test_comp_1.<locals>.run_setc�s dd��d��d�fD�IdHS)Nc�si|]}|IdHd�qS)Nr�r
rfr
r
r�
<dictcomp>sz@CoroutineTest.test_comp_1.<locals>.run_dict1.<locals>.<dictcomp>r!rgr
r
r�r
r�	run_dict1
sz,CoroutineTest.test_comp_1.<locals>.run_dict1c�s$dd�t�d��d�g�D�IdHS)Nc�si|]\}}||IdH�qSrr
)rgr$r�r
r
rrksz@CoroutineTest.test_comp_1.<locals>.run_dict2.<locals>.<dictcomp>r!rg)�	enumerater
r�r
r�	run_dict2sz,CoroutineTest.test_comp_1.<locals>.run_dict2r!rgr�)r!rg)rr!r�)r	rhrjrlrnr
r�r�test_comp_1szCoroutineTest.test_comp_1c	s�dd���fdd�}|�t|��gddddd	gf��fd
d�}|�t|��gdd
dhf��fdd�}|�t|��gdd
hf�dS)Nc�s|Srr
r;r
r
rrWsz$CoroutineTest.test_comp_2.<locals>.fc�s0dd��d��d��d��ddg�fD�IdHS)Nc�s g|]}|IdHD]}|�qqSrr
�rgr��sr
r
rrhs�z?CoroutineTest.test_comp_2.<locals>.run_list.<locals>.<listcomp>��abc�de�fgr
r
r�r
rrhsz+CoroutineTest.test_comp_2.<locals>.run_listr�r�r�rtruc�s,dd���ddg��dg�g�fD�IdHS)Nc�s0h|](}|IdHD]}|IdHD]}|�q qqSrr
)rgr�rq�dr
r
rri%s�z=CoroutineTest.test_comp_2.<locals>.run_set.<locals>.<setcomp>rN�r1r
r
r�r
rrj$s
��z*CoroutineTest.test_comp_2.<locals>.run_setrNr1rwc�s&dd���d��d�g�fD�IdHS)Nc�s&h|]}|IdHD]}|IdH�qqSrr
rpr
r
rri0s�z>CoroutineTest.test_comp_2.<locals>.run_set2.<locals>.<setcomp>rNr1r
r
r�r
r�run_set2/s�z+CoroutineTest.test_comp_2.<locals>.run_set2r�)r	rhrjrxr
r�r�test_comp_2s ��
�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
rrW9sz$CoroutineTest.test_comp_3.<locals>.fc�sdd��ddg�2�IdHS)Nc�sg|z3dHW}|d�q6Sror
rfr
r
rrh>sz?CoroutineTest.test_comp_3.<locals>.run_list.<locals>.<listcomp>rNr1r
r
r�r
rrh=sz+CoroutineTest.test_comp_3.<locals>.run_listr.r6c�sdd��ddg�2�IdHS)Nc�sh|z3dHW}|d�q6Sror
rfr
r
rriDsz=CoroutineTest.test_comp_3.<locals>.run_set.<locals>.<setcomp>rNr1r
r
r�r
rrjCsz*CoroutineTest.test_comp_3.<locals>.run_setc�sdd��ddg�2�IdHS)Nc�s$i|z3dHW}|d|d�q6Srtr
rfr
r
rrkJsz?CoroutineTest.test_comp_3.<locals>.run_dict.<locals>.<dictcomp>rNr1r
r
r�r
r�run_dictIsz+CoroutineTest.test_comp_3.<locals>.run_dict��)r.r6c�s*dd��ddg�2�}dd�|2�IdHS)NcSs |z3dHW}|dVq6dSror
rfr
r
r�	<genexpr>Psz=CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<genexpr>rNr1c�sg|z3dHW}|d�q6S�Nrr
�rgr�r
r
rrhQsz>CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<listcomp>r
r�r�r
r�run_genOsz*CoroutineTest.test_comp_3.<locals>.run_gen�o�yr��r	rhrjr{r�r
r�r�test_comp_38s*
�
��
�zCoroutineTest.test_comp_3cs�dd���fdd�}|�t|��gdgf��fdd�}|�t|��gdhf��fdd	�}|�t|��gdd
if��fdd�}|�t|��gd
gf�dS)NcSs|D]
}|VqdSrr
rzr
r
rrWWsz$CoroutineTest.test_comp_4.<locals>.fc�sdd��ddg�2�IdHS)Nc�s&g|z3dHW}|dkr|d�q6SrKr
rfr
r
rrh\sz?CoroutineTest.test_comp_4.<locals>.run_list.<locals>.<listcomp>rNr1r
r
r�r
rrh[sz+CoroutineTest.test_comp_4.<locals>.run_listr6c�sdd��ddg�2�IdHS)Nc�s&h|z3dHW}|dkr|d�q6SrKr
rfr
r
rribsz=CoroutineTest.test_comp_4.<locals>.run_set.<locals>.<setcomp>rNr1r
r
r�r
rrjasz*CoroutineTest.test_comp_4.<locals>.run_setc�sdd��ddg�2�IdHS)Nc�s,i|z"3dHW}|dkr|d|d�q6S)NrNr!r r
rfr
r
rrkhsz?CoroutineTest.test_comp_4.<locals>.run_dict.<locals>.<dictcomp>rNr1r
r
r�r
rr{gsz+CoroutineTest.test_comp_4.<locals>.run_dictr}c�s*dd��ddg�2�}dd�|2�IdHS)NcSs(|z3dHW}|dkr|dVq6dSrKr
rfr
r
rr~nsz=CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<genexpr>rNr1c�sg|z3dHW}|d�q6Srr
r�r
r
rrhosz>CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<listcomp>r
r�r�r
rr�msz*CoroutineTest.test_comp_4.<locals>.run_genr�r�r�r
r�r�test_comp_4Vs*��
��zCoroutineTest.test_comp_4cs�dd���fdd�}|�t|��gdddgf��fdd	�}|�t|��gdddhf��fd
d�}|�t|��gdd
dd�f��fdd�}|�t|��gdddgf�dS)NcSs|D]
}|VqdSrr
rzr
r
rrWusz&CoroutineTest.test_comp_4_2.<locals>.fc�sdd��td��2�IdHS)Nc�s6g|z,3dHW}d|kr$dkrnq|d�q6S�NrrrNr
rfr
r
rrhzs

zACoroutineTest.test_comp_4_2.<locals>.run_list.<locals>.<listcomp>�rr
r�r
rrhysz-CoroutineTest.test_comp_4_2.<locals>.run_listr.r|�
c�sdd��td��2�IdHS)Nc�s6h|z,3dHW}d|kr$dkrnq|d�q6Sr�r
rfr
r
rri�s

z?CoroutineTest.test_comp_4_2.<locals>.run_set.<locals>.<setcomp>r�rr
r�r
rrjsz,CoroutineTest.test_comp_4_2.<locals>.run_setc�sdd��td��2�IdHS)Nc�s<i|z23dHW}d|kr$dkrnq|d|d�q6S)NrrrNrr
rfr
r
rrk�s
zACoroutineTest.test_comp_4_2.<locals>.run_dict.<locals>.<dictcomp>r�rr
r�r
rr{�sz-CoroutineTest.test_comp_4_2.<locals>.run_dictr/r��g)r.r|r�c�s*dd��td��2�}dd�|2�IdHS)NcSs8|z.3dHW}d|kr"dkrnq|dVq6dSr�r
rfr
r
rr~�s

z?CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<genexpr>r�c�sg|z3dHW}|d�q6Srr
r�r
r
rrh�sz@CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<listcomp>rr�r�r
rr��sz,CoroutineTest.test_comp_4_2.<locals>.run_genr��p�qr�r�r
r�r�
test_comp_4_2ts*����zCoroutineTest.test_comp_4_2cs0dd���fdd�}|�t|��gdgf�dS)NcSs|D]
}|VqdSrr
rzr
r
rrW�sz$CoroutineTest.test_comp_5.<locals>.fc�s$�fdd�ddgddgfD�IdHS)Nc	�s@g|]8}|ddkr�|�2z3dHW}|dkr|d�q6qS)rrNNrwr!r
)rgZpairr$r�r
rrh�s�z?CoroutineTest.test_comp_5.<locals>.run_list.<locals>.<listcomp>rNr1rw�(r
r
r�r
rrh�sz+CoroutineTest.test_comp_5.<locals>.run_listrgr��r	rhr
r�r�test_comp_5�s�zCoroutineTest.test_comp_5cs4dd���fdd�}|�t|��gdddgf�dS)NcSs|D]
}|VqdSrr
rzr
r
rrW�sz$CoroutineTest.test_comp_6.<locals>.fc�sdd��ddg�2�IdHS)Nc�s(g|z3dHW}|D]}|d�qq6Sror
)rg�seqr$r
r
rrh�s�z?CoroutineTest.test_comp_6.<locals>.run_list.<locals>.<listcomp>)rNr1)rwr
r
r�r
rrh�sz+CoroutineTest.test_comp_6.<locals>.run_listr.r6�r�r�r
r�r�test_comp_6�s�zCoroutineTest.test_comp_6c	s:dd���fdd�}|�td��t|��W5QRXdS)NcSsdVdVtd��dS)Nr!r �aaa)r�r
r
r
rrW�sz$CoroutineTest.test_comp_7.<locals>.fc�sdd���2�IdHS)Nc�sg|z3dHW}|�q6Srr
rfr
r
rrh�sz?CoroutineTest.test_comp_7.<locals>.run_list.<locals>.<listcomp>r
r
r�r
rrh�sz+CoroutineTest.test_comp_7.<locals>.run_listr�)rZr�rr�r
r�r�test_comp_7�szCoroutineTest.test_comp_7cCs(dd�}|�t|��gdddgf�dS)Nc�sdd�dD�S)NcSsg|]}|�qSr
r
rfr
r
rrh�sz8CoroutineTest.test_comp_8.<locals>.f.<locals>.<listcomp>r9r
r
r
r
rrW�sz$CoroutineTest.test_comp_8.<locals>.fr!r r�r��r	rWr
r
r�test_comp_8�s
�zCoroutineTest.test_comp_8cs2dd���fdd�}|�t|��gddgf�dS)NcSsdVdVdSrtr
r
r
r
rrH�sz&CoroutineTest.test_comp_9.<locals>.genc�s$dd���2�IdH}dd�|D�S)Nc�sg|z3dHW}|�q6Srr
rfr
r
rrh�sz8CoroutineTest.test_comp_9.<locals>.f.<locals>.<listcomp>cSsg|]}|�qSr
r
rfr
r
rrh�sr
)�lr�r
rrW�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
rfr
r
rri�sz8CoroutineTest.test_comp_10.<locals>.f.<locals>.<setcomp>r9cSsi|]
}||�qSr
r
)rg�xr
r
rrk�sz9CoroutineTest.test_comp_10.<locals>.f.<locals>.<dictcomp>r
)Zxxr
r
rrW�sz%CoroutineTest.test_comp_10.<locals>.fr!r r�r9r�r�r
r
r�test_comp_10�s
�zCoroutineTest.test_comp_10c	Csjdd�}|�}|�t��t�|�W5QRX|��}z$|�t��t�|�W5QRXW5|��XdS)Nc�sdSrr
r
r
r
rr��rIz%CoroutineTest.test_copy.<locals>.func)r2rd�copyrr`)r	r�rr#r
r
r�	test_copy�szCoroutineTest.test_copyc
Cs�dd�}|�}ttjd�D],}|�ttjf��t�||�W5QRXq|��}z@ttjd�D],}|�ttjf��t�||�W5QRXqbW5|��XdS)Nc�sdSrr
r
r
r
rr��rIz'CoroutineTest.test_pickle.<locals>.funcr!)	r>�pickle�HIGHEST_PROTOCOLr2rd�
PicklingError�dumpsrr`)r	r�r�protor#r
r
r�test_pickle�szCoroutineTest.test_picklec
Cs�dd�}t���ft���R}t�d�|�}t|�}d}t��|�dt|j	j
��|�t|j	j�|�W5QRXW5QRXdS)Nc�sdSrr
r
r
r
rr��rIz3CoroutineTest.test_fatal_coro_warning.<locals>.funcrQzwas 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
dVdSrMr
r
r
r
r�sourceszJCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.sourcec	�sD��t�� }��2z3dHW�d<q6W5QRX��|jjd�dS)Nr�r�r3�r2r&rAr[rr�r	r��tgtr
r�run_fors
zKCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_forr3c
�sL��t��(}�fdd���2�IdHW5QR�SQRX��|jjd�dS)Nc�sg|z3dHW�d<d�q6Srr
�rg�r�r
rrhsz`CoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_list.<locals>.<listcomp>r�r3r�rr�r
rrhs,zLCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_listc	�sd�fdd���2�}|�d�}��t��}|IdHW5QRX��|jjt���|jjjd�dS)Ncs |z3dHW�d<dVq6dSrr
r�r�r
rr~sz^CoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_gen.<locals>.<genexpr>r�r3�	�asendr2r[rPr[r\r&rAr�rHr�rr�r
rr�s
zKCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_genr�)r	r�r�rhr�r
r�r�,test_for_assign_raising_stop_async_iteration�sz: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	�sD��t�� }��2z3dHW\}}q6W5QRX��|jjd�dS)Nr�r3r�)rr$�j�r�r	r
rr�'s
zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_forr3c
�sH��t��$}dd���2�IdHW5QR�SQRX��|jjd�dS)Nc�sg|z3dHW\}}d�q6Srr
�rgr$r�r
r
rrh1szbCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_list.<locals>.<listcomp>r�r3r�rr�r
rrh/s(zNCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_listc	�s`dd���2�}|�d�}��t��}|IdHW5QRX��|jjt���|jjjd�dS)NcSs |z3dHW\}}dVq6dSrr
r�r
r
rr~7sz`CoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_gen.<locals>.<genexpr>r�r3r�r�r�r
rr�6s
zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_genr�)r	r�rhr�r
)r�r�r	r�.test_for_assign_raising_stop_async_iteration_2 sz<CoroutineTest.test_for_assign_raising_stop_async_iteration_2N)RrrrrLrXr]rarnrsrurxr{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�r�rrrrrrrr r"r8rCrHrIrSrWrXr^rdreroryr�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rrG�s�	#
	(	


"(@H\ 
	
!rGc@seZdZdd�ZdS)�CoroAsyncIOCompatTestc	s�t�d��Gdd�dt��g�G��fdd�d������fdd�}���}��|�z*z|�|��Wn�k
r|YnXW5|����d�X|��dd	dg�dS)
N�asyncioc@seZdZdS)z9CoroAsyncIOCompatTest.test_asyncio_1.<locals>.MyExceptionNr�r
r
r
r�MyExceptionHsr�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�Ns

z;CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aenter__c�s ��d�IdH��|j�dS)Nr�)r�rr)r	�exc_type�exc_val�exc_tbr�r
rr�Tsz:CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aexit__Nrr
r�r
rr�Msr�c
�sB��4IdH�}��d�IdH��W5QIdHRX��d�dS)Nr�Zunreachable)r�rr��r�r�r�rr
rrWXsz/CoroAsyncIOCompatTest.test_asyncio_1.<locals>.fr!r )	r�
import_moduler�Znew_event_loopZset_event_loopr`Zset_event_loop_policyZrun_until_completerA)r	rWZloopr
r�r�test_asyncio_1Cs


z$CoroAsyncIOCompatTest.test_asyncio_1N)rrrr�r
r
r
rr�Asr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�OriginTrackingTestcCst�t��j�}|j|jfSr)rCZgetframeinfo�currentframe�f_back�filename�lineno)r	�infor
r
r�herelszOriginTrackingTest.herec	s�t��}�z�dd��t�d���t��d�t�����}��|j�W5QRXt�d���t��d����\}}t����� }��|j||ddff�W5QRXt�d���t��d���fdd�}���\}}|�\\}}}t�|��(��|j||d	f||ddff�W5QRXt�d
�t�����,}��	dt
|j�k�oZd
kn�W5QRX��t��t�d�W5QRX��t��d
�W5t�|�XdS)Nc�sdSrr
r
r
r
r�corofnssz7OriginTrackingTest.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�ps@

�
��
0z'OriginTrackingTest.test_origin_trackingc
s�dd�����\}}�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��W5t�|�XdS)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>.a2c	sDt�|���t��}��t��W5QRX��|t|j��dSr)	r@r�ZassertWarnsr|rr*rAr��warning)�depth�msgr)r�r	r
rrm�s

z>OriginTrackingTest.test_origin_tracking_warning.<locals>.checkrzcoroutine 'z' was never awaitedr!rrz' 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�r�rr@)r	Za1_filenameZ	a1_linenoZa2_filenameZ	a2_linenormr�r�r
)r�r�r�r	r�test_origin_tracking_warning�s4��
z/OriginTrackingTest.test_origin_tracking_warningc
Cs�dd�}tj}z�dd�t_t���\}t�dtf��B|�}t|�}~t��|�t|j	j
�|�|�|j	jt�W5QRXW5QRXt`t�dtf��|�t��W5QRXW5|t_XdS)Nc�sdSrr
r
r
r
rr��szLOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.corofncSsddSr	r
rvr
r
rre�rIzNOriginTrackingTest.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,

��$�z<OriginTrackingTest.test_unawaited_warning_when_module_brokenN)rrrr�r�r�r�r
r
r
rr�ks.*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��}|IdHSror���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�rlrAr"r)r	r�r�r
r
r�test_tp_await_2
	szCAPITest.test_tp_await_2c	sHddlm��fdd�}|�td��|�|��d�d�W5QRXdS)Nrr�c�s�d�}|IdHSror
r�r�r
rr=	sz%CAPITest.test_tp_await_3.<locals>.fooz.__await__.*returned non-iterator of type 'int'r!)r�r�rZrdrArr\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@rQZunittestr'�testrZtest.support.script_helperrrrrr%�contextmanagerr+ZTestCaser,r:rGr�r�r�Zcpython_onlyr�rrPr
r
r
r�<module>sP
X*