HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_coroutines.cpython-37.opt-1.pyc
B

��g��@sFddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZGdd�d�Z
Gdd�d�Zdd	�Zd
d�Zejdd
��ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Ze
jGdd�dej��Zedk�rBe��dS)�N)�support)�assert_python_okc@seZdZdd�Zdd�ZdS)�AsyncYieldFromcCs
||_dS)N)�obj)�selfr�r�0/usr/local/lib/python3.7/test/test_coroutines.py�__init__szAsyncYieldFrom.__init__ccs|jEdHdS)N)r)rrrr�	__await__szAsyncYieldFrom.__await__N)�__name__�
__module__�__qualname__r	r
rrrrrsrc@seZdZdd�Zdd�ZdS)�
AsyncYieldcCs
||_dS)N)�value)rrrrrr	szAsyncYield.__init__ccs|jVdS)N)r)rrrrr
szAsyncYield.__await__N)rrr
r	r
rrrrrsrc
Csdg}d}xRy|�|�d��Wq
tk
rV}z|jr@|jdnd}PWdd}~XYq
Xq
W||fS)Nr)�append�send�
StopIteration�args)�coro�buffer�result�exrrr�	run_asyncsrc
Cs�|��}g}d}d}xry4|dr0|�t|��n|�|�d��|d7}Wqtk
r�}z|jrl|jdnd}PWdd}~XYqXqW||fS)Nr��)r
r�nextrrr)r�awrr�irrrr�run_async__await__,src	cs0t���t�d�dVt��WdQRXdS)N�ignore)�warnings�catch_warnings�simplefilterr�
gc_collectrrrr�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;}xF|D]>}|j|d<��(|�t��t|d=d>�WdQRXWdQRXq�WdS)?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
            )�codez<test>�exec)�subTest�assertRaises�SyntaxError�compile)r�samplesr&rrr�test_badsyntax_1Is|		
z#AsyncBadSyntaxTest.test_badsyntax_1cCsbddddddddd	g	}xF|D]>}|j|d
��(|�t��t|dd�WdQRXWdQRXqWdS)
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&z<test>r')r(r)r*r+)rr,r&rrr�test_badsyntax_2�s
z#AsyncBadSyntaxTest.test_badsyntax_2c	Cs&|�t��tddd�WdQRXdS)Nz	async = 1z<test>r')r)r*r+)rrrr�test_badsyntax_3�sz#AsyncBadSyntaxTest.test_badsyntax_3cCsZdddddg}xF|D]>}|j|d��(|�t��t|dd�WdQRXWdQRXqWdS)	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&z<test>r')r(r)r*r+)rr,r&rrr�test_badsyntax_4�s	

z#AsyncBadSyntaxTest.test_badsyntax_4N)rrr
r-r.r/r0rrrrr%Gs;'r%c@seZdZdd�ZdS)�TokenizerRegrTestcCs�g}x"td�D]}|�dj|d��qWd�|�}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�joinr'�assertEqual�
assertTrue�inspectZiscoroutinefunction)r�bufr�nsrrr�test_oneline_defs�s
z#TokenizerRegrTest.test_oneline_defsN)rrr
r<rrrrr1�sr1c@steZdZdd�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�S)��
CoroutineTestcCsdd�}|�t|d��dS)Ncss
dVdS)Nrrrrr�gen��z%CoroutineTest.test_gen_1.<locals>.genr
)�assertFalse�hasattr)rr>rrr�
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�
rrrrrr3�sz&CoroutineTest.test_func_1.<locals>.foorCcSsdS)Nrrrrr�bar
r?z&CoroutineTest.test_func_1.<locals>.bar)�assertIsInstance�types�
CoroutineTyper8�bool�__code__�co_flagsr9ZCO_COROUTINEr@ZCO_GENERATOR�cr_coder7rr)rr3�frDrrr�test_func_1�szCoroutineTest.test_func_1c	Cs.dd�}|�td��t|��WdQRXdS)Nc�st�dS)N)rrrrrr3sz&CoroutineTest.test_func_2.<locals>.foozcoroutine raised StopIteration)�assertRaisesRegex�RuntimeErrorr)rr3rrr�test_func_2
s
zCoroutineTest.test_func_2cCs*dd�}|�}|�t|�d�|��dS)Nc�st�dS)N)rrrrrr3sz&CoroutineTest.test_func_3.<locals>.fooz^<coroutine object.* at 0x.*>$)�assertRegex�repr�close)rr3rrrr�test_func_3szCoroutineTest.test_func_3c	s�dd�}|�}�fdd�}|��t|�WdQRX|��t|�WdQRX|��t|�WdQRX|��t|�WdQRX|��x|D]}q�WWdQRX|��dd�|D�WdQRX|��dS)Nc�st�dS)N)rrrrrr3sz&CoroutineTest.test_func_4.<locals>.foocs��td�S)Nz"'coroutine' object is not iterable)rN�	TypeErrorr)rrr�<lambda>#sz+CoroutineTest.test_func_4.<locals>.<lambda>cSsg|]}|�qSrr)�.0rrrr�
<listcomp>7sz-CoroutineTest.test_func_4.<locals>.<listcomp>)�list�tuple�sum�iterrS)rr3r�checkrr)rr�test_func_4s"
zCoroutineTest.test_func_4c	s�tjdd����fdd�}�fdd�}|�}|��x|D]}q:WWdQRX|��x��D]}��|d�q\W��dd	���D�dg���t���d
���tt����d�dS)Ncss
dVdS)NrrrrrrrD<sz&CoroutineTest.test_func_5.<locals>.barc�s��IdHdS)Nrr)rDrrr3@sz&CoroutineTest.test_func_5.<locals>.foocs��td�S)Nz"'coroutine' object is not iterable)rNrUr)rrrrVCsz+CoroutineTest.test_func_5.<locals>.<lambda>rcSsg|]}|�qSrr)rW�elrrrrXOsz-CoroutineTest.test_func_5.<locals>.<listcomp>)r)rF�	coroutinerSr7rZrr\)rr3r]rr_r)rDrr�test_func_5;s
zCoroutineTest.test_func_5c	shtjdd����fdd�}|�}|�|�d�d�|�|�d�d�|�t��|�d�WdQRXdS)NcssdVdVdS)NrrrrrrrrDTsz&CoroutineTest.test_func_6.<locals>.barc�s��IdHdS)Nrr)rDrrr3Ysz&CoroutineTest.test_func_6.<locals>.foorr)rFr`r7rr)r)rr3rLr)rDr�test_func_6SszCoroutineTest.test_func_6c	sHdd�}|���fdd�}|�td��t|��WdQRX���dS)Nc�sdS)NrCrrrrrrDcsz&CoroutineTest.test_func_7.<locals>.barc3s�EdHdS)Nrr)rrrr3gsz&CoroutineTest.test_func_7.<locals>.foozCcannot 'yield from' a coroutine object in a non-coroutine generator)rNrUrYrS)rrDr3r)rr�test_func_7bszCoroutineTest.test_func_7csBtj�fdd��}dd�}|��|�t|��gdf����dS)Nc3s
�EdHS)Nrr)rrrrDssz&CoroutineTest.test_func_8.<locals>.barc�sdS)N�spamrrrrrr3wsz&CoroutineTest.test_func_8.<locals>.foord)rFr`r7rrS)rrDr3r)rr�test_func_8rs
zCoroutineTest.test_func_8c
Csxdd�}|�td��|�t��WdQRX|�td��4|�t��x|�D]}qPWWdQRXt��WdQRXdS)Nc�sdS)Nrrrrrr3sz&CoroutineTest.test_func_9.<locals>.fooz0coroutine '.*test_func_9.*foo' was never awaited)ZassertWarnsRegex�RuntimeWarningrr#r)rU)rr3�_rrr�test_func_9~szCoroutineTest.test_func_9c	s�d�tj�fdd����fdd�}|�}|��}|�|t|��t|�|�|�d�d�|��d�|��|��d�|�}|��}t|�|�	t
��|�t
dd�WdQRX|��d	�dS)
Nrc3sHz8ydV}|dVWntk
r4�d7��YnXWd�d7�XdS)Nr�dr)�ZeroDivisionError)�a)�Nrrr>�sz'CoroutineTest.test_func_10.<locals>.genc�s��IdHdS)Nrr)r>rrr3�sz'CoroutineTest.test_func_10.<locals>.foorCrir�f)rFr`r
�assertIsr\rr7rrSr)rj�throw)rr3rrr)rlr>r�test_func_10�s"zCoroutineTest.test_func_10cCsRdd�}|�}|�dt|��|�dt|����|�dt|����|��dS)Nc�sdS)Nrrrrr�func�r?z(CoroutineTest.test_func_11.<locals>.funcr
�__iter__Zcoroutine_wrapper)�assertIn�dirr
rRrS)rrqrrrr�test_func_11�szCoroutineTest.test_func_11c	s8�fdd�}|��|�td����d�WdQRXdS)Nc�s��d�}tIdHdS)N)rr3)r)�merr�g�s
z%CoroutineTest.test_func_12.<locals>.gzcoroutine already executing)rN�
ValueErrorr)rrwr)rvr�test_func_12�s
zCoroutineTest.test_func_12c	Cs<dd�}|�}|�td��|�d�WdQRX|��dS)Nc�sdS)Nrrrrrrw�sz%CoroutineTest.test_func_13.<locals>.gz5can't send non-None value to a just-started coroutinerd)rNrUrrS)rrwrrrr�test_func_13�szCoroutineTest.test_func_13c	sNtjdd����fdd�}|�}|�d�|�td��|��WdQRXdS)Ncss
dVdS)Nrrrrrr>�sz'CoroutineTest.test_func_14.<locals>.genc�s6y��IdHWn tk
r0��IdHYnXdS)N)�
GeneratorExitr)r>rrr�sz(CoroutineTest.test_func_14.<locals>.corozcoroutine ignored GeneratorExit)rFr`rrNrOrS)rr�cr)r>r�test_func_14�s
zCoroutineTest.test_func_14c	Csfdd�}dd�}|�}|�td��||��d�WdQRX|�td��||��d�WdQRXdS)Nc�sdS)Nrdrrrrr�spammer�sz+CoroutineTest.test_func_15.<locals>.spammerc�s
|IdHS)Nr)rrrr�reader�sz*CoroutineTest.test_func_15.<locals>.readerrdz&cannot reuse already awaited coroutine)rNrrrO)rr~rZspammer_cororrr�test_func_15�szCoroutineTest.test_func_15c	s�tjdd����fdd�}�fdd�}|�}||�}|�d�|�d�|�td��|�td��WdQRX||�}|�d�|�td��|�d�WdQRX|�td��|�td	��WdQRXdS)
Ncss
dVdS)Nrrrrr�nop�sz'CoroutineTest.test_func_16.<locals>.nopc�s��IdHdS)Nrdrr)r�rrr�sz(CoroutineTest.test_func_16.<locals>.sendc�s��IdH|IdHS)Nr)r)r�rr�read�sz(CoroutineTest.test_func_16.<locals>.read�hamz&cannot reuse already awaited coroutine�wat)rFr`rrN�	ExceptionrorO)rrr�r~rr)r�r�test_func_16�s"


