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.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
Csz|jtjtjhkst�g}d}xRy|�|�d��Wq tk
rl}z|jrV|jdnd}PWdd}~XYq Xq W||fS)Nr)	�	__class__�types�
GeneratorType�
CoroutineType�AssertionError�append�send�
StopIteration�args)�coro�buffer�result�exrrr�	run_asyncsrc
Cs�|jtjkst�|��}g}d}d}xry4|dr@|�t|��n|�|�d��|d7}Wq&tk
r�}z|j	r||j	dnd}PWdd}~XYq&Xq&W||fS)Nr��)
rrrrr
r�nextrrr)r�awrr�irrrr�run_async__await__,sr#c	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/r0)rr1r+rrr�test_badsyntax_2�s
z#AsyncBadSyntaxTest.test_badsyntax_2c	Cs&|�t��tddd�WdQRXdS)Nz	async = 1z<test>r,)r.r/r0)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/r0)rr1r+rrr�test_badsyntax_4�s	

z#AsyncBadSyntaxTest.test_badsyntax_4N)rrr
r2r3r4r5rrrrr*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
rArrrrr6�sr6c@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)rrCrrr�
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�
rrrrrr8�sz&CoroutineTest.test_func_1.<locals>.foorHcSsdS)Nrrrrr�bar
rDz&CoroutineTest.test_func_1.<locals>.bar)�assertIsInstancerrr=�bool�__code__�co_flagsr>ZCO_COROUTINErEZCO_GENERATOR�cr_coder<rr#)rr8�frIrrr�test_func_1�szCoroutineTest.test_func_1c	Cs.dd�}|�td��t|��WdQRXdS)Nc�st�dS)N)rrrrrr8sz&CoroutineTest.test_func_2.<locals>.foozcoroutine raised StopIteration)�assertRaisesRegex�RuntimeErrorr)rr8rrr�test_func_2
s
zCoroutineTest.test_func_2cCs*dd�}|�}|�t|�d�|��dS)Nc�st�dS)N)rrrrrr8sz&CoroutineTest.test_func_3.<locals>.fooz^<coroutine object.* at 0x.*>$)�assertRegex�repr�close)rr8rrrr�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)rrrrrr8sz&CoroutineTest.test_func_4.<locals>.foocs��td�S)Nz"'coroutine' object is not iterable)rQ�	TypeErrorr)rrr�<lambda>#sz+CoroutineTest.test_func_4.<locals>.<lambda>cSsg|]}|�qSrr)�.0r"rrr�
<listcomp>7sz-CoroutineTest.test_func_4.<locals>.<listcomp>)�list�tuple�sum�iterrV)rr8r�checkr"r)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)NrrrrrrrI<sz&CoroutineTest.test_func_5.<locals>.barc�s��IdHdS)Nrr)rIrrr8@sz&CoroutineTest.test_func_5.<locals>.foocs��td�S)Nz"'coroutine' object is not iterable)rQrXr)rrrrYCsz+CoroutineTest.test_func_5.<locals>.<lambda>rcSsg|]}|�qSrr)rZ�elrrrr[Osz-CoroutineTest.test_func_5.<locals>.<listcomp>)r)r�	coroutinerVr<r]r r_)rr8r`rrbr)rIrr�test_func_5;s
zCoroutineTest.test_func_5c	shtjdd����fdd�}|�}|�|�d�d�|�|�d�d�|�t��|�d�WdQRXdS)NcssdVdVdS)NrrrrrrrrITsz&CoroutineTest.test_func_6.<locals>.barc�s��IdHdS)Nrr)rIrrr8Ysz&CoroutineTest.test_func_6.<locals>.foorr)rrcr<rr.r)rr8rOr)rIr�test_func_6SszCoroutineTest.test_func_6c	sHdd�}|���fdd�}|�td��t|��WdQRX���dS)Nc�sdS)NrHrrrrrrIcsz&CoroutineTest.test_func_7.<locals>.barc3s�EdHdS)Nrr)rrrr8gsz&CoroutineTest.test_func_7.<locals>.foozCcannot 'yield from' a coroutine object in a non-coroutine generator)rQrXr\rV)rrIr8r)rr�test_func_7bszCoroutineTest.test_func_7csBtj�fdd��}dd�}|��|�t|��gdf����dS)Nc3s
�EdHS)Nrr)rrrrIssz&CoroutineTest.test_func_8.<locals>.barc�sdS)N�spamrrrrrr8wsz&CoroutineTest.test_func_8.<locals>.foorg)rrcr<rrV)rrIr8r)rr�test_func_8rs
zCoroutineTest.test_func_8c
Csxdd�}|�td��|�t��WdQRX|�td��4|�t��x|�D]}qPWWdQRXt��WdQRXdS)Nc�sdS)Nrrrrrr8sz&CoroutineTest.test_func_9.<locals>.fooz0coroutine '.*test_func_9.*foo' was never awaited)ZassertWarnsRegex�RuntimeWarningrr(r.rX)rr8�_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)�NrrrC�sz'CoroutineTest.test_func_10.<locals>.genc�s��IdHdS)Nrr)rCrrr8�sz'CoroutineTest.test_func_10.<locals>.foorHrlr�f)rrcr
�assertIsr_r r<rrVr.rm�throw)rr8rr!r)rorCr�test_func_10�s"zCoroutineTest.test_func_10cCsRdd�}|�}|�dt|��|�dt|����|�dt|����|��dS)Nc�sdS)Nrrrrr�func�rDz(CoroutineTest.test_func_11.<locals>.funcr
�__iter__Zcoroutine_wrapper)�assertIn�dirr
rUrV)rrtrrrr�test_func_11�szCoroutineTest.test_func_11c	s8�fdd�}|��|�td����d�WdQRXdS)Nc�s��d�}tIdHdS)N)rr8)r")�merr�g�s
z%CoroutineTest.test_func_12.<locals>.gzcoroutine already executing)rQ�
ValueErrorr)rrzr)ryr�test_func_12�s
zCoroutineTest.test_func_12c	Cs<dd�}|�}|�td��|�d�WdQRX|��dS)Nc�sdS)Nrrrrrrz�sz%CoroutineTest.test_func_13.<locals>.gz5can't send non-None value to a just-started coroutinerg)rQrXrrV)rrzrrrr�test_func_13�szCoroutineTest.test_func_13c	sNtjdd����fdd�}|�}|�d�|�td��|��WdQRXdS)Ncss
dVdS)NrrrrrrC�sz'CoroutineTest.test_func_14.<locals>.genc�s6y��IdHWn tk
r0��IdHYnXdS)N)�
GeneratorExitr)rCrrr�sz(CoroutineTest.test_func_14.<locals>.corozcoroutine ignored GeneratorExit)rrcrrQrRrV)rr�cr)rCr�test_func_14�s
zCoroutineTest.test_func_14c	Csfdd�}dd�}|�}|�td��||��d�WdQRX|�td��||��d�WdQRXdS)Nc�sdS)Nrgrrrrr�spammer�sz+CoroutineTest.test_func_15.<locals>.spammerc�s
|IdHS)Nr)rrrr�reader�sz*CoroutineTest.test_func_15.<locals>.readerrgz&cannot reuse already awaited coroutine)rQrrrR)rr�r�Z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)Nrgrr)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)rrcrrQ�	ExceptionrrrR)rrr�r�r�r)r�r�test_func_16�s"


zCoroutineTest.test_func_16c	Cs�dd�}|�}|�td��|�d�WdQRX|�td��|�d�WdQRX|�td��|�td��WdQRX|��|��dS)Nc�sdS)Nrgrrrrrrcsz-CoroutineTest.test_func_17.<locals>.coroutinergz&cannot reuse already awaited coroutiner�)rQrrrRrrr�rV)rrcrrrr�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)Nrgrrrrrrc/sz-CoroutineTest.test_func_18.<locals>.coroutinergz&cannot reuse already awaited coroutiner�)
r
r_rQrrrRr rrr�rV)rrcrZ
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)�CHKrrr8Ws

z'CoroutineTest.test_func_19.<locals>.fooc�s��IdHdS)Nrr)r8rrrc`sz-CoroutineTest.test_func_19.<locals>.coroutiner�)rrcrr<rVr9)rrcrrjr)r�r8r�test_func_19Ts	