zCoroutineTest.test_func_16c	Cs�dd�}|�}|�td��|�d�WdQRX|�td��|�d�WdQRX|�td��|�td��WdQRX|��|��dS)Nc�sdS)Nrdrrrrrr`sz-CoroutineTest.test_func_17.<locals>.coroutinerdz&cannot reuse already awaited coroutiner�)rNrrrOror�rS)rr`rrrr�test_func_17szCoroutineTest.test_func_17c	Cs�dd�}|�}|��}t|�}|�td��|�d�WdQRX|�td��|�d�WdQRX|�td��t|�WdQRX|�td��|�td��WdQRX|�td��|�td��WdQRX|�	�|�	�dS)Nc�sdS)Nrdrrrrrr`/sz-CoroutineTest.test_func_18.<locals>.coroutinerdz&cannot reuse already awaited coroutiner�)
r
r\rNrrrOrror�rS)rr`rZ
await_iter�itrrr�test_func_18,s(zCoroutineTest.test_func_18cs�d�tj�fdd����fdd�}|�}|�d�|�d�|��d�|��|��d�x$td�D]}|��|��d�qfWdS)Nrc3s2dVy
dVWntk
r,�d7�YnXdS)Nr)r{r)�CHKrrr3Ws

z'CoroutineTest.test_func_19.<locals>.fooc�s��IdHdS)Nrr)r3rrr``sz-CoroutineTest.test_func_19.<locals>.coroutiner�)rFr`rr7rSr4)rr`rrgr)r�r3r�test_func_19Ts	

zCoroutineTest.test_func_19cCs&dd�}t|��}|�|gdf�dS)Nc�sdS)N)rCrrrrrr3ssz7CoroutineTest.test_coro_wrapper_send_tuple.<locals>.foo)rC)rr7)rr3rrrr�test_coro_wrapper_send_tuplers
z*CoroutineTest.test_coro_wrapper_send_tuplecCs8dd�}t|��}|�|dt�|�|djd�dS)Nc�std�S)NrC)rrrrrr3zsz?CoroutineTest.test_coro_wrapper_send_stop_iterator.<locals>.foorrC)rrErr7r)rr3rrrr�$test_coro_wrapper_send_stop_iteratorys
z2CoroutineTest.test_coro_wrapper_send_stop_iteratorc	s�tj��fdd����fdd�����fdd�}|����t���tj����j���d���t���tj	����jjj
jd���t
����d�WdQRX��t���tj����j�dS)Nc3sJ��t���tj����j�dV��t���tj����j�dS)N)r7r9�getcoroutinestateZCORO_RUNNING�assertIsNone�cr_awaitr)�coro_brrrrk�s
z&CoroutineTest.test_cr_await.<locals>.ac�s��IdHdS)Nrr)rkrrr|�sz&CoroutineTest.test_cr_await.<locals>.cc�s(���j���IdH���j�dS)N)r�r�r)r|r�rrr�b�sz&CoroutineTest.test_cr_await.<locals>.brk)rFr`r7r9r�ZCORO_CREATEDr�r�rZCORO_SUSPENDED�gi_code�co_namer)rZCORO_CLOSED)rr�r)rkr|r�rr�
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 coroutinerr
r`c�sdS)NrrrrrrL�r?z(CoroutineTest.test_corotype_1.<locals>.fzcoroutine object)rFrGrsr�__doc__rSro�__dict__r7rrR)rZctrLr|rrr�test_corotype_1�szCoroutineTest.test_corotype_1c	Cs.dd�}|�td��t|��WdQRXdS)Nc�sdIdHdS)Nrrrrrrr3�sz'CoroutineTest.test_await_1.<locals>.foozobject int can.t.*await)rNrUr)rr3rrr�test_await_1�szCoroutineTest.test_await_1c	Cs.dd�}|�td��t|��WdQRXdS)Nc�sgIdHdS)Nrrrrrr3�sz'CoroutineTest.test_await_2.<locals>.foozobject list can.t.*await)rNrUr)rr3rrr�test_await_2�szCoroutineTest.test_await_2cCsDdd�}|�t|��dddgdf�|�t|��dddgdf�dS)Nc�stdddg�IdHdS)Nrrr�)rrrrrr3�sz'CoroutineTest.test_await_3.<locals>.foorrr�)r7rr)rr3rrr�test_await_3�szCoroutineTest.test_await_3cs.dd���fdd�}|�t|��gdf�dS)Nc�sdS)N�*rrrrrrD�sz'CoroutineTest.test_await_4.<locals>.barc�s��IdHS)Nrr)rDrrr3�sz'CoroutineTest.test_await_4.<locals>.foor�)r7r)rr3r)rDr�test_await_4�szCoroutineTest.test_await_4c	s@Gdd�d���fdd�}|�td��t|��WdQRXdS)Nc@seZdZdd�ZdS)z-CoroutineTest.test_await_5.<locals>.AwaitablecSsdS)Nr)rrrrr
�sz7CoroutineTest.test_await_5.<locals>.Awaitable.__await__N)rrr
r
rrrr�	Awaitable�sr�c�s��IdHS)Nrr)r�rrr3�sz'CoroutineTest.test_await_5.<locals>.fooz(__await__.*returned non-iterator of type)rNrUr)rr3r)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)r\)rrrrr
�sz7CoroutineTest.test_await_6.<locals>.Awaitable.__await__N)rrr
r
rrrrr��sr�c�s��IdHS)Nrr)r�rrr3�sz'CoroutineTest.test_await_6.<locals>.foor�)r7r)rr3r)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�rir)rrrrr
�sz7CoroutineTest.test_await_7.<locals>.Awaitable.__await__N)rrr
r
rrrrr��sr�c�s��IdHS)Nrr)r�rrr3�sz'CoroutineTest.test_await_7.<locals>.foor�ri)r7r)rr3r)r�r�test_await_7�szCoroutineTest.test_await_7c	s@Gdd�d���fdd�}|�td��t|��WdQRXdS)Nc@seZdZdS)z-CoroutineTest.test_await_8.<locals>.AwaitableN)rrr
rrrrr��sr�c�s��IdHS)Nrr)r�rrr3�r?z'CoroutineTest.test_await_8.<locals>.fooz4object Awaitable can't be used in 'await' expression)rNrUr)rr3r)r�r�test_await_8�s

zCoroutineTest.test_await_8cs^�fdd��dd����fdd�}�fdd�}|�t|��gd	f�|�t|��gd
f�dS)Ncs�S)Nrr)rDrr�wrap�sz(CoroutineTest.test_await_9.<locals>.wrapc�sdS)Nr�rrrrrrD�sz'CoroutineTest.test_await_9.<locals>.barc�spd�fdd�i}G�fdd�d�}��IdH���IdH|d���IdH��IdHd|���IdHS)Nr�cs�S)Nrr)r�rrrV�r?z9CoroutineTest.test_await_9.<locals>.foo.<locals>.<lambda>cseZdZ�ZdS)z3CoroutineTest.test_await_9.<locals>.foo.<locals>.DBN)rrr
r�r)r�rr�DBsr�i�)r�)Zdbr�)rDr�rrr3�sz'CoroutineTest.test_await_9.<locals>.fooc�s��IdHS)Nrr)rDrr�foo2sz(CoroutineTest.test_await_9.<locals>.foo2i��i���)r7r)rr3r�r)rDr�r�test_await_9�s	zCoroutineTest.test_await_9cs:dd���fdd���fdd�}|�t|��gdf�dS)Nc�sdS)Nr�rrrrr�bazsz(CoroutineTest.test_await_10.<locals>.bazc�s��S)Nrr)r�rrrDsz(CoroutineTest.test_await_10.<locals>.barc�s��IdHIdHS)Nrr)rDrrr3sz(CoroutineTest.test_await_10.<locals>.foor�)r7r)rr3r)rDr�r�
test_await_10
szCoroutineTest.test_await_10csDdd��dd����fdd�}�fdd�}|�t|��gd	f�dS)
NcSs|S)Nr)�valrrr�identsz*CoroutineTest.test_await_11.<locals>.identc�sdS)NrdrrrrrrDsz(CoroutineTest.test_await_11.<locals>.barc�s���IdHd�S)N)r�rr)rDr�rrr3 sz(CoroutineTest.test_await_11.<locals>.fooc�s��IdHdfS)Nr�rr)rDrrr�#sz)CoroutineTest.test_await_11.<locals>.foo2)rdr�)r7r)rr3r�r)rDr�r�
test_await_11s
zCoroutineTest.test_await_11c	sZdd�}|��G�fdd�d���fdd�}|�td��t|��WdQRX���dS)Nc�sdS)Nrdrrrrrr)sz)CoroutineTest.test_await_12.<locals>.corocseZdZ�fdd�ZdS)z.CoroutineTest.test_await_12.<locals>.Awaitablecs�S)Nr)r)r|rrr
.sz8CoroutineTest.test_await_12.<locals>.Awaitable.__await__N)rrr
r
r)r|rrr�-sr�c�s��IdHS)Nrr)r�rrr31sz(CoroutineTest.test_await_12.<locals>.fooz"__await__\(\) returned a coroutine)rNrUrrS)rrr3r)r�r|r�
test_await_12(s
zCoroutineTest.test_await_12c	s@Gdd�d���fdd�}|�td��t|��WdQRXdS)Nc@seZdZdd�ZdS)z.CoroutineTest.test_await_13.<locals>.AwaitablecSs|S)Nr)rrrrr
<sz8CoroutineTest.test_await_13.<locals>.Awaitable.__await__N)rrr
r
rrrrr�;sr�c�s��IdHS)Nrr)r�rrr3?sz(CoroutineTest.test_await_13.<locals>.fooz(__await__.*returned non-iterator of type)rNrUr)rr3r)r�r�
test_await_13:s

zCoroutineTest.test_await_13c	s�Gdd�d��Gdd�d��Gdd�dt����fdd����fd	d
�}|�}|�d�|�td��|�d�WdQRX|�}|�d�|����|�t�WdQRXdS)Nc@seZdZdd�Zdd�ZdS)z,CoroutineTest.test_await_14.<locals>.WrappercSs
||_dS)N)r)rrrrrr	Jsz5CoroutineTest.test_await_14.<locals>.Wrapper.__init__cSs
|j��S)N)rr
)rrrrr
Msz6CoroutineTest.test_await_14.<locals>.Wrapper.__await__N)rrr
r	r
rrrr�WrapperHsr�c@seZdZdd�ZdS)z/CoroutineTest.test_await_14.<locals>.FutureLikecssdVS)Nr)rrrrr
Qsz9CoroutineTest.test_await_14.<locals>.FutureLike.__await__N)rrr
r
rrrr�
FutureLikePsr�c@seZdZdS)z+CoroutineTest.test_await_14.<locals>.MarkerN)rrr
rrrr�MarkerTsr�c�s*y��IdHStk
r$��YnXdS)N)rjr)r�r�rr�coro1Wsz*CoroutineTest.test_await_14.<locals>.coro1c�s����IdHS)Nrr)r�r�rr�coro2\sz*CoroutineTest.test_await_14.<locals>.coro2rd)r�rrNrr)rorj)rr�r|r)r�r�r�r�r�
test_await_14Gs