zCoroutineTest.test_func_19cCs&dd�}t|��}|�|gdf�dS)Nc�sdS)N)rHrrrrrr8ssz7CoroutineTest.test_coro_wrapper_send_tuple.<locals>.foo)rH)r#r<)rr8rrrr�test_coro_wrapper_send_tuplers
z*CoroutineTest.test_coro_wrapper_send_tuplecCs8dd�}t|��}|�|dt�|�|djd�dS)Nc�std�S)NrH)rrrrrr8zsz?CoroutineTest.test_coro_wrapper_send_stop_iterator.<locals>.foorrH)r#rJrr<r)rr8rrrr�$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)r<r>�getcoroutinestateZCORO_RUNNING�assertIsNone�cr_awaitr)�coro_brrrrn�s
z&CoroutineTest.test_cr_await.<locals>.ac�s��IdHdS)Nrr)rnrrr�sz&CoroutineTest.test_cr_await.<locals>.cc�s(���j���IdH���j�dS)N)r�r�r)rr�rrr�b�sz&CoroutineTest.test_cr_await.<locals>.brn)rrcr<r>r�ZCORO_CREATEDr�r�rZCORO_SUSPENDED�gi_code�co_namer.rZCORO_CLOSED)rr�r)rnrr�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
rcc�sdS)NrrrrrrO�rDz(CoroutineTest.test_corotype_1.<locals>.fzcoroutine object)rrrvr�__doc__rVrr�__dict__r<rrU)rZctrOrrrr�test_corotype_1�szCoroutineTest.test_corotype_1c	Cs.dd�}|�td��t|��WdQRXdS)Nc�sdIdHdS)Nrrrrrrr8�sz'CoroutineTest.test_await_1.<locals>.foozobject int can.t.*await)rQrXr)rr8rrr�test_await_1�szCoroutineTest.test_await_1c	Cs.dd�}|�td��t|��WdQRXdS)Nc�sgIdHdS)Nrrrrrr8�sz'CoroutineTest.test_await_2.<locals>.foozobject list can.t.*await)rQrXr)rr8rrr�test_await_2�szCoroutineTest.test_await_2cCsDdd�}|�t|��dddgdf�|�t|��dddgdf�dS)Nc�stdddg�IdHdS)Nrrr�)rrrrrr8�sz'CoroutineTest.test_await_3.<locals>.foorrr�)r<rr#)rr8rrr�test_await_3�szCoroutineTest.test_await_3cs.dd���fdd�}|�t|��gdf�dS)Nc�sdS)N�*rrrrrrI�sz'CoroutineTest.test_await_4.<locals>.barc�s��IdHS)Nrr)rIrrr8�sz'CoroutineTest.test_await_4.<locals>.foor�)r<r)rr8r)rIr�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�rrr8�sz'CoroutineTest.test_await_5.<locals>.fooz(__await__.*returned non-iterator of type)rQrXr)rr8r)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�rrr8�sz'CoroutineTest.test_await_6.<locals>.foor�)r<r)rr8r)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�rlr)rrrrr
�sz7CoroutineTest.test_await_7.<locals>.Awaitable.__await__N)rrr
r
rrrrr��sr�c�s��IdHS)Nrr)r�rrr8�sz'CoroutineTest.test_await_7.<locals>.foor�rl)r<r)rr8r)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�rrr8�rDz'CoroutineTest.test_await_8.<locals>.fooz4object Awaitable can't be used in 'await' expression)rQrXr)rr8r)r�r�test_await_8�s