zCoroutineTest.test_await_14c	s\tjdd����fdd�}dd�}|�}|�d�|�td��||��d�WdQRXdS)Ncss
dVdS)Nrrrrrr�jsz(CoroutineTest.test_await_15.<locals>.nopc�s��IdHdS)Nrr)r�rrr`nsz.CoroutineTest.test_await_15.<locals>.coroutinec�s|IdHdS)Nr)rrrr�waiterqsz+CoroutineTest.test_await_15.<locals>.waiterz"coroutine is being awaited already)rFr`rrNrO)rr`r�rr)r�r�
test_await_15is
zCoroutineTest.test_await_15cs2dd���fdd�}t|��\}}|�|j�dS)Nc�st�S)N)rxrrrrrL~sz&CoroutineTest.test_await_16.<locals>.fc�s yt�Wn��IdHSdS)N)�KeyErrorr)rLrrrw�sz&CoroutineTest.test_await_16.<locals>.g)rr��__context__)rrwrgrr)rLr�
test_await_16{szCoroutineTest.test_await_16cszGdd�d���fdd�}|�}t|�\}}|�|ddddd	d
ddd
g	��fdd�}|�t��t|��WdQRXdS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)z*CoroutineTest.test_with_1.<locals>.ManagercSs
||_dS)N)�name)rr�rrrr	�sz3CoroutineTest.test_with_1.<locals>.Manager.__init__c�s"td|jd|jg�IdH|S)Nzenter-1-zenter-2-)rr�)rrrr�
__aenter__�s
z5CoroutineTest.test_with_1.<locals>.Manager.__aenter__c�s0td|jd|jg�IdH|jdkr,dSdS)Nzexit-1-zexit-2-�BT)rr�)rrrrr�	__aexit__�s

z4CoroutineTest.test_with_1.<locals>.Manager.__aexit__N)rrr
r	r�r�rrrr�Manager�sr�c�sj�d�4IdH�J}�d�4IdH�(}td|j|jfg�IdHddWdQIdHRXWdQIdHRXdS)N�Ar��managersrr)rr�)rkr�)r�rrr3�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�IdHddWdQIdHRXWdQIdHRXdS)Nr��Cr�rr)rr�)rkr|)r�rrr3�s$)rr7r)rj)rr3rLrrgr)r�r�test_with_1�s
zCoroutineTest.test_with_1c	s@Gdd�d���fdd�}|�td��t|��WdQRXdS)Nc@seZdZdd�ZdS)z%CoroutineTest.test_with_2.<locals>.CMcSsdS)Nr)rrrrr��sz0CoroutineTest.test_with_2.<locals>.CM.__aenter__N)rrr
r�rrrr�CM�sr�c
�s$��4IdH�WdQIdHRXdS)Nrr)r�rrr3�sz&CoroutineTest.test_with_2.<locals>.foor�)rN�AttributeErrorr)rr3r)r�r�test_with_2�szCoroutineTest.test_with_2c	s@Gdd�d���fdd�}|�td��t|��WdQRXdS)Nc@seZdZdd�ZdS)z%CoroutineTest.test_with_3.<locals>.CMcSsdS)Nr)rrrrr��sz/CoroutineTest.test_with_3.<locals>.CM.__aexit__N)rrr
r�rrrrr��sr�c
�s$��4IdH�WdQIdHRXdS)Nrr)r�rrr3�sz&CoroutineTest.test_with_3.<locals>.foor�)rNr�r)rr3r)r�r�test_with_3�szCoroutineTest.test_with_3c	s@Gdd�d���fdd�}|�td��t|��WdQRXdS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_4.<locals>.CMcSsdS)Nr)rrrr�	__enter__�sz/CoroutineTest.test_with_4.<locals>.CM.__enter__cSsdS)Nr)rrrr�__exit__�sz.CoroutineTest.test_with_4.<locals>.CM.__exit__N)rrr
r�r�rrrrr��sr�c
�s$��4IdH�WdQIdHRXdS)Nrr)r�rrr3�sz&CoroutineTest.test_with_4.<locals>.foor�)rNr�r)rr3r)r�r�test_with_4�szCoroutineTest.test_with_4c	s>Gdd�d���fdd�}|�t��t|��WdQRXdS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_5.<locals>.CMc�s|S)Nr)rrrrr��sz0CoroutineTest.test_with_5.<locals>.CM.__aenter__c�sdS)Nr)r�excrrrr��sz/CoroutineTest.test_with_5.<locals>.CM.__aexit__N)rrr
r�r�rrrrr��sr�c
�s$��4IdH�WdQIdHRXdS)Nrr)r�rrrq�sz'CoroutineTest.test_with_5.<locals>.func)r)�AssertionErrorr)rrqr)r�r�test_with_5�szCoroutineTest.test_with_5c	s@Gdd�d���fdd�}|�td��t|��WdQRXdS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_6.<locals>.CMcSsdS)N�{r)rrrrr��sz0CoroutineTest.test_with_6.<locals>.CM.__aenter__cWsdS)Ni�r)r�errrr��sz/CoroutineTest.test_with_6.<locals>.CM.__aexit__N)rrr
r�r�rrrrr��sr�c
�s$��4IdH�WdQIdHRXdS)Nrr)r�rrr3�sz&CoroutineTest.test_with_6.<locals>.foozV'async with' received an object from __aenter__ that does not implement __await__: int)rNrUr)rr3r)r�r�test_with_6�szCoroutineTest.test_with_6c
s�Gdd�d���fdd�}yt|��WnVtk
r~}z8|�|jdd�|�|jdk	�|�t|jt��Wdd}~XYnX|�d�dS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_7.<locals>.CMc�s|S)Nr)rrrrr�sz0CoroutineTest.test_with_7.<locals>.CM.__aenter__cWsdS)Ni�r)rr�rrrr�sz/CoroutineTest.test_with_7.<locals>.CM.__aexit__N)rrr
r�r�rrrrr�sr�c
�s,��4IdH�ddWdQIdHRXdS)Nrrrr)r�rrr3sz&CoroutineTest.test_with_7.<locals>.foorzU'async with' received an object from __aexit__ that does not implement __await__: intz1invalid asynchronous context manager did not fail)	rrUrQrr8r��
isinstancerj�fail)rr3r�r)r�r�test_with_7�s$zCoroutineTest.test_with_7c	sd�Gdd�d����fdd�}|�td��t|��WdQRX|��d���fdd�}|�td��t|��WdQRX|��d	���fd
d�}|�td��t|��WdQRX|��d���fdd�}|�td��t|��WdQRX|��d
�dS)Nrc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_8.<locals>.CMc�s|S)Nr)rrrrr�sz0CoroutineTest.test_with_8.<locals>.CM.__aenter__cWsdS)Ni�r)rr�rrrr� sz/CoroutineTest.test_with_8.<locals>.CM.__aexit__N)rrr
r�r�rrrrr�sr�c
�s,��4IdH��d7�WdQIdHRXdS)Nrrr)r��CNTrrr3$sz&CoroutineTest.test_with_8.<locals>.foozU'async with' received an object from __aexit__ that does not implement __await__: intrc�s@x:td�D].}��4IdH��d7�PWdQIdHRXq
WdS)Nrr)r4)r)r�r�rrr30src�s@x:td�D].}��4IdH��d7�w
WdQIdHRXq
WdS)Nrr)r4)r)r�r�rrr3>sr�c
�s,��4IdH��d7�dSQIdHRXdS)Nrrr)r�r�rrr3Ls�)rNrUrr7)rr3r)r�r�r�test_with_8s4zCoroutineTest.test_with_8c	sPd�Gdd�d����fdd�}|�t��t|��WdQRX|��d�dS)Nrc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_9.<locals>.CMc�s|S)Nr)rrrrr�]sz0CoroutineTest.test_with_9.<locals>.CM.__aenter__c�sdddS)Nrrr)rr�rrrr�`sz/CoroutineTest.test_with_9.<locals>.CM.__aexit__N)rrr
r�r�rrrrr�\sr�c
�s,��4IdH��d7�WdQIdHRXdS)Nrrr)r�r�rrr3csz&CoroutineTest.test_with_9.<locals>.foor)r)rjrr7)rr3r)r�r�r�test_with_9YszCoroutineTest.test_with_9c
s�d�Gdd�d����fdd�}yt|��WnXtk
r�}z:|�|jdk	�|�t|jt��|�t|jjt��Wdd}~XYnX|�d�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_10.<locals>.CMc�s|S)Nr)rrrrr�qsz1CoroutineTest.test_with_10.<locals>.CM.__aenter__c�sdddS)Nrrr)rr�rrrr�tsz0CoroutineTest.test_with_10.<locals>.CM.__aexit__N)rrr
r�r�rrrrr�psr�c�sH��4IdH�*��4IdH�
t�WdQIdHRXWdQIdHRXdS)N)rOr)r�r�rrr3wsz'CoroutineTest.test_with_10.<locals>.fooz*exception from __aexit__ did not propagate)rrjr8r�r�rOr�)rr3r�r)r�r�r�test_with_10mszCoroutineTest.test_with_10c
spd�Gdd�d����fdd�}yt|��Wn2tk
r`}z|�|jdk�Wdd}~XYnX|�d�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_11.<locals>.CMc�st�dS)N)�NotImplementedError)rrrrr��sz1CoroutineTest.test_with_11.<locals>.CM.__aenter__c�sdddS)Nrrr)rr�rrrr��sz0CoroutineTest.test_with_11.<locals>.CM.__aexit__N)rrr
r�r�rrrrr��sr�c
�s(��4IdH�
t�WdQIdHRXdS)N)rOr)r�r�rrr3�sz'CoroutineTest.test_with_11.<locals>.fooz+exception from __aenter__ did not propagate)rr�r8r�r�)rr3r�r)r�r�r�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|S)Nr)rrrrr��sz1CoroutineTest.test_with_12.<locals>.CM.__aenter__c�sdS)NTr)rr�rrrr��sz0CoroutineTest.test_with_12.<locals>.CM.__aexit__N)rrr
r�r�rrrrr��sr�c
�s6��4IdH�}��|j��t�WdQIdHRXdS)N)rn�	__class__rO)�cm)r�r�rrrr3�sz'CoroutineTest.test_with_12.<locals>.foo)r)rr3r)r�r�rr�test_with_12�szCoroutineTest.test_with_12c	sPd�Gdd�d����fdd�}|�t��t|��WdQRX|��d�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_13.<locals>.CMc�sdddS)Nrrr)rrrrr��sz1CoroutineTest.test_with_13.<locals>.CM.__aenter__c�sdS)NTr)rr�rrrr��sz0CoroutineTest.test_with_13.<locals>.CM.__aexit__N)rrr
r�r�rrrrr��sr�c
�s<�d7���4IdH��d7�WdQIdHRX�d7�dS)Nri�i'rr)r�r�rrr3�sz'CoroutineTest.test_with_13.<locals>.foor)r)rjrr7)rr3r)r�r�r�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|_dS)Nr)r)rrrrr	�sz4CoroutineTest.test_for_1.<locals>.AsyncIter.__init__cs�d7�|S)Nrr)r)�aiter_callsrr�	__aiter__�sz5CoroutineTest.test_for_1.<locals>.AsyncIter.__aiter__c�sF|jd7_|jds,t|jd�IdH|jdkr:t�|j|jfS)NrrCri)rr�StopAsyncIteration)rrrr�	__anext__�s

z5CoroutineTest.test_for_1.<locals>.AsyncIter.__anext__N)rrr
r	r�r�r)r�rr�	AsyncIter�sr�c	�sDx>��2y3dH\}}Wn
tk
s4X��||�qYWdS)N)r�r)Zi1Zi2)r�rrr�test1�s$z'CoroutineTest.test_for_1.<locals>.test1rcSsg|]}|d�qS)rir)rWrrrrrX�sz,CoroutineTest.test_for_1.<locals>.<listcomp>�cSsg|]}|d�qS)rr)rWrrrrrX�s�ec	�sbxR��2y3dH}Wn
tk
s>X��|d�|ddkrPqYW��d���d�dS)Nr�zwhat?�end)r�r)r)r�rrr�test2�s 
z'CoroutineTest.test_for_1.<locals>.test2rri��cSsg|]}|�qSrr)rWrrrrrX�s�r�c	�sbxR��2y3dH}Wn
tk
s>X|ddkr.q��|d�qYW��d���d�dS)Nrr�zwhat?r�)r�r)r)r�rrr�test3�s 
z'CoroutineTest.test_for_1.<locals>.test3r�cSsg|]}|d�qS)rir)rWrrrrrXscSsg|]}|�qSrr)rWrrrrrX	szwhat?)rr7r4)rr�Zyieldedrgr�r�r)r�r�rr�
test_for_1�s*
"
zCoroutineTest.test_for_1c	sRd�t���}�fdd�}|�td��t|��WdQRX|�t���|�dS)N)rrr�c	�s8x2�2y3dH}Wn
tk
s(Xtd�qYWdS)Nznever going to happen)r��print)r)�tuprrr3sz%CoroutineTest.test_for_2.<locals>.fooz/async for' requires an object.*__aiter__.*tuple)�sys�getrefcountrNrUrr7)r�refs_beforer3r)r�r�
test_for_2s

zCoroutineTest.test_for_2c	sbGdd�d�}|��t���}�fdd�}|�td��t|��WdQRX|�t���|�dS)Nc@seZdZdd�ZdS)z#CoroutineTest.test_for_3.<locals>.IcSs|S)Nr)rrrrr�sz-CoroutineTest.test_for_3.<locals>.I.__aiter__N)rrr
r�rrrr�Isr�c	�s8x2�2y3dH}Wn
tk
s(Xtd�qYWdS)Nznever going to happen)r�r�)r)�aiterrrr3#sz%CoroutineTest.test_for_3.<locals>.fooz!that does not implement __anext__)r�r�rNrUrr7)rr�r�r3r)r�r�
test_for_3s
zCoroutineTest.test_for_3c	sbGdd�d�}|��t���}�fdd�}|�td��t|��WdQRX|�t���|�dS)Nc@seZdZdd�Zdd�ZdS)z#CoroutineTest.test_for_4.<locals>.IcSs|S)Nr)rrrrr�1sz-CoroutineTest.test_for_4.<locals>.I.__aiter__cSsdS)Nrr)rrrrr�4sz-CoroutineTest.test_for_4.<locals>.I.__anext__N)rrr
r�r�rrrrr�0sr�c	�s8x2�2y3dH}Wn
tk
s(Xtd�qYWdS)Nznever going to happen)r�r�)r)r�rrr3:sz%CoroutineTest.test_for_4.<locals>.fooz7async for' received an invalid object.*__anext__.*tuple)r�r�rNrUrr7)rr�r�r3r)r�r�
test_for_4/s
zCoroutineTest.test_for_4c	s�d�G�fdd�d��Gdd�d��������t���}t���}���fdd�}t���t�d�t|��WdQRX|��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)Ni'r)r)r�rrr�Jsz4CoroutineTest.test_for_6.<locals>.Manager.__aenter__c�s�d7�dS)Ni��r)rr)r�rrr�Nsz3CoroutineTest.test_for_6.<locals>.Manager.__aexit__N)rrr
r�r�r)r�rrr�Isr�c@s$eZdZdd�Zdd�Zdd�ZdS)z*CoroutineTest.test_for_6.<locals>.IterablecSs
d|_dS)Nr)r)rrrrr	Ssz3CoroutineTest.test_for_6.<locals>.Iterable.__init__cSs|S)Nr)rrrrr�Vsz4CoroutineTest.test_for_6.<locals>.Iterable.__aiter__c�s"|jdkrt�|jd7_|jS)NrCr)rr�)rrrrr�Ys
z4CoroutineTest.test_for_6.<locals>.Iterable.__anext__N)rrr
r	r�r�rrrr�IterableRsr�c
�s^�4IdH�:x2�2y3dH}Wn
tk
s6X�d7�qYWWdQIdHRX�d7�dS)Nri�)r�)r)r��iterable�managerrr�mainfs&z&CoroutineTest.test_for_6.<locals>.main�errori��c
�s���4IdH�<x4��2y3dH}Wn
tk
s:X�d7�qYWWdQIdHRX�d7���4IdH�<x4��2y3dH}Wn
tk
s�X�d7�qvYWWdQIdHRX�d7�dS)Nri�)r�)r)r�r�r�rrr�zs & &i�c
�s���4IdH�L�d7�x<��2y3dH}Wn
tk
sBX�d7�q YW�d7�WdQIdHRX�d7���4IdH�L�d7�x<��2y3dH}Wn
tk
s�X�d7�q�YW�d7�WdQIdHRX�d7�dS)Nriri���i�)r�)r)r�r�r�rrr��s  i��9)r�r�r r!r"rr7)rZmrefs_beforeZirefs_beforer�r)r�r�r�r�r�r�
test_for_6Fs(	





zCoroutineTest.test_for_6c	sPd�Gdd�d����fdd�}|�t��t|��WdQRX|��d�dS)Nrc@seZdZdd�ZdS)z$CoroutineTest.test_for_7.<locals>.AIcSsdddS)Nrrr)rrrrr��sz.CoroutineTest.test_for_7.<locals>.AI.__aiter__N)rrr
r�rrrr�AI�sr�c	�sBx4��2y3dH}Wn
tk
s*X�d7�qYW�d7�dS)NrrC)r�)r)r�r�rrr3�s z%CoroutineTest.test_for_7.<locals>.foo)r)rjrr7)rr3r)r�r�r�
test_for_7�szCoroutineTest.test_for_7c
snd�Gdd�d����fdd�}|�t��.t���t�d�t|��WdQRXWdQRX|��d�dS)Nrc@seZdZdd�ZdS)z$CoroutineTest.test_for_8.<locals>.AIcSsdddS)Nrrr)rrrrr��sz.CoroutineTest.test_for_8.<locals>.AI.__aiter__N)rrr
r�rrrrr��sr�c	�sBx4��2y3dH}Wn
tk
s*X�d7�qYW�d7�dS)NrrC)r�)r)r�r�rrr3�s z%CoroutineTest.test_for_8.<locals>.foor�)r)rjr r!r"rr7)rr3r)r�r�r�
test_for_8�s

zCoroutineTest.test_for_8c	sVGdd�d���fdd�}|�td��}|��d�WdQRX|j}|�|jt�dS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)z$CoroutineTest.test_for_11.<locals>.FcSs|S)Nr)rrrrr��sz.CoroutineTest.test_for_11.<locals>.F.__aiter__cSs|S)Nr)rrrrr��sz.CoroutineTest.test_for_11.<locals>.F.__anext__cSsdddS)Nrrr)rrrrr
�sz.CoroutineTest.test_for_11.<locals>.F.__await__N)rrr
r�r�r
rrrr�F�src	�s2x,��2y3dH}Wqtk
s"XqYWdS)N)r�)rg)rrrr��s z'CoroutineTest.test_for_11.<locals>.mainz an invalid object from __anext__)rNrUrZ	exceptionrE�	__cause__rj)rr�r|�errr)rr�test_for_11�szCoroutineTest.test_for_11c	shGdd�dt��Gdd�dt��g����fdd�}|����|��d�WdQRX|��dg�dS)Nc@seZdZdS)z*CoroutineTest.test_for_tuple.<locals>.DoneN)rrr
rrrr�Done�src@s eZdZdZdd�Zdd�ZdS)z+CoroutineTest.test_for_tuple.<locals>.AIterrcSs|S)Nr)rrrrr��sz5CoroutineTest.test_for_tuple.<locals>.AIter.__aiter__c�s.|jt|�krt�|jd7_||jdS)Nr)r�lenr�)rrrrr��sz5CoroutineTest.test_for_tuple.<locals>.AIter.__anext__N)rrr
rr�r�rrrr�AIter�src	�sDx:�dg�2y3dH}Wn
tk
s0X��|�qYW��dS)Nr�)r�r)r)rrrrrr3�s$z)CoroutineTest.test_for_tuple.<locals>.foor�)r�rZr)rr7)rr3r)rrrr�test_for_tuple�s
zCoroutineTest.test_for_tuplec	shGdd�dt��Gdd�dt��g����fdd�}|����|��d�WdQRX|��dg�dS)Nc@seZdZdS)z3CoroutineTest.test_for_stop_iteration.<locals>.DoneN)rrr
rrrrr�src@s eZdZdZdd�Zdd�ZdS)z4CoroutineTest.test_for_stop_iteration.<locals>.AIterrcSs|S)Nr)rrrrr��sz>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__aiter__c�s|jr
t�|jd7_|jS)Nr)rr�r)rrrrr��sz>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__anext__N)rrr
rr�r�rrrrr�src	�sBx8�d�2y3dH}Wn
tk
s.X��|�q
YW��dS)Nr�)r�r)r)rrrrrr3�s"z2CoroutineTest.test_for_stop_iteration.<locals>.foor�)r�rr)rr7)rr3r)rrrr�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|S)Nr)rrrrrLsz$CoroutineTest.test_comp_1.<locals>.fc�s dd��d��d�gD�IdHS)Nc�sg|]}|IdH�qS)Nr)rWr|rrrrX	sz?CoroutineTest.test_comp_1.<locals>.run_list.<locals>.<listcomp>r�)rr)rLrr�run_listsz+CoroutineTest.test_comp_1.<locals>.run_listc�s dd��d��d�gD�IdHS)Nc�sh|]}|IdH�qS)Nr)rWr|rrr�	<setcomp>sz=CoroutineTest.test_comp_1.<locals>.run_set.<locals>.<setcomp>rr
rr)rLrr�run_setsz*CoroutineTest.test_comp_1.<locals>.run_setc�s dd��d��d�gD�IdHS)Nc�si|]}d|IdH�qS)rkNr)rWr|rrr�
<dictcomp>sz@CoroutineTest.test_comp_1.<locals>.run_dict1.<locals>.<dictcomp>rr
rr)rLrr�	run_dict1sz,CoroutineTest.test_comp_1.<locals>.run_dict1c�s$dd�t�d��d�g�D�IdHS)Nc�si|]\}}|IdH|�qS)Nr)rWrr|rrrrsz@CoroutineTest.test_comp_1.<locals>.run_dict2.<locals>.<dictcomp>rr
)�	enumerater)rLrr�	run_dict2sz,CoroutineTest.test_comp_1.<locals>.run_dict2rr
rk)rr
)rr)r7r)rrr
rrr)rLr�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|S)Nr)rrrrrLsz$CoroutineTest.test_comp_2.<locals>.fc�s0dd��d��d��d��ddg�gD�IdHS)Nc�s g|]}|IdHD]}|�qqS)Nr)rWr|�srrrrXsz?CoroutineTest.test_comp_2.<locals>.run_list.<locals>.<listcomp>��abc�de�fgrr)rLrrrsz+CoroutineTest.test_comp_2.<locals>.run_listrkr�r|rrc�s,dd���ddg��dg�g�gD�IdHS)Nc�s0h|](}|IdHD]}|IdHD]}|�q qqS)Nr)rWr|r�drrrr&sz=CoroutineTest.test_comp_2.<locals>.run_set.<locals>.<setcomp>rC�r�rr)rLrrr
%sz*CoroutineTest.test_comp_2.<locals>.run_setrCr�rc�s&dd���d��d�g�gD�IdHS)Nc�s&h|]}|IdHD]}|IdH�qqS)Nr)rWr|rrrrr1sz>CoroutineTest.test_comp_2.<locals>.run_set2.<locals>.<setcomp>rCr�rr)rLrr�run_set20sz+CoroutineTest.test_comp_2.<locals>.run_set2)r7r)rrr
rr)rLr�test_comp_2szCoroutineTest.test_comp_2cs�dd���fdd�}|�t|��gddgf��fdd�}|�t|��gddhf��fd	d
�}|�t|��gddd
�f��fdd�}|�t|��gddgf�dS)NcSsx|D]
}|VqWdS)Nr)r�rrrrrL:s
z$CoroutineTest.test_comp_3.<locals>.fc�sdd��ddg�2�IdHS)Nc
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nr)r�)rWrrrrrX?sz?CoroutineTest.test_comp_3.<locals>.run_list.<locals>.<listcomp>rCr�rr)rLrrr>sz+CoroutineTest.test_comp_3.<locals>.run_listr�r�c�sdd��ddg�2�IdHS)Nc
�s2h|y3dH}Wn
tk
s&X|d�qYS)Nr)r�)rWrrrrrEsz=CoroutineTest.test_comp_3.<locals>.run_set.<locals>.<setcomp>rCr�rr)rLrrr
Dsz*CoroutineTest.test_comp_3.<locals>.run_setc�sdd��ddg�2�IdHS)Nc
�s8i|y3dH}Wn
tk
s,X|d|d�qYS)Nrr)r�)rWrrrrrKsz?CoroutineTest.test_comp_3.<locals>.run_dict.<locals>.<dictcomp>rCr�rr)rLrr�run_dictJsz+CoroutineTest.test_comp_3.<locals>.run_dict��)r�r�c�s*dd��ddg�2�}dd�|2�IdHS)Nc	Ss4|y3dH}Wn
tk
s&X|dVqYdS)Nr)r�)rWrrrr�	<genexpr>Qs
z=CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<genexpr>rCr�c
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nri)r�)rWrwrrrrXRsz>CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<listcomp>r)r>)rLrr�run_genPsz*CoroutineTest.test_comp_3.<locals>.run_gen�o�y)r7r)rrr
rr r)rLr�test_comp_39s"zCoroutineTest.test_comp_3cs�dd���fdd�}|�t|��gdgf��fdd�}|�t|��gdhf��fdd	�}|�t|��gdd
if��fdd�}|�t|��gd
gf�dS)NcSsx|D]
}|VqWdS)Nr)r�rrrrrLXs
z$CoroutineTest.test_comp_4.<locals>.fc�sdd��ddg�2�IdHS)Nc
�s:g|y3dH}Wn
tk
s.X|dkr|d�qYS)NrCr)r�)rWrrrrrX]sz?CoroutineTest.test_comp_4.<locals>.run_list.<locals>.<listcomp>rCr�rr)rLrrr\sz+CoroutineTest.test_comp_4.<locals>.run_listr�c�sdd��ddg�2�IdHS)Nc
�s:h|y3dH}Wn
tk
s.X|dkr|d�qYS)NrCr)r�)rWrrrrrcsz=CoroutineTest.test_comp_4.<locals>.run_set.<locals>.<setcomp>rCr�rr)rLrrr
bsz*CoroutineTest.test_comp_4.<locals>.run_setc�sdd��ddg�2�IdHS)Nc
�s@i|y3dH}Wn
tk
s4X|dkr|d|d�qYS)NrCrr)r�)rWrrrrrisz?CoroutineTest.test_comp_4.<locals>.run_dict.<locals>.<dictcomp>rCr�rr)rLrrrhsz+CoroutineTest.test_comp_4.<locals>.run_dictrc�s*dd��ddg�2�}dd�|2�IdHS)Nc	Ss<|y3dH}Wn
tk
s.X|dkr|dVqYdS)NrCr)r�)rWrrrrros
z=CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<genexpr>rCr�c
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nri)r�)rWrwrrrrXpsz>CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<listcomp>r)r>)rLrrr nsz*CoroutineTest.test_comp_4.<locals>.run_genr")r7r)rrr
rr r)rLr�test_comp_4Ws"zCoroutineTest.test_comp_4cs�dd���fdd�}|�t|��gdddgf��fdd	�}|�t|��gdddhf��fd
d�}|�t|��gdd
dd�f��fdd�}|�t|��gdddgf�dS)NcSsx|D]
}|VqWdS)Nr)r�rrrrrLvs
z&CoroutineTest.test_comp_4_2.<locals>.fc�sdd��td��2�IdHS)Nc
�sJg|y3dH}Wn
tk
s>Xd|kr0dkrnq|d�qYS)Nrr�rC)r�)rWrrrrrX{szACoroutineTest.test_comp_4_2.<locals>.run_list.<locals>.<listcomp>�)r4r)rLrrrzsz-CoroutineTest.test_comp_4_2.<locals>.run_listr�r�
c�sdd��td��2�IdHS)Nc
�sJh|y3dH}Wn
tk
s>Xd|kr0dkrnq|d�qYS)Nrr�rC)r�)rWrrrrr�sz?CoroutineTest.test_comp_4_2.<locals>.run_set.<locals>.<setcomp>r%)r4r)rLrrr
�sz,CoroutineTest.test_comp_4_2.<locals>.run_setc�sdd��td��2�IdHS)Nc
�sPi|y3dH}Wn
tk
sDXd|kr0dkrnq|d|d�qYS)Nrr�rirC)r�)rWrrrrr�szACoroutineTest.test_comp_4_2.<locals>.run_dict.<locals>.<dictcomp>r%)r4r)rLrrr�sz-CoroutineTest.test_comp_4_2.<locals>.run_dictr�rm�g)r�rr&c�s*dd��td��2�}dd�|2�IdHS)Nc	SsL|y3dH}Wn
tk
s>Xd|kr.dkrnq|dVqYdS)Nrr�rC)r�)rWrrrrr�s
z?CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<genexpr>r%c
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nri)r�)rWrwrrrrX�sz@CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<listcomp>)r4)r>)rLrrr �sz,CoroutineTest.test_comp_4_2.<locals>.run_genr!�p�q)r7r)rrr
rr r)rLr�
test_comp_4_2us"zCoroutineTest.test_comp_4_2cs0dd���fdd�}|�t|��gdgf�dS)NcSsx|D]
}|VqWdS)Nr)r�rrrrrL�s
z$CoroutineTest.test_comp_5.<locals>.fc�s$�fdd�ddgddgfD�IdHS)Nc�sTg|]L}|ddkr�|�2y3dH}Wn
tk
sFX|dkr|d�qYqS)rrCNrr)r�)rWZpairr)rLrrrX�sz?CoroutineTest.test_comp_5.<locals>.run_list.<locals>.<listcomp>rCr�r�(rr)rLrrr�sz+CoroutineTest.test_comp_5.<locals>.run_listr
)r7r)rrr)rLr�test_comp_5�s
zCoroutineTest.test_comp_5cs4dd���fdd�}|�t|��gdddgf�dS)NcSsx|D]
}|VqWdS)Nr)r�rrrrrL�s
z$CoroutineTest.test_comp_6.<locals>.fc�sdd��ddg�2�IdHS)Nc
�s<g|y3dH}Wn
tk
s0X|D]}|d�q qYS)Nr)r�)rW�seqrrrrrX�sz?CoroutineTest.test_comp_6.<locals>.run_list.<locals>.<listcomp>)rCr�)rrr)rLrrr�sz+CoroutineTest.test_comp_6.<locals>.run_listr�r��)r7r)rrr)rLr�test_comp_6�s
zCoroutineTest.test_comp_6c	s:dd���fdd�}|�td��t|��WdQRXdS)NcSsdVdVtd��dS)Nrr�aaa)r�rrrrrL�sz$CoroutineTest.test_comp_7.<locals>.fc�sdd���2�IdHS)Nc
�s.g|y3dH}Wn
tk
s"X|�qYS)N)r�)rWrrrrrX�sz?CoroutineTest.test_comp_7.<locals>.run_list.<locals>.<listcomp>rr)rLrrr�sz+CoroutineTest.test_comp_7.<locals>.run_listr0)rNr�r)rrr)rLr�test_comp_7�szCoroutineTest.test_comp_7cCs(dd�}|�t|��gdddgf�dS)Nc�sdd�dD�S)NcSsg|]}|�qSrr)rWrrrrrX�sz8CoroutineTest.test_comp_8.<locals>.f.<locals>.<listcomp>)rrr�rrrrrrL�sz$CoroutineTest.test_comp_8.<locals>.frrr�)r7r)rrLrrr�test_comp_8�szCoroutineTest.test_comp_8cs2dd���fdd�}|�t|��gddgf�dS)NcSsdVdVdS)Nrrrrrrrr>�sz&CoroutineTest.test_comp_9.<locals>.genc�s$dd���2�IdH}dd�|D�S)Nc
�s.g|y3dH}Wn
tk
s"X|�qYS)N)r�)rWrrrrrX�sz8CoroutineTest.test_comp_9.<locals>.f.<locals>.<listcomp>cSsg|]}|�qSrr)rWrrrrrX�sr)�l)r>rrrL�sz$CoroutineTest.test_comp_9.<locals>.frr)r7r)rrLr)r>r�test_comp_9�s
zCoroutineTest.test_comp_9cCs*dd�}|�t|��gdddd�f�dS)Nc�sdd�dD�}dd�|D�S)NcSsh|]}|�qSrr)rWrrrrr�sz8CoroutineTest.test_comp_10.<locals>.f.<locals>.<setcomp>)rrr�cSsi|]
}||�qSrr)rW�xrrrr�sz9CoroutineTest.test_comp_10.<locals>.f.<locals>.<dictcomp>r)ZxxrrrrL�sz%CoroutineTest.test_comp_10.<locals>.frrr�)rrr�)r7r)rrLrrr�test_comp_10�szCoroutineTest.test_comp_10c	Csjdd�}|�}|�t��t�|�WdQRX|��}z$|�t��t�|�WdQRXWd|��XdS)Nc�sdS)Nrrrrrrq�r?z%CoroutineTest.test_copy.<locals>.func)r)rU�copyr
rS)rrqrrrrr�	test_copy�szCoroutineTest.test_copyc
Cs�dd�}|�}x>ttjd�D],}|�ttjf��t�||�WdQRXqW|��}zDx>ttjd�D],}|�ttjf��t�||�WdQRXqhWWd|��XdS)Nc�sdS)Nrrrrrrq�r?z'CoroutineTest.test_pickle.<locals>.funcr)	r4�pickleZHIGHEST_PROTOCOLr)rUZ
PicklingError�dumpsr
rS)rrqr�protorrrr�test_pickle�szCoroutineTest.test_picklec
Cs\dd�}t���2t���}t�d�|�t��WdQRXWdQRX|�d|���dS)Nc�sdS)Nrrrrrrq�r?z3CoroutineTest.test_fatal_coro_warning.<locals>.funcr�zwas never awaited)r r!r�captured_stderr�filterwarningsr#rs�getvalue)rrq�stderrrrr�test_fatal_coro_warning�s
z%CoroutineTest.test_fatal_coro_warningN)Prrr
rBrMrPrTr^rarbrcrerhrpruryrzr}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�r�r�r�r�r�r�r�r�r�rrrr	rrr#r$r*r,r/r1r2r4r6r8r<rArrrrr=�s�	#
	(	


"(@H\ 
	
r=c@seZdZdd�ZdS)�CoroAsyncIOCompatTestc	s�t�d��Gdd�dt��g�G��fdd�d������fdd�}���}��|�z*y|�|��Wn�k
r|YnXWd|����d�X|��dd	dg�dS)
N�asyncioc@seZdZdS)z9CoroAsyncIOCompatTest.test_asyncio_1.<locals>.MyExceptionN)rrr
rrrr�MyExceptionsrDcs(eZdZ��fdd�Z��fdd�ZdS)z0CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CMc�s(��d���d�IdH��d�|S)Nrg{�G�z�?r)r�sleep)r)rCrrrr�s

z;CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aenter__c�s ��d�IdH��|j�dS)Ng{�G�z�?)rErr)r�exc_typeZexc_valZexc_tb)rCrrrr�sz:CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aexit__N)rrr
r�r�r)rCrrrr�sr�c
�sB��4IdH�}��d�IdH��WdQIdHRX��d�dS)Ng{�G�z�?Zunreachable)rEr)r|)r�rDrCrrrrLsz/CoroAsyncIOCompatTest.test_asyncio_1.<locals>.frr)r�
import_moduler�Znew_event_loopZset_event_loopZrun_until_completerSr7)rrLZloopr)r�rDrCrr�test_asyncio_1�s


z$CoroAsyncIOCompatTest.test_asyncio_1N)rrr
rHrrrrrB�srBc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�SysSetCoroWrapperTestcsdd�}d��fdd�}|�t��|�t���WdQRX|�t��t�|�WdQRX|�t��|�t��|�WdQRXz(|�}|���|�t	|�gdf�Wd|�t��t�d�WdQRX|�
�X|�t��|�t���WdQRXd�|�}|���|�
�dS)Nc�sdS)Nrdrrrrrr3(sz5SysSetCoroWrapperTest.test_set_wrapper_1.<locals>.foocs|�|S)Nr)r>)�wrappedrrr�,sz6SysSetCoroWrapperTest.test_set_wrapper_1.<locals>.wraprd)�assertWarns�DeprecationWarningr�r��get_coroutine_wrapper�set_coroutine_wrapperrnr8r7rrSr@)rr3r�rLrr)rJr�test_set_wrapper_1's,


z(SysSetCoroWrapperTest.test_set_wrapper_1c
Cs�|�t��|�t���WdQRX|�td��&|�t��t�d�WdQRXWdQRX|�t��|�t���WdQRXdS)Nzcallable expected, got intr)rKrLr�r�rMrNrUrN)rrrr�test_set_wrapper_2Jsz(SysSetCoroWrapperTest.test_set_wrapper_2cCs�dd�}dd�}|�t��t�|�WdQRXz4t��$|�td��|�WdQRXWdQRXWd|�t��t�d�WdQRXXdS)Nc�sdS)Nrdrrrrrr3Tsz5SysSetCoroWrapperTest.test_set_wrapper_3.<locals>.foocSsdd�}||�S)Nc�s
|IdHS)Nr)rrrrr�XszGSysSetCoroWrapperTest.test_set_wrapper_3.<locals>.wrapper.<locals>.wrapr)rr�rrr�wrapperWsz9SysSetCoroWrapperTest.test_set_wrapper_3.<locals>.wrapperzLcoroutine wrapper.*\.wrapper at 0x.*attempted to recursively wrap .* wrap .*)rKrLr�rNr$rNrO)rr3rQrrr�test_set_wrapper_3Ssz(SysSetCoroWrapperTest.test_set_wrapper_3cs~tjdd��}d��fdd�}|�t��t�|�WdQRXz|�|��dd�Wd|�t��t�d�WdQRXXdS)NcSsdS)Nrdrrrrrr3ksz5SysSetCoroWrapperTest.test_set_wrapper_4.<locals>.foocs|�|S)Nr)r>)rJrrr�psz6SysSetCoroWrapperTest.test_set_wrapper_4.<locals>.wrapzCgenerator-based coroutine was wrapped via sys.set_coroutine_wrapper)rFr`rKrLr�rNrn)rr3r�r)rJr�test_set_wrapper_4js
z(SysSetCoroWrapperTest.test_set_wrapper_4N)rrr
rOrPrRrSrrrrrI%s#	rIc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�OriginTrackingTestcCst�t��j�}|j|jfS)N)r9ZgetframeinfoZcurrentframe�f_back�filename�lineno)r�inforrr�here�szOriginTrackingTest.herec	s�t��}�z�dd��t�d���t��d�t�����}��|j�WdQRXt�d���t��d����\}}t����� }��|j||ddff�WdQRXt�d���t��d���fdd�}���\}}|�\\}}}t�|��(��|j||d	f||ddff�WdQRXt�d
�t�����,}��	dt
|j�k�oZd
kn�WdQRX��t��t�d�WdQRX��t��d
�Wdt�|�XdS)Nc�sdS)Nrrrrr�corofn�sz7OriginTrackingTest.test_origin_tracking.<locals>.corofnrr�test_origin_trackingrcs�����fS)N)rYr)rZrrr�nested�sz7OriginTrackingTest.test_origin_tracking.<locals>.nestedr\i����)
r��#get_coroutine_origin_tracking_depth�#set_coroutine_origin_tracking_depthr7�
contextlib�closingr��	cr_originrYr8rr)rx)r�
orig_depthrZfnamerWr\Znested_fnameZ
nested_linenor)rZrrr[�s:



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��Wdt�|�XdS)Nc�sdS)NrrrrrrZ�sz?OriginTrackingTest.test_origin_tracking_warning.<locals>.corofncs��S)Nrr)rZrr�a1�sz;OriginTrackingTest.test_origin_tracking_warning.<locals>.a1rcs��S)Nrr)rdrr�a2�sz;OriginTrackingTest.test_origin_tracking_warning.<locals>.a2c	sDt�|���t��}��t��WdQRX��|t|j��dS)N)	r�r_rKrfrr#r7�strZwarning)�depth�msgr�)rerrrr]�s