zCoroutineTest.test_await_8cs^�fdd��dd����fdd�}�fdd�}|�t|��gd	f�|�t|��gd
f�dS)Ncs�S)Nrr)rIrr�wrap�sz(CoroutineTest.test_await_9.<locals>.wrapc�sdS)Nr�rrrrrrI�sz'CoroutineTest.test_await_9.<locals>.barc�spd�fdd�i}G�fdd�d�}��IdH���IdH|d���IdH��IdHd|���IdHS)Nr�cs�S)Nrr)r�rrrY�rDz9CoroutineTest.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�)rIr�rrr8�sz'CoroutineTest.test_await_9.<locals>.fooc�s��IdHS)Nrr)rIrr�foo2sz(CoroutineTest.test_await_9.<locals>.foo2i��i���)r<r)rr8r�r)rIr�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�rrrIsz(CoroutineTest.test_await_10.<locals>.barc�s��IdHIdHS)Nrr)rIrrr8sz(CoroutineTest.test_await_10.<locals>.foor�)r<r)rr8r)rIr�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)NrgrrrrrrIsz(CoroutineTest.test_await_11.<locals>.barc�s���IdHd�S)N)r�rr)rIr�rrr8 sz(CoroutineTest.test_await_11.<locals>.fooc�s��IdHdfS)Nr�rr)rIrrr�#sz)CoroutineTest.test_await_11.<locals>.foo2)rgr�)r<r)rr8r�r)rIr�r�
test_await_11s
zCoroutineTest.test_await_11c	sZdd�}|��G�fdd�d���fdd�}|�td��t|��WdQRX���dS)Nc�sdS)Nrgrrrrrr)sz)CoroutineTest.test_await_12.<locals>.corocseZdZ�fdd�ZdS)z.CoroutineTest.test_await_12.<locals>.Awaitablecs�S)Nr)r)rrrr
.sz8CoroutineTest.test_await_12.<locals>.Awaitable.__await__N)rrr
r
r)rrrr�-sr�c�s��IdHS)Nrr)r�rrr81sz(CoroutineTest.test_await_12.<locals>.fooz"__await__\(\) returned a coroutine)rQrXrrV)rrr8r)r�rr�
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�rrr8?sz(CoroutineTest.test_await_13.<locals>.fooz(__await__.*returned non-iterator of type)rQrXr)rr8r)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|jtjkst�||_dS)N)rrrrr)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)rmr)r�r�rr�coro1Wsz*CoroutineTest.test_await_14.<locals>.coro1c�s����IdHS)Nrr)r�r�rr�coro2\sz*CoroutineTest.test_await_14.<locals>.coro2rg)r�rrQrr.rrrm)rr�rr)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�rrrcnsz.CoroutineTest.test_await_15.<locals>.coroutinec�s|IdHdS)Nr)rrrr�waiterqsz+CoroutineTest.test_await_15.<locals>.waiterz"coroutine is being awaited already)rrcrrQrR)rrcr�rr)r�r�
test_await_15is
zCoroutineTest.test_await_15cs2dd���fdd�}t|��\}}|�|j�dS)Nc�st�S)N)r{rrrrrO~sz&CoroutineTest.test_await_16.<locals>.fc�s yt�Wn��IdHSdS)N)�KeyErrorr)rOrrrz�sz&CoroutineTest.test_await_16.<locals>.g)rr��__context__)rrzrjrr)rOr�
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�)rnr�)r�rrr8�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�)rnr)r�rrr8�s$)rr<r.rm)rr8rOrrjr)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�rrr8�sz&CoroutineTest.test_with_2.<locals>.foor�)rQ�AttributeErrorr)rr8r)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�rrr8�sz&CoroutineTest.test_with_3.<locals>.foor�)rQr�r)rr8r)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�rrr8�sz&CoroutineTest.test_with_4.<locals>.foor�)rQr�r)rr8r)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
�s0��4IdH�ddkst�WdQIdHRXdS)N)rr)rr)r�rrrt�sz'CoroutineTest.test_with_5.<locals>.func)r.rr)rrtr)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�rrr8�sz&CoroutineTest.test_with_6.<locals>.foozV'async with' received an object from __aenter__ that does not implement __await__: int)rQrXr)rr8r)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�rrr8sz&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)	rrXrTrr=r��
isinstancerm�fail)rr8r�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��CNTrrr8$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)r9)r")r�r�rrr80src�s@x:td�D].}��4IdH��d7�w
WdQIdHRXq
WdS)Nrr)r9)r")r�r�rrr8>sr�c
�s,��4IdH��d7�dSQIdHRXdS)Nrrr)r�r�rrr8Ls�)rQrXrr<)rr8r)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�rrr8csz&CoroutineTest.test_with_9.<locals>.foor)r.rmrr<)rr8r)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)rRr)r�r�rrr8wsz'CoroutineTest.test_with_10.<locals>.fooz*exception from __aexit__ did not propagate)rrmr=r�r�rRr�)rr8r�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)rRr)r�r�rrr8�sz'CoroutineTest.test_with_11.<locals>.fooz+exception from __aenter__ did not propagate)rr�r=r�r�)rr8r�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)rqrrR)�cm)r�r�rrrr8�sz'CoroutineTest.test_with_12.<locals>.foo)r)rr8r)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�rrr8�sz'CoroutineTest.test_with_13.<locals>.foor)r.rmrr<)rr8r)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)NrrHrl)r"r�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)rlr)rZr"rrrr[�sz,CoroutineTest.test_for_1.<locals>.<listcomp>�cSsg|]}|d�qS)rr)rZr"rrrr[�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>.test2rrl��cSsg|]}|�qSrr)rZr"rrrr[�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)rlr)rZr"rrrr[scSsg|]}|�qSrr)rZr"rrrr[	szwhat?)rr<r9)rr�Zyieldedrjr�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")�tuprrr8sz%CoroutineTest.test_for_2.<locals>.fooz/async for' requires an object.*__aiter__.*tuple)�sys�getrefcountrQrXrr<)r�refs_beforer8r)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")�aiterrrr8#sz%CoroutineTest.test_for_3.<locals>.fooz!that does not implement __anext__)r�r�rQrXrr<)rr�r�r8r)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�rrr8:sz%CoroutineTest.test_for_4.<locals>.fooz7async for' received an invalid object.*__anext__.*tuple)r�r�rQrXrr<)rr�r�r8r)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)NrHr)r"r�)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)Nrlri���i�)r�)r")r�r�r�rrr��s  i��9)r�r�r%r&r'rr<)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)NrrH)r�)r")r�r�rrr8�s z%CoroutineTest.test_for_7.<locals>.foo)r.rmrr<)rr8r)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)NrrH)r�)r")r�r�rrr8�s z%CoroutineTest.test_for_8.<locals>.foor�)r.rmr%r&r'rr<)rr8r)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�)rj)rrrr��s z'CoroutineTest.test_for_11.<locals>.mainz an invalid object from __anext__)rQrXrZ	exceptionrJ�	__cause__rm)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
r"r�r�rrrr�AIter�src	�sDx:�dg�2y3dH}Wn
tk
s0X��|�qYW��dS)Nr�)r�r)r")rrrrrr8�s$z)CoroutineTest.test_for_tuple.<locals>.foor�)r�r]r.rr<)rr8r)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)r"r�r)rrrrr��sz>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__anext__N)rrr
r"r�r�rrrrr�src	�sBx8�d�2y3dH}Wn
tk
s.X��|�q
YW��dS)Nr�)r�r)r")rrrrrr8�s"z2CoroutineTest.test_for_stop_iteration.<locals>.foor�)r�rr.rr<)rr8r)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)r"rrrrOsz$CoroutineTest.test_comp_1.<locals>.fc�s dd��d��d�gD�IdHS)Nc�sg|]}|IdH�qS)Nr)rZrrrrr[	sz?CoroutineTest.test_comp_1.<locals>.run_list.<locals>.<listcomp>r�)rr)rOrr�run_listsz+CoroutineTest.test_comp_1.<locals>.run_listc�s dd��d��d�gD�IdHS)Nc�sh|]}|IdH�qS)Nr)rZrrrr�	<setcomp>sz=CoroutineTest.test_comp_1.<locals>.run_set.<locals>.<setcomp>rrrr)rOrr�run_setsz*CoroutineTest.test_comp_1.<locals>.run_setc�s dd��d��d�gD�IdHS)Nc�si|]}d|IdH�qS)rnNr)rZrrrr�
<dictcomp>sz@CoroutineTest.test_comp_1.<locals>.run_dict1.<locals>.<dictcomp>rrrr)rOrr�	run_dict1sz,CoroutineTest.test_comp_1.<locals>.run_dict1c�s$dd�t�d��d�g�D�IdHS)Nc�si|]\}}|IdH|�qS)Nr)rZr"rrrrrsz@CoroutineTest.test_comp_1.<locals>.run_dict2.<locals>.<dictcomp>rr)�	enumerater)rOrr�	run_dict2sz,CoroutineTest.test_comp_1.<locals>.run_dict2rrrn)rr)rr)r<r)rrrrrr)rOr�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)r"rrrrOsz$CoroutineTest.test_comp_2.<locals>.fc�s0dd��d��d��d��ddg�gD�IdHS)Nc�s g|]}|IdHD]}|�qqS)Nr)rZr�srrrr[sz?CoroutineTest.test_comp_2.<locals>.run_list.<locals>.<listcomp>��abc�de�fgrr)rOrrrsz+CoroutineTest.test_comp_2.<locals>.run_listrnr�rrrc�s,dd���ddg��dg�g�gD�IdHS)Nc�s0h|](}|IdHD]}|IdHD]}|�q qqS)Nr)rZrr�drrrr
&sz=CoroutineTest.test_comp_2.<locals>.run_set.<locals>.<setcomp>rH�r�rr)rOrrr%sz*CoroutineTest.test_comp_2.<locals>.run_setrHr�rc�s&dd���d��d�g�gD�IdHS)Nc�s&h|]}|IdHD]}|IdH�qqS)Nr)rZrrrrrr
1sz>CoroutineTest.test_comp_2.<locals>.run_set2.<locals>.<setcomp>rHr�rr)rOrr�run_set20sz+CoroutineTest.test_comp_2.<locals>.run_set2)r<r)rrrrr)rOr�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�r"rrrrO:s
z$CoroutineTest.test_comp_3.<locals>.fc�sdd��ddg�2�IdHS)Nc
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nr)r�)rZr"rrrr[?sz?CoroutineTest.test_comp_3.<locals>.run_list.<locals>.<listcomp>rHr�rr)rOrrr>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�)rZr"rrrr
Esz=CoroutineTest.test_comp_3.<locals>.run_set.<locals>.<setcomp>rHr�rr)rOrrrDsz*CoroutineTest.test_comp_3.<locals>.run_setc�sdd��ddg�2�IdHS)Nc
�s8i|y3dH}Wn
tk
s,X|d|d�qYS)Nrr)r�)rZr"rrrrKsz?CoroutineTest.test_comp_3.<locals>.run_dict.<locals>.<dictcomp>rHr�rr)rOrr�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�)rZr"rrr�	<genexpr>Qs
z=CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<genexpr>rHr�c
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nrl)r�)rZrzrrrr[Rsz>CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<listcomp>r)rC)rOrr�run_genPsz*CoroutineTest.test_comp_3.<locals>.run_gen�o�y)r<r)rrrrr!r)rOr�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�r"rrrrOXs
z$CoroutineTest.test_comp_4.<locals>.fc�sdd��ddg�2�IdHS)Nc
�s:g|y3dH}Wn
tk
s.X|dkr|d�qYS)NrHr)r�)rZr"rrrr[]sz?CoroutineTest.test_comp_4.<locals>.run_list.<locals>.<listcomp>rHr�rr)rOrrr\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)NrHr)r�)rZr"rrrr
csz=CoroutineTest.test_comp_4.<locals>.run_set.<locals>.<setcomp>rHr�rr)rOrrrbsz*CoroutineTest.test_comp_4.<locals>.run_setc�sdd��ddg�2�IdHS)Nc
�s@i|y3dH}Wn
tk
s4X|dkr|d|d�qYS)NrHrr)r�)rZr"rrrrisz?CoroutineTest.test_comp_4.<locals>.run_dict.<locals>.<dictcomp>rHr�rr)rOrrrhsz+CoroutineTest.test_comp_4.<locals>.run_dictrc�s*dd��ddg�2�}dd�|2�IdHS)Nc	Ss<|y3dH}Wn
tk
s.X|dkr|dVqYdS)NrHr)r�)rZr"rrrr os
z=CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<genexpr>rHr�c
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nrl)r�)rZrzrrrr[psz>CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<listcomp>r)rC)rOrrr!nsz*CoroutineTest.test_comp_4.<locals>.run_genr#)r<r)rrrrr!r)rOr�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�r"rrrrOvs
z&CoroutineTest.test_comp_4_2.<locals>.fc�sdd��td��2�IdHS)Nc
�sJg|y3dH}Wn
tk
s>Xd|kr0dkrnq|d�qYS)Nrr�rH)r�)rZr"rrrr[{szACoroutineTest.test_comp_4_2.<locals>.run_list.<locals>.<listcomp>�)r9r)rOrrrzsz-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�rH)r�)rZr"rrrr
�sz?CoroutineTest.test_comp_4_2.<locals>.run_set.<locals>.<setcomp>r&)r9r)rOrrr�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�rlrH)r�)rZr"rrrr�szACoroutineTest.test_comp_4_2.<locals>.run_dict.<locals>.<dictcomp>r&)r9r)rOrrr�sz-CoroutineTest.test_comp_4_2.<locals>.run_dictr�rp�g)r�rr'c�s*dd��td��2�}dd�|2�IdHS)Nc	SsL|y3dH}Wn
tk
s>Xd|kr.dkrnq|dVqYdS)Nrr�rH)r�)rZr"rrrr �s
z?CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<genexpr>r&c
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nrl)r�)rZrzrrrr[�sz@CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<listcomp>)r9)rC)rOrrr!�sz,CoroutineTest.test_comp_4_2.<locals>.run_genr"�p�q)r<r)rrrrr!r)rOr�
test_comp_4_2us"zCoroutineTest.test_comp_4_2cs0dd���fdd�}|�t|��gdgf�dS)NcSsx|D]
}|VqWdS)Nr)r�r"rrrrO�s
z$CoroutineTest.test_comp_5.<locals>.fc�s$�fdd�ddgddgfD�IdHS)Nc�sTg|]L}|ddkr�|�2y3dH}Wn
tk
sFX|dkr|d�qYqS)rrHNrr)r�)rZZpairr")rOrrr[�sz?CoroutineTest.test_comp_5.<locals>.run_list.<locals>.<listcomp>rHr�r�(rr)rOrrr�sz+CoroutineTest.test_comp_5.<locals>.run_listr)r<r)rrr)rOr�test_comp_5�s
zCoroutineTest.test_comp_5cs4dd���fdd�}|�t|��gdddgf�dS)NcSsx|D]
}|VqWdS)Nr)r�r"rrrrO�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�)rZ�seqr"rrrr[�sz?CoroutineTest.test_comp_6.<locals>.run_list.<locals>.<listcomp>)rHr�)rrr)rOrrr�sz+CoroutineTest.test_comp_6.<locals>.run_listr�r��)r<r)rrr)rOr�test_comp_6�s
zCoroutineTest.test_comp_6c	s:dd���fdd�}|�td��t|��WdQRXdS)NcSsdVdVtd��dS)Nrr�aaa)r�rrrrrO�sz$CoroutineTest.test_comp_7.<locals>.fc�sdd���2�IdHS)Nc
�s.g|y3dH}Wn
tk
s"X|�qYS)N)r�)rZr"rrrr[�sz?CoroutineTest.test_comp_7.<locals>.run_list.<locals>.<listcomp>rr)rOrrr�sz+CoroutineTest.test_comp_7.<locals>.run_listr1)rQr�r)rrr)rOr�test_comp_7�szCoroutineTest.test_comp_7cCs(dd�}|�t|��gdddgf�dS)Nc�sdd�dD�S)NcSsg|]}|�qSrr)rZr"rrrr[�sz8CoroutineTest.test_comp_8.<locals>.f.<locals>.<listcomp>)rrr�rrrrrrO�sz$CoroutineTest.test_comp_8.<locals>.frrr�)r<r)rrOrrr�test_comp_8�szCoroutineTest.test_comp_8cs2dd���fdd�}|�t|��gddgf�dS)NcSsdVdVdS)NrrrrrrrrC�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�)rZr"rrrr[�sz8CoroutineTest.test_comp_9.<locals>.f.<locals>.<listcomp>cSsg|]}|�qSrr)rZr"rrrr[�sr)�l)rCrrrO�sz$CoroutineTest.test_comp_9.<locals>.frr)r<r)rrOr)rCr�test_comp_9�s
zCoroutineTest.test_comp_9cCs*dd�}|�t|��gdddd�f�dS)Nc�sdd�dD�}dd�|D�S)NcSsh|]}|�qSrr)rZr"rrrr
�sz8CoroutineTest.test_comp_10.<locals>.f.<locals>.<setcomp>)rrr�cSsi|]
}||�qSrr)rZ�xrrrr�sz9CoroutineTest.test_comp_10.<locals>.f.<locals>.<dictcomp>r)ZxxrrrrO�sz%CoroutineTest.test_comp_10.<locals>.frrr�)rrr�)r<r)rrOrrr�test_comp_10�szCoroutineTest.test_comp_10c	Csjdd�}|�}|�t��t�|�WdQRX|��}z$|�t��t�|�WdQRXWd|��XdS)Nc�sdS)Nrrrrrrt�rDz%CoroutineTest.test_copy.<locals>.func)r.rX�copyr
rV)rrtrr!rrr�	test_copy�szCoroutineTest.test_copyc
Cs�dd�}|�}x>ttjd�D],}|�ttjf��t�||�WdQRXqW|��}zDx>ttjd�D],}|�ttjf��t�||�WdQRXqhWWd|��XdS)Nc�sdS)Nrrrrrrt�rDz'CoroutineTest.test_pickle.<locals>.funcr)	r9�pickleZHIGHEST_PROTOCOLr.rXZ
PicklingError�dumpsr
rV)rrtr�protor!rrr�test_pickle�szCoroutineTest.test_picklec
Cs\dd�}t���2t���}t�d�|�t��WdQRXWdQRX|�d|���dS)Nc�sdS)Nrrrrrrt�rDz3CoroutineTest.test_fatal_coro_warning.<locals>.funcr�zwas never awaited)r%r&r�captured_stderr�filterwarningsr(rv�getvalue)rrt�stderrrrr�test_fatal_coro_warning�s
z%CoroutineTest.test_fatal_coro_warningN)Prrr
rGrPrSrWrardrerfrhrkrsrxr|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�r�rrrr	r
rrr$r%r+r-r0r2r3r5r7r9r=rBrrrrrB�s�	#
	(	


"(@H\ 
	
rBc@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�MyExceptionsrEcs(eZdZ��fdd�Z��fdd�ZdS)z0CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CMc�s(��d���d�IdH��d�|S)Nrg{�G�z�?r)r�sleep)r)rDrrrr�s