z>OriginTrackingTest.test_origin_tracking_warning.<locals>.checkrzcoroutine 'z' was never awaitedrrz' 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
)rYr�r^r
r6r_)rZa1_filenameZ	a1_linenoZa2_filenameZ	a2_linenor]rcrhr)rdrerZrr�test_origin_tracking_warning�s0
z/OriginTrackingTest.test_origin_tracking_warningc	Cs�dd�}tj}z�dd�t_t���}|�t��WdQRX|�d|���|�d|���|�d|���t`t���}|�t��WdQRX|�d|���Wd|t_XdS)Nc�sdS)NrrrrrrZ�szLOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.corofncSsddS)Nrrr)rrrrrV�r?zNOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.<lambda>zException ignored inrjzwas never awaited)r �_warn_unawaited_coroutinerr=r#rsr?)rrZZorig_wuc�streamrrr�)test_unawaited_warning_when_module_broken�s 


z<OriginTrackingTest.test_unawaited_warning_when_module_brokenN)rrr
rYr[rirlrrrrrT�s.*rTc@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)rr&rrr�&test_unawaited_warning_during_shutdown�s

zIUnawaitedWarningDuringShutdownTest.test_unawaited_warning_during_shutdownN)rrr
rnrrrrrm�srmc@s$eZdZdd�Zdd�Zdd�ZdS)�CAPITestcs0ddlm��fdd�}|�|��d�d�dS)Nr)�	awaitTypec�s�tdg��}|IdHS)Nr)r\)�future)�atrrr3	sz%CAPITest.test_tp_await_1.<locals>.foor)�	_testcapirpr7r)rr3r)rrr�test_tp_await_1	szCAPITest.test_tp_await_1cCs2ddlm}|tdg��}|�t|���d�dS)Nr)rpr)rsrpr\r7rr
)rrrrqrrr�test_tp_await_2	szCAPITest.test_tp_await_2c	sHddlm��fdd�}|�td��|�|��d�d�WdQRXdS)Nr)rpc�s�d�}|IdHS)Nrr)rq)rrrrr3#	sz%CAPITest.test_tp_await_3.<locals>.fooz.__await__.*returned non-iterator of type 'int'r)rsrprNrUr7r)rr3r)rrr�test_tp_await_3 	s

zCAPITest.test_tp_await_3N)rrr
rtrurvrrrrro	s	ro�__main__)r`r7r9r9�rer�rFZunittestr ZtestrZtest.support.script_helperrrrrr�contextmanagerr$ZTestCaser%r1r=rBrIrTrmZcpython_onlyrorr�rrrr�<module>sR*]x