z;CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aenter__c�s ��d�IdH��|j�dS)Ng{�G�z�?)rFrr)r�exc_typeZexc_valZexc_tb)rDrrrr�sz:CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aexit__N)rrr
r�r�r)rDrrrr�sr�c
�sB��4IdH�}��d�IdH��WdQIdHRX��d�dS)Ng{�G�z�?Zunreachable)rFr)r)r�rErDrrrrOsz/CoroAsyncIOCompatTest.test_asyncio_1.<locals>.frr)r�
import_moduler�Znew_event_loopZset_event_loopZrun_until_completerVr<)rrOZloopr)r�rErDrr�test_asyncio_1�s


z$CoroAsyncIOCompatTest.test_asyncio_1N)rrr
rIrrrrrC�srCc@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)Nrgrrrrrr8(sz5SysSetCoroWrapperTest.test_set_wrapper_1.<locals>.foocs|�|S)Nr)rC)�wrappedrrr�,sz6SysSetCoroWrapperTest.test_set_wrapper_1.<locals>.wraprg)�assertWarns�DeprecationWarningr�r��get_coroutine_wrapper�set_coroutine_wrapperrqr=r<rrVrE)rr8r�rOrr)rKr�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)rLrMr�r�rNrQrXrO)rrrr�test_set_wrapper_2Jsz(SysSetCoroWrapperTest.test_set_wrapper_2cCs�dd�}dd�}|�t��t�|�WdQRXz4t��$|�td��|�WdQRXWdQRXWd|�t��t�d�WdQRXXdS)Nc�sdS)Nrgrrrrrr8Tsz5SysSetCoroWrapperTest.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 .*)rLrMr�rOr)rQrR)rr8rRrrr�test_set_wrapper_3Ssz(SysSetCoroWrapperTest.test_set_wrapper_3cs~tjdd��}d��fdd�}|�t��t�|�WdQRXz|�|��dd�Wd|�t��t�d�WdQRXXdS)NcSsdS)Nrgrrrrrr8ksz5SysSetCoroWrapperTest.test_set_wrapper_4.<locals>.foocs|�|S)Nr)rC)rKrrr�psz6SysSetCoroWrapperTest.test_set_wrapper_4.<locals>.wrapzCgenerator-based coroutine was wrapped via sys.set_coroutine_wrapper)rrcrLrMr�rOrq)rr8r�r)rKr�test_set_wrapper_4js
z(SysSetCoroWrapperTest.test_set_wrapper_4N)rrr
rPrQrSrTrrrrrJ%s#	rJc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�OriginTrackingTestcCst�t��j�}|j|jfS)N)r>Z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)rZr)r[rrr�nested�sz7OriginTrackingTest.test_origin_tracking.<locals>.nestedr]i����)
r��#get_coroutine_origin_tracking_depth�#set_coroutine_origin_tracking_depthr<�
contextlib�closingr��	cr_originrZr=rr.r{)r�
orig_depthrZfnamerXr]Znested_fnameZ
nested_linenor)r[rrr\�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)Nrrrrrr[�sz?OriginTrackingTest.test_origin_tracking_warning.<locals>.corofncs��S)Nrr)r[rr�a1�sz;OriginTrackingTest.test_origin_tracking_warning.<locals>.a1rcs��S)Nrr)rerr�a2�sz;OriginTrackingTest.test_origin_tracking_warning.<locals>.a2c	sDt�|���t��}��t��WdQRX��|t|j��dS)N)	r�r`rLrirr(r<�strZwarning)�depth�msgr�)rfrrrr`�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
)rZr�r_r
r;r`)rZa1_filenameZ	a1_linenoZa2_filenameZ	a2_linenor`rdrir)rerfr[rr�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)Nrrrrrr[�szLOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.corofncSsddS)Nrrr)rrrrrY�rDzNOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.<lambda>zException ignored inrmzwas never awaited)r%�_warn_unawaited_coroutinerr>r(rvr@)rr[Zorig_wuc�streamrrr�)test_unawaited_warning_when_module_broken�s 


z<OriginTrackingTest.test_unawaited_warning_when_module_brokenN)rrr
rZr\rjrmrrrrrU�s.*rUc@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
rorrrrrn�srnc@s$eZdZdd�Zdd�Zdd�ZdS)�CAPITestcs0ddlm��fdd�}|�|��d�d�dS)Nr)�	awaitTypec�s�tdg��}|IdHS)Nr)r_)�future)�atrrr8	sz%CAPITest.test_tp_await_1.<locals>.foor)�	_testcapirqr<r)rr8r)rsr�test_tp_await_1	szCAPITest.test_tp_await_1cCs2ddlm}|tdg��}|�t|���d�dS)Nr)rqr)rtrqr_r<r r
)rrsrrrrr�test_tp_await_2	szCAPITest.test_tp_await_2c	sHddlm��fdd�}|�td��|�|��d�d�WdQRXdS)Nr)rqc�s�d�}|IdHS)Nrr)rr)rsrrr8#	sz%CAPITest.test_tp_await_3.<locals>.fooz.__await__.*returned non-iterator of type 'int'r)rtrqrQrXr<r)rr8r)rsr�test_tp_await_3 	s

zCAPITest.test_tp_await_3N)rrr
rurvrwrrrrrp	s	rp�__main__)rar8r>r:�rer�rZunittestr%ZtestrZtest.support.script_helperrrrrr#�contextmanagerr)ZTestCaser*r6rBrCrJrUrnZcpython_onlyrprr�rrrr�<module>sR*]x