Your IP : 216.73.216.213


Current Path : /opt/alt/python36/lib64/python3.6/test/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/test/__pycache__/test_coroutines.cpython-36.pyc

3

� fW��@sddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	Gdd�d�Z
Gdd�d�Zdd�Zd	d
�Z
ejdd��ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Ze	jGdd�dej��Zedk�r
ej�dS)�N)�supportc@seZdZdd�Zdd�ZdS)�AsyncYieldFromcCs
||_dS)N)�obj)�selfr�r�9/opt/alt/python36/lib64/python3.6/test/test_coroutines.py�__init__
szAsyncYieldFrom.__init__ccs|jEdHdS)N)r)rrrr�	__await__szAsyncYieldFrom.__await__N)�__name__�
__module__�__qualname__rr	rrrrrsrc@seZdZdd�Zdd�ZdS)�
AsyncYieldcCs
||_dS)N)�value)rrrrrrszAsyncYield.__init__ccs|jVdS)N)r)rrrrr	szAsyncYield.__await__N)r
rrrr	rrrrr
sr
cCsz|jtjtjhkst�g}d}xRy|j|jd��Wq tk
rl}z|jrV|jdnd}PWYdd}~Xq Xq W||fS)Nr)	�	__class__�types�
GeneratorType�
CoroutineType�AssertionError�append�send�
StopIteration�args)�coro�buffer�result�exrrr�	run_asyncsrcCs�|jtjkst�|j�}g}d}d}xry4|dr@|jt|��n|j|jd��|d7}Wq&tk
r�}z|j	r||j	dnd}PWYdd}~Xq&Xq&W||fS)Nr��)
rrrrr	r�nextrrr)r�awrr�irrrr�run_async__await__*sr"c	cs0tj��tjd�dVtj�WdQRXdS)N�ignore)�warnings�catch_warnings�simplefilterr�
gc_collectrrrr�silence_coro_gc=s

r(c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�AsyncBadSyntaxTestc5Cs�ddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5g5}xF|D]>}|j|d6��(|jt��t|d7d8�WdQRXWdQRXqtWdS)9Nz9def 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]
            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
            )�codez<test>�exec)�subTest�assertRaises�SyntaxError�compile)r�samplesr*rrr�test_badsyntax_1Gsp		
z#AsyncBadSyntaxTest.test_badsyntax_1cCsdddddddddd	g	}xH|D]@}|j|d
��*|jtd��t|dd
�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%'await' will become reserved keywordsz<test>r+)r,�assertWarnsRegex�DeprecationWarningr/)rr0r*rrr�test_badsyntax_2is
z#AsyncBadSyntaxTest.test_badsyntax_2cCsD|jt��0tj��tjd�tddd�WdQRXWdQRXdS)N�errorz	async = 1z<test>r+)r-r3r$r%r&r/)rrrr�test_badsyntax_3�s

z#AsyncBadSyntaxTest.test_badsyntax_3cCszdddddg}xf|D]^}|j|d��Hi}tj��tjd�t|||�WdQRX|j|dd	�d
�WdQRXqWdS)Nz�def foo(await):
                async def foo(): pass
                async def foo():
                    pass
                return await + 1
            z�def foo(await):
                async def foo(): pass
                async def foo(): pass
                return await + 1
            z�def foo(await):

                async def foo(): pass

                async def foo(): pass

                return await + 1
            z�def foo(await):
                """spam"""
                async def foo():                     pass
                # 123
                async def foo(): pass
                # 456
                return await + 1
            a:def foo(await):
                def foo(): pass
                def foo(): pass
                async def bar(): return await_
                await_ = await
                try:
                    bar().send(None)
                except StopIteration as ex:
                    return ex.args[0] + 1
            )r*r#�foo�
�)r,r$r%r&r+�assertEqual)rr0r*�locrrr�test_goodsyntax_1�s		



z$AsyncBadSyntaxTest.test_goodsyntax_1N)r
rrr1r4r6r<rrrrr)Es$)r)c@seZdZdd�ZdS)�TokenizerRegrTestcCs�g}x"td�D]}|jdj|d��qWdj|�}i}t|||�|j|d�d�|d7}i}t|||�|j|d�d�|jtj|d��dS)	Ni�zdef i{i}(): return {i})r!�
Zi499i�z
async def foo():
    returnr7)	�ranger�format�joinr+r:�
assertTrue�inspectZiscoroutinefunction)rZbufr!�nsrrr�test_oneline_defs�s
z#TokenizerRegrTest.test_oneline_defsN)r
rrrErrrrr=�sr=c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_d`�Z2dadb�Z3dcdd�Z4dedf�Z5dgdh�Z6didj�Z7dkdl�Z8dmdn�Z9dodp�Z:dqdr�Z;dsdt�Z<dudv�Z=dwdx�Z>dydz�Z?d{d|�Z@d}d~�ZAdd��ZBd�d��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�S)��
CoroutineTestcCsdd�}|jt|d��dS)Ncss
dVdS)Nrrrrr�gen�sz%CoroutineTest.test_gen_1.<locals>.genr	)�assertFalse�hasattr)rrGrrr�
test_gen_1�szCoroutineTest.test_gen_1cCs�dd�}|�}|j|tj�|jt|jjtj@��|j	t|jjtj
@��|jt|jjtj@��|j	t|jjtj
@��|jt
|�gdf�|jt|��gdf�dd�}|j	t|jjtj@��dS)Nc�sdS)Nr8rrrrrr7�sz&CoroutineTest.test_func_1.<locals>.foor8cSsdS)Nrrrrr�bar�sz&CoroutineTest.test_func_1.<locals>.bar)�assertIsInstancerrrB�bool�__code__�co_flagsrCZCO_COROUTINErHZCO_GENERATOR�cr_coder:rr")rr7�frKrrr�test_func_1�szCoroutineTest.test_func_1c	Cs.dd�}|jtd��t|��WdQRXdS)Nc�st�dS)N)rrrrrr7sz&CoroutineTest.test_func_2.<locals>.foozcoroutine raised StopIteration)�assertRaisesRegex�RuntimeErrorr)rr7rrr�test_func_2s
zCoroutineTest.test_func_2c
Cs0dd�}t��|jt|��d�WdQRXdS)Nc�st�dS)N)rrrrrr7
sz&CoroutineTest.test_func_3.<locals>.fooz^<coroutine object.* at 0x.*>$)r(�assertRegex�repr)rr7rrr�test_func_3	szCoroutineTest.test_func_3c:s�dd�}�fdd�}|��t|��WdQRX|��t|��WdQRX|��t|��WdQRX|��t|��WdQRXt��(|��x|�D]}q�WWdQRXWdQRXt��(|��dd�|�D�WdQRXWdQRXdS)Nc�st�dS)N)rrrrrr7sz&CoroutineTest.test_func_4.<locals>.foocs�jtd�S)Nz"'coroutine' object is not iterable)rS�	TypeErrorr)rrr�<lambda>sz+CoroutineTest.test_func_4.<locals>.<lambda>cSsg|]}|�qSrr)�.0r!rrr�
<listcomp>(sz-CoroutineTest.test_func_4.<locals>.<listcomp>)�list�tuple�sum�iterr()rr7�checkr!r)rr�test_func_4szCoroutineTest.test_func_4cs�tjdd����fdd�}�fdd�}|��x|�D]}q6WWdQRXx��D]}�j|d�qPW�jdd	���D�dg��jt���d
��jtt����d�dS)Ncss
dVdS)NrrrrrrrK+sz&CoroutineTest.test_func_5.<locals>.barc�s��IdHdS)Nrr)rKrrr7/sz&CoroutineTest.test_func_5.<locals>.foocs�jtd�S)Nz"'coroutine' object is not iterable)rSrYr)rrrrZ2sz+CoroutineTest.test_func_5.<locals>.<lambda>rcSsg|]}|�qSrr)r[�elrrrr\;sz-CoroutineTest.test_func_5.<locals>.<listcomp>)r)r�	coroutiner:r^rr`)rr7rarcr)rKrr�test_func_5*szCoroutineTest.test_func_5c	shtjdd����fdd�}|�}|j|jd�d�|j|jd�d�|jt��|jd�WdQRXdS)NcssdVdVdS)NrrrrrrrrK@sz&CoroutineTest.test_func_6.<locals>.barc�s��IdHdS)Nrr)rKrrr7Esz&CoroutineTest.test_func_6.<locals>.foorr)rrdr:rr-r)rr7rQr)rKr�test_func_6?szCoroutineTest.test_func_6csLdd���fdd�}t��(|jtd��t|��WdQRXWdQRXdS)Nc�sdS)Nr8rrrrrrKOsz&CoroutineTest.test_func_7.<locals>.barc3s��EdHdS)Nrr)rKrrr7Rsz&CoroutineTest.test_func_7.<locals>.foozCcannot 'yield from' a coroutine object in a non-coroutine generator)r(rSrYr])rr7r)rKr�test_func_7NszCoroutineTest.test_func_7cs4tj�fdd��}dd��|jt|��gdf�dS)Nc3s��EdHS)Nrr)r7rrrK\sz&CoroutineTest.test_func_8.<locals>.barc�sdS)N�spamrrrrrr7`sz&CoroutineTest.test_func_8.<locals>.foorh)rrdr:r)rrKr)r7r�test_func_8[szCoroutineTest.test_func_8c	Cs2dd�}|jtd��|�tj�WdQRXdS)Nc�sdS)Nrrrrrr7fsz&CoroutineTest.test_func_9.<locals>.fooz0coroutine '.*test_func_9.*foo' was never awaited)r2�RuntimeWarningrr')rr7rrr�test_func_9es

zCoroutineTest.test_func_9cs�d�tj�fdd����fdd�}|�}|j�}|j|t|��t|�|j|jd�d�|j�d�|j�|j�d�|�}|j�}t|�|j	t
��|jt
dd�WdQRX|j�d	�dS)
Nrc3sHz8ydV}|dVWntk
r4�d7��YnXWd�d7�XdS)Nr�dr)�ZeroDivisionError)�a)�NrrrGqsz'CoroutineTest.test_func_10.<locals>.genc�s��IdHdS)Nrr)rGrrr7}sz'CoroutineTest.test_func_10.<locals>.foor8rlr�f)rrdr	�assertIsr`rr:r�closer-rm�throw)rr7rr r)rorGr�test_func_10ns"zCoroutineTest.test_func_10cCsRdd�}|�}|jdt|��|jdt|j���|jdt|j���|j�dS)Nc�sdS)Nrrrrr�func�sz(CoroutineTest.test_func_11.<locals>.funcr	�__iter__Zcoroutine_wrapper)�assertIn�dirr	rWrr)rrurrrr�test_func_11�szCoroutineTest.test_func_11c	s8�fdd�}|��|jtd���jd�WdQRXdS)Nc�s�jd�}tIdHdS)N)rr7)r!)�merr�g�s
z%CoroutineTest.test_func_12.<locals>.gzcoroutine already executing)rS�
ValueErrorr)rr{r)rzr�test_func_12�s
zCoroutineTest.test_func_12c	Cs0dd�}|jtd��|�jd�WdQRXdS)Nc�sdS)Nrrrrrr{�sz%CoroutineTest.test_func_13.<locals>.gz5can't send non-None value to a just-started coroutinerh)rSrYr)rr{rrr�test_func_13�s
zCoroutineTest.test_func_13c	sNtjdd����fdd�}|�}|jd�|jtd��|j�WdQRXdS)Ncss
dVdS)NrrrrrrG�sz'CoroutineTest.test_func_14.<locals>.genc�s6y��IdHWn tk
r0��IdHYnXdS)N)�
GeneratorExitr)rGrrr�sz(CoroutineTest.test_func_14.<locals>.corozcoroutine ignored GeneratorExit)rrdrrSrTrr)rr�cr)rGr�test_func_14�s
zCoroutineTest.test_func_14cCsfdd�}dd�}|�}|jtd��||�jd�WdQRX|jtd��||�jd�WdQRXdS)Nc�sdS)Nrhrrrrr�spammer�sz+CoroutineTest.test_func_15.<locals>.spammerc�s
|IdHS)Nr)rrrr�reader�sz*CoroutineTest.test_func_15.<locals>.readerrhz&cannot reuse already awaited coroutine)rSrrrT)rr�r�Zspammer_cororrr�test_func_15�szCoroutineTest.test_func_15cs�tjdd����fdd�}�fdd�}|�}||�}|jd�|jd�|jtd��|jtd��WdQRX||�}|jd�|jtd��|jd�WdQRX|jtd��|jtd	��WdQRXdS)
Ncss
dVdS)Nrrrrr�nop�sz'CoroutineTest.test_func_16.<locals>.nopc�s��IdHdS)Nrhrr)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)rrdrrS�	ExceptionrsrT)rrr�r�r�r)r�r�test_func_16�s"


zCoroutineTest.test_func_16cCs�dd�}|�}|jtd��|jd�WdQRX|jtd��|jd�WdQRX|jtd��|jtd��WdQRX|j�|j�dS)Nc�sdS)Nrhrrrrrrd�sz-CoroutineTest.test_func_17.<locals>.coroutinerhz&cannot reuse already awaited coroutiner�)rSrrrTrsr�rr)rrdrrrr�test_func_17�szCoroutineTest.test_func_17c&Cs�dd�}|�}|j�}t|�}|jtd��|jd�WdQRX|jtd��|jd�WdQRX|jtd��t|�WdQRX|jtd��|jtd��WdQRX|jtd��|jtd��WdQRX|j	�|j	�dS)Nc�sdS)Nrhrrrrrrdsz-CoroutineTest.test_func_18.<locals>.coroutinerhz&cannot reuse already awaited coroutiner�)
r	r`rSrrrTrrsr�rr)rrdrZ
await_iter�itrrr�test_func_18s(zCoroutineTest.test_func_18cs�d�tj�fdd����fdd�}|�}|jd�|jd�|j�d�|j�|j�d�x$td�D]}|j�|j�d�qfWdS)Nrc3s2dVy
dVWntk
r,�d7�YnXdS)Nr)rr)�CHKrrr7.s

z'CoroutineTest.test_func_19.<locals>.fooc�s��IdHdS)Nrr)r7rrrd7sz-CoroutineTest.test_func_19.<locals>.coroutiner�)rrdrr:rrr?)rrdr�_r)r�r7r�test_func_19+s	

zCoroutineTest.test_func_19cCs&dd�}t|��}|j|gdf�dS)Nc�sdS)Nr8)r8rrrrrr7Jsz7CoroutineTest.test_coro_wrapper_send_tuple.<locals>.foor8)r8)r"r:)rr7rrrr�test_coro_wrapper_send_tupleIs
z*CoroutineTest.test_coro_wrapper_send_tuplecCs8dd�}t|��}|j|dt�|j|djd�dS)Nc�std�S)Nr8)rrrrrr7Qsz?CoroutineTest.test_coro_wrapper_send_stop_iterator.<locals>.foorr8)r"rLrr:r)rr7rrrr�$test_coro_wrapper_send_stop_iteratorPs
z2CoroutineTest.test_coro_wrapper_send_stop_iteratorc
s�tj��fdd����fdd�����fdd�}|���jtj��tj��j�j��jd��jtj��tj	��j�jjj
jd��jt
���jd�WdQRX�jtj��tj��j�j�dS)Nc3sJ�jtj��tj��j�j�dV�jtj��tj��j�j�dS)N)r:rC�getcoroutinestateZCORO_RUNNING�assertIsNone�cr_awaitr)�coro_brrrrnYs
z&CoroutineTest.test_cr_await.<locals>.ac�s��IdHdS)Nrr)rnrrr�asz&CoroutineTest.test_cr_await.<locals>.cc�s(�j�j���IdH�j�j�dS)N)r�r�r)r�r�rrr�bdsz&CoroutineTest.test_cr_await.<locals>.brn)rrdr:rCr�ZCORO_CREATEDr�r�rZCORO_SUSPENDED�gi_code�co_namer-rZCORO_CLOSED)rr�r)rnr�r�rr�
test_cr_awaitXs
zCoroutineTest.test_cr_awaitcCs�tj}|jd|jj�|jd|jj�|jd|jj�|jd|jdj�|jd|jdj�|j|j	d�dd	�}|�}|jd
t
|��|j�dS)Nzinto coroutinezinside coroutinezin coroutinezof the coroutiner
rrdc�sdS)NrrrrrrQsz(CoroutineTest.test_corotype_1.<locals>.fzcoroutine object)rrrwr�__doc__rrrs�__dict__r:r
rW)rZctrQr�rrr�test_corotype_1vszCoroutineTest.test_corotype_1c	Cs.dd�}|jtd��t|��WdQRXdS)Nc�sdIdHdS)Nrrrrrrr7�sz'CoroutineTest.test_await_1.<locals>.foozobject int can.t.*await)rSrYr)rr7rrr�test_await_1�szCoroutineTest.test_await_1c	Cs.dd�}|jtd��t|��WdQRXdS)Nc�sgIdHdS)Nrrrrrr7�sz'CoroutineTest.test_await_2.<locals>.foozobject list can.t.*await)rSrYr)rr7rrr�test_await_2�szCoroutineTest.test_await_2cCsDdd�}|jt|��dddgdf�|jt|��dddgdf�dS)Nc�stdddg�IdHdS)Nrrr�)rrrrrr7�sz'CoroutineTest.test_await_3.<locals>.foorrr�)r:rr")rr7rrr�test_await_3�szCoroutineTest.test_await_3cs.dd���fdd�}|jt|��gdf�dS)Nc�sdS)N�*rrrrrrK�sz'CoroutineTest.test_await_4.<locals>.barc�s��IdHS)Nrr)rKrrr7�sz'CoroutineTest.test_await_4.<locals>.foor�)r:r)rr7r)rKr�test_await_4�szCoroutineTest.test_await_4c	s@Gdd�d���fdd�}|jtd��t|��WdQRXdS)Nc@seZdZdd�ZdS)z-CoroutineTest.test_await_5.<locals>.AwaitablecSsdS)Nr)rrrrr	�sz7CoroutineTest.test_await_5.<locals>.Awaitable.__await__N)r
rrr	rrrr�	Awaitable�sr�c�s��IdHS)Nrr)r�rrr7�sz'CoroutineTest.test_await_5.<locals>.fooz(__await__.*returned non-iterator of type)rSrYr)rr7r)r�r�test_await_5�s

zCoroutineTest.test_await_5cs6Gdd�d���fdd�}|jt|��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)r
rrr	rrrrr��sr�c�s��IdHS)Nrr)r�rrr7�sz'CoroutineTest.test_await_6.<locals>.foor�)r:r)rr7r)r�r�test_await_6�szCoroutineTest.test_await_6cs6Gdd�d���fdd�}|jt|��dgdf�dS)Nc@seZdZdd�ZdS)z-CoroutineTest.test_await_7.<locals>.Awaitablecss
dVdS)Nr�rlr)rrrrr	�sz7CoroutineTest.test_await_7.<locals>.Awaitable.__await__N)r
rrr	rrrrr��sr�c�s��IdHS)Nrr)r�rrr7�sz'CoroutineTest.test_await_7.<locals>.foor�rl)r:r)rr7r)r�r�test_await_7�szCoroutineTest.test_await_7c	s@Gdd�d���fdd�}|jtd��t|��WdQRXdS)Nc@seZdZdS)z-CoroutineTest.test_await_8.<locals>.AwaitableN)r
rrrrrrr��sr�c�s��IdHS)Nrr)r�rrr7�sz'CoroutineTest.test_await_8.<locals>.fooz4object Awaitable can't be used in 'await' expression)rSrYr)rr7r)r�r�test_await_8�s

zCoroutineTest.test_await_8cs^�fdd��dd����fdd�}�fdd�}|jt|��gd	f�|jt|��gdf�dS)Ncs�S)Nrr)rKrr�wrap�sz(CoroutineTest.test_await_9.<locals>.wrapc�sdS)Nr�rrrrrrK�sz'CoroutineTest.test_await_9.<locals>.barc�sv��}d�fdd�i}G�fdd�d�}��IdH���IdH|d���IdH��IdHd|j��IdHS)Nr�cs�S)Nrr)r�rrrZ�sz9CoroutineTest.test_await_9.<locals>.foo.<locals>.<lambda>cseZdZ�ZdS)z3CoroutineTest.test_await_9.<locals>.foo.<locals>.DBN)r
rrr�r)r�rr�DB�sr�i�)r�)r�Zdbr�)rKr�rrr7�sz'CoroutineTest.test_await_9.<locals>.fooc�s��IdHS)Nrr)rKrr�foo2�sz(CoroutineTest.test_await_9.<locals>.foo2i��r�i���)r:r)rr7r�r)rKr�r�test_await_9�szCoroutineTest.test_await_9cs:dd���fdd���fdd�}|jt|��gdf�dS)Nc�sdS)Nr�rrrrr�baz�sz(CoroutineTest.test_await_10.<locals>.bazc�s��S)Nrr)r�rrrK�sz(CoroutineTest.test_await_10.<locals>.barc�s��IdHIdHS)Nrr)rKrrr7�sz(CoroutineTest.test_await_10.<locals>.foor�)r:r)rr7r)rKr�r�
test_await_10�szCoroutineTest.test_await_10csDdd��dd����fdd�}�fdd�}|jt|��gdf�dS)NcSs|S)Nr)�valrrr�ident�sz*CoroutineTest.test_await_11.<locals>.identc�sdS)NrhrrrrrrK�sz(CoroutineTest.test_await_11.<locals>.barc�s���IdHd�S)N)r�rr)rKr�rrr7�sz(CoroutineTest.test_await_11.<locals>.fooc�s��IdHdfS)Nr�rr)rKrrr��sz)CoroutineTest.test_await_11.<locals>.foo2rhr�)rhr�)r:r)rr7r�r)rKr�r�
test_await_11�s
zCoroutineTest.test_await_11c	sLdd��G�fdd�d���fdd�}|jtd��t|��WdQRXdS)Nc�sdS)Nrhrrrrrrsz)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)r
rrr	r)rrrr�sr�c�s��IdHS)Nrr)r�rrr7	sz(CoroutineTest.test_await_12.<locals>.fooz"__await__\(\) returned a coroutine)rSrYr)rr7r)r�rr�
test_await_12s
zCoroutineTest.test_await_12c	s@Gdd�d���fdd�}|jtd��t|��WdQRXdS)Nc@seZdZdd�ZdS)z.CoroutineTest.test_await_13.<locals>.AwaitablecSs|S)Nr)rrrrr	sz8CoroutineTest.test_await_13.<locals>.Awaitable.__await__N)r
rrr	rrrrr�sr�c�s��IdHS)Nrr)r�rrr7sz(CoroutineTest.test_await_13.<locals>.fooz(__await__.*returned non-iterator of type)rSrYr)rr7r)r�r�
test_await_13s

zCoroutineTest.test_await_13cs�Gdd�d��Gdd�d��Gdd�dt����fdd����fd	d
�}|�}|jd�|jtd��|jd�WdQRX|�}|jd�|j���|jt�WdQRXdS)Nc@seZdZdd�Zdd�ZdS)z,CoroutineTest.test_await_14.<locals>.WrappercSs|jtjkst�||_dS)N)rrrrr)rrrrrr!sz5CoroutineTest.test_await_14.<locals>.Wrapper.__init__cSs
|jj�S)N)rr	)rrrrr	$sz6CoroutineTest.test_await_14.<locals>.Wrapper.__await__N)r
rrrr	rrrr�Wrappersr�c@seZdZdd�ZdS)z/CoroutineTest.test_await_14.<locals>.FutureLikecssdVS)Nr)rrrrr	(sz9CoroutineTest.test_await_14.<locals>.FutureLike.__await__N)r
rrr	rrrr�
FutureLike'sr�c@seZdZdS)z+CoroutineTest.test_await_14.<locals>.MarkerN)r
rrrrrr�Marker+sr�c�s*y��IdHStk
r$��YnXdS)N)rmr)r�r�rr�coro1.sz*CoroutineTest.test_await_14.<locals>.coro1c�s����IdHS)Nrr)r�r�rr�coro23sz*CoroutineTest.test_await_14.<locals>.coro2rh)r�rrSrr-rsrm)rr�r�r)r�r�r�r�r�
test_await_14s

zCoroutineTest.test_await_14c	s\tjdd����fdd�}dd�}|�}|jd�|jtd��||�jd�WdQRXdS)Ncss
dVdS)Nrrrrrr�Asz(CoroutineTest.test_await_15.<locals>.nopc�s��IdHdS)Nrr)r�rrrdEsz.CoroutineTest.test_await_15.<locals>.coroutinec�s|IdHdS)Nr)rrrr�waiterHsz+CoroutineTest.test_await_15.<locals>.waiterz"coroutine is being awaited already)rrdrrSrT)rrdr�rr)r�r�
test_await_15@s
zCoroutineTest.test_await_15cs2dd���fdd�}t|��\}}|j|j�dS)Nc�st�S)N)r|rrrrrQUsz&CoroutineTest.test_await_16.<locals>.fc	�s yt�Wn��IdHSdS)N)�KeyErrorr)rQrrr{Xsz&CoroutineTest.test_await_16.<locals>.g)rr��__context__)rr{r�rr)rQr�
test_await_16RszCoroutineTest.test_await_16cszGdd�d���fdd�}|�}t|�\}}|j|ddddddd
ddg	��fdd�}|jt��t|��WdQRXdS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)z*CoroutineTest.test_with_1.<locals>.ManagercSs
||_dS)N)�name)rr�rrrrcsz3CoroutineTest.test_with_1.<locals>.Manager.__init__c�s"td|jd|jg�IdH|S)Nzenter-1-zenter-2-)rr�)rrrr�
__aenter__fs
z5CoroutineTest.test_with_1.<locals>.Manager.__aenter__c�s0td|jd|jg�IdH|jdkr,dSdS)Nzexit-1-zexit-2-�BT)rr�)rrrrr�	__aexit__ks

z4CoroutineTest.test_with_1.<locals>.Manager.__aexit__N)r
rrrr�r�rrrr�Managerbsr�c�sj�d�4IdH�J}�d�4IdH�(}td|j|jfg�IdHddWdQIdHRXWdQIdHRXdS)N�Ar��managersrr)rr�)rnr�)r�rrr7ss$z&CoroutineTest.test_with_1.<locals>.fooz	enter-1-Az	enter-2-Az	enter-1-Bz	enter-2-Br�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�rrr7�s$)r�r�r�)rr:r-rm)rr7rQrr�r)r�r�test_with_1as
zCoroutineTest.test_with_1c	s@Gdd�d���fdd�}|jtd��t|��WdQRXdS)Nc@seZdZdd�ZdS)z%CoroutineTest.test_with_2.<locals>.CMcSsdS)Nr)rrrrr��sz0CoroutineTest.test_with_2.<locals>.CM.__aenter__N)r
rrr�rrrr�CM�sr�c
�s$��4IdH�WdQIdHRXdS)Nrr)r�rrr7�sz&CoroutineTest.test_with_2.<locals>.foor�)rS�AttributeErrorr)rr7r)r�r�test_with_2�szCoroutineTest.test_with_2c	s@Gdd�d���fdd�}|jtd��t|��WdQRXdS)Nc@seZdZdd�ZdS)z%CoroutineTest.test_with_3.<locals>.CMcSsdS)Nr)rrrrr��sz/CoroutineTest.test_with_3.<locals>.CM.__aexit__N)r
rrr�rrrrr��sr�c
�s$��4IdH�WdQIdHRXdS)Nrr)r�rrr7�sz&CoroutineTest.test_with_3.<locals>.foor�)rSr�r)rr7r)r�r�test_with_3�szCoroutineTest.test_with_3c	s@Gdd�d���fdd�}|jtd��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)r
rrr�r�rrrrr��sr�c
�s$��4IdH�WdQIdHRXdS)Nrr)r�rrr7�sz&CoroutineTest.test_with_4.<locals>.foor�)rSr�r)rr7r)r�r�test_with_4�szCoroutineTest.test_with_4c	s>Gdd�d���fdd�}|jt��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)r
rrr�r�rrrrr��sr�c
�s0��4IdH�ddkst�WdQIdHRXdS)Nr)r)rr)r�rrru�sz'CoroutineTest.test_with_5.<locals>.func)r-rr)rrur)r�r�test_with_5�szCoroutineTest.test_with_5c	s@Gdd�d���fdd�}|jtd��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)r
rrr�r�rrrrr��sr�c
�s$��4IdH�WdQIdHRXdS)Nrr)r�rrr7�sz&CoroutineTest.test_with_6.<locals>.foozV'async with' received an object from __aenter__ that does not implement __await__: int)rSrYr)rr7r)r�r�test_with_6�szCoroutineTest.test_with_6cs�Gdd�d���fdd�}yt|��WnVtk
r~}z:|j|jdd�|j|jdk	�|jt|jt��WYdd}~XnX|jd�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)r
rrr�r�rrrrr��sr�c
�s,��4IdH�ddWdQIdHRXdS)Nrrrr)r�rrr7�sz&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)	rrYrVrrBr��
isinstancerm�fail)rr7r�r)r�r�test_with_7�s$zCoroutineTest.test_with_7csd�Gdd�d����fdd�}|jtd��t|��WdQRX|j�d���fdd�}|jtd��t|��WdQRX|j�d	���fd
d�}|jtd��t|��WdQRX|j�d���fdd�}|jtd��t|��WdQRX|j�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)r
rrr�r�rrrrr��sr�c
�s,��4IdH��d7�WdQIdHRXdS)Nrrr)r��CNTrrr7�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)r?)r!)r�r�rrr7src�s@x:td�D].}��4IdH��d7�w
WdQIdHRXq
WdS)Nrr)r?)r!)r�r�rrr7sr�c
�s,��4IdH��d7�dSQIdHRXdS)Nrrr)r�r�rrr7#s�)rSrYrr:)rr7r)r�r�r�test_with_8�s4zCoroutineTest.test_with_8c
sPd�Gdd�d����fdd�}|jt��t|��WdQRX|j�d�dS)Nrc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_9.<locals>.CMc�s|S)Nr)rrrrr�4sz0CoroutineTest.test_with_9.<locals>.CM.__aenter__c�sdddS)Nrrr)rr�rrrr�7sz/CoroutineTest.test_with_9.<locals>.CM.__aexit__N)r
rrr�r�rrrrr�3sr�c
�s,��4IdH��d7�WdQIdHRXdS)Nrrr)r�r�rrr7:sz&CoroutineTest.test_with_9.<locals>.foor)r-rmrr:)rr7r)r�r�r�test_with_90szCoroutineTest.test_with_9cs�d�Gdd�d����fdd�}yt|��WnXtk
r�}z<|j|jdk	�|jt|jt��|jt|jjt��WYdd}~XnX|jd�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_10.<locals>.CMc�s|S)Nr)rrrrr�Hsz1CoroutineTest.test_with_10.<locals>.CM.__aenter__c�sdddS)Nrrr)rr�rrrr�Ksz0CoroutineTest.test_with_10.<locals>.CM.__aexit__N)r
rrr�r�rrrrr�Gsr�c�sH��4IdH�*��4IdH�
t�WdQIdHRXWdQIdHRXdS)N)rTr)r�r�rrr7Nsz'CoroutineTest.test_with_10.<locals>.fooz*exception from __aexit__ did not propagate)rrmrBr�r�rTr�)rr7r�r)r�r�r�test_with_10DszCoroutineTest.test_with_10cspd�Gdd�d����fdd�}yt|��Wn2tk
r`}z|j|jdk�WYdd}~XnX|jd�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_11.<locals>.CMc�st�dS)N)�NotImplementedError)rrrrr�bsz1CoroutineTest.test_with_11.<locals>.CM.__aenter__c�sdddS)Nrrr)rr�rrrr�esz0CoroutineTest.test_with_11.<locals>.CM.__aexit__N)r
rrr�r�rrrrr�asr�c
�s(��4IdH�
t�WdQIdHRXdS)N)rTr)r�r�rrr7hsz'CoroutineTest.test_with_11.<locals>.fooz+exception from __aenter__ did not propagate)rr�rBr�r�)rr7r�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�xsz1CoroutineTest.test_with_12.<locals>.CM.__aenter__c�sdS)NTr)rr�rrrr�{sz0CoroutineTest.test_with_12.<locals>.CM.__aexit__N)r
rrr�r�rrrrr�wsr�c
�s6��4IdH�}�j|j��t�WdQIdHRXdS)N)rqrrT)�cm)r�r�rrrr7~sz'CoroutineTest.test_with_12.<locals>.foo)r)rr7r)r�r�rr�test_with_12tszCoroutineTest.test_with_12c
sPd�Gdd�d����fdd�}|jt��t|��WdQRX|j�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)r
rrr�r�rrrrr��sr�c
�s<�d7���4IdH��d7�WdQIdHRX�d7�dS)Nri�i'rr)r�r�rrr7�sz'CoroutineTest.test_with_13.<locals>.foor)r-rmrr:)rr7r)r�r�r�test_with_13�szCoroutineTest.test_with_13csNd�G�fdd�d��g����fdd�}t|��\}}�j�d��j|dd�tdd	�D���j�d
d�tdd�D��g����fdd
�}t|��\}}�j�d��j|ddg��j�dd�tdd�D�dg�g����fdd�}t|��\}}�j�d��j|dd�tdd	�D���j�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__c�s�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)Nrr8rl)r!r
�StopAsyncIteration)rrrr�	__anext__�s

z5CoroutineTest.test_for_1.<locals>.AsyncIter.__anext__N)r
rrrr�r�r)r�rr�	AsyncIter�sr�c�s`�jtd��JxB��2dHy3dH\}}Wn
tk
sFX�j||�qYWWdQRXdS)N�legacy)r2r3r�r)Zi1Zi2)r�rrrr�test1�s(z'CoroutineTest.test_for_1.<locals>.test1rcSsg|]}|d�qS)rlr)r[r!rrrr\�sz,CoroutineTest.test_for_1.<locals>.<listcomp>r9cSsg|]}|d�qS)rr)r[r!rrrr\�s�ec�s~�jtd��^xV��2dHy3dH}Wn
tk
sPX�j|d�|ddkrPqYW�jd�WdQRX�jd�dS)Nr�r�zwhat?�end)r2r3r�r)r!)r�rrrr�test2�s$z'CoroutineTest.test_for_1.<locals>.test2rrl��cSsg|]}|�qSrr)r[r!rrrr\�s�r�c�s~�jtd��^xV��2dHy3dH}Wn
tk
sPX|ddkr@q�j|d�qYW�jd�WdQRX�jd�dS)Nr�rr�zwhat?r�)r2r3r�r)r!)r�rrrr�test3�s$z'CoroutineTest.test_for_1.<locals>.test3r�cSsg|]}|d�qS)rlr)r[r!rrrr\�scSsg|]}|�qSrr)r[r!rrrr\�szwhat?)rr:r?)rr�Zyieldedr�r�r�r)r�r�rrr�
test_for_1�s*"zCoroutineTest.test_for_1c
sRd�tj��}�fdd�}|jtd��t|��WdQRX|jtj��|�dS)Nrrr�c�s<x6�2dHy3dH}Wn
tk
s,Xtd�q
YWdS)Nznever going to happen)r��print)r!)�tuprrr7�s"z%CoroutineTest.test_for_2.<locals>.fooz/async for' requires an object.*__aiter__.*tuple)rrr�)�sys�getrefcountrSrYrr:)r�refs_beforer7r)r�r�
test_for_2�s

zCoroutineTest.test_for_2c
sbGdd�d�}|��tj��}�fdd�}|jtd��t|��WdQRX|jtj��|�dS)Nc@seZdZdd�ZdS)z#CoroutineTest.test_for_3.<locals>.IcSs|S)Nr)rrrrr��sz-CoroutineTest.test_for_3.<locals>.I.__aiter__N)r
rrr�rrrr�I�sr�c�s<x6�2dHy3dH}Wn
tk
s,Xtd�q
YWdS)Nznever going to happen)r�r�)r!)�aiterrrr7�s"z%CoroutineTest.test_for_3.<locals>.fooz4async for' received an invalid object.*__aiter.*\: I)r�r�rSrYrr:)rr�r�r7r)r�r�
test_for_3�s
zCoroutineTest.test_for_3c
sbGdd�d�}|��tj��}�fdd�}|jtd��t|��WdQRX|jtj��|�dS)Nc@seZdZdd�Zdd�ZdS)z#CoroutineTest.test_for_4.<locals>.IcSs|S)Nr)rrrrr�sz-CoroutineTest.test_for_4.<locals>.I.__aiter__cSsfS)Nr)rrrrr�sz-CoroutineTest.test_for_4.<locals>.I.__anext__N)r
rrr�r�rrrrr�
sr�c�s<x6�2dHy3dH}Wn
tk
s,Xtd�q
YWdS)Nznever going to happen)r�r�)r!)r�rrr7s"z%CoroutineTest.test_for_4.<locals>.fooz7async for' received an invalid object.*__anext__.*tuple)r�r�rSrYrr:)rr�r�r7r)r�r�
test_for_4	s
zCoroutineTest.test_for_4c	sBGdd�d����fdd�}�jtd��t|��WdQRXdS)Nc@seZdZdd�Zdd�ZdS)z#CoroutineTest.test_for_5.<locals>.Ic�s|S)Nr)rrrrr�"sz-CoroutineTest.test_for_5.<locals>.I.__aiter__cSsdS)Nr�r)rrrrr�%sz-CoroutineTest.test_for_5.<locals>.I.__anext__N)r
rrr�r�rrrrr�!sr�c�sV�jtd��@x8��2dHy3dH}Wn
tk
s<Xtd�qYWWdQRXdS)Nr�znever going to happen)r2r3r�r�)r!)r�rrrr7(s$z%CoroutineTest.test_for_5.<locals>.fooz3async for' received an invalid object.*__anext.*int)rSrYr)rr7r)r�rr�
test_for_5 szCoroutineTest.test_for_5c
s�d�G�fdd�d��Gdd�d��������tj��}tj��}���fdd�}tj��tjd�t|��WdQRX|j�d	�|jtj��|�|jtj��|����fd
d�}t|��|j�d����fdd�}t|��|j�d
�dS)Nrcs$eZdZ�fdd�Z�fdd�ZdS)z)CoroutineTest.test_for_6.<locals>.Managerc�s�d7�dS)Ni'r)r)r�rrr�7sz4CoroutineTest.test_for_6.<locals>.Manager.__aenter__c�s�d7�dS)Ni��r)rr)r�rrr�;sz3CoroutineTest.test_for_6.<locals>.Manager.__aexit__N)r
rrr�r�r)r�rrr�6sr�c@s$eZdZdd�Zdd�Zdd�ZdS)z*CoroutineTest.test_for_6.<locals>.IterablecSs
d|_dS)Nr)r!)rrrrr@sz3CoroutineTest.test_for_6.<locals>.Iterable.__init__cSs|S)Nr)rrrrr�Csz4CoroutineTest.test_for_6.<locals>.Iterable.__aiter__c�s"|jdkrt�|jd7_|jS)Nr8r)r!r�)rrrrr�Fs
z4CoroutineTest.test_for_6.<locals>.Iterable.__anext__N)r
rrrr�r�rrrr�Iterable?sr�c�sb�4IdH�>x6�2dHy3dH}Wn
tk
s:X�d7�qYWWdQIdHRX�d7�dS)Nri�)r�)r!)r��iterable�managerrr�mainSs"&z&CoroutineTest.test_for_6.<locals>.mainr5i��c �s���4IdH�@x8��2dHy3dH}Wn
tk
s>X�d7�qYWWdQIdHRX�d7���4IdH�@x8��2dHy3dH}Wn
tk
s�X�d7�q~YWWdQIdHRX�d7�dS)Nri�)r�)r!)r�r�r�rrr�gs$&$&i�c �s���4IdH�P�d7�x@��2dHy3dH}Wn
tk
sFX�d7�q$YW�d7�WdQIdHRX�d7���4IdH�P�d7�x@��2dHy3dH}Wn
tk
s�X�d7�q�YW�d7�WdQIdHRX�d7�dS)Nrlri���i�)r�)r!)r�r�r�rrr�ys$$i��9)r�r�r$r%r&rr:)rZmrefs_beforeZirefs_beforer�r)r�r�r�r�r�r�
test_for_63s(	





zCoroutineTest.test_for_6c
sRd�Gdd�d�����fdd�}�jt��t|��WdQRX�j�d�dS)Nrc@seZdZdd�ZdS)z$CoroutineTest.test_for_7.<locals>.AIc�sdddS)Nrrr)rrrrr��sz.CoroutineTest.test_for_7.<locals>.AI.__aiter__N)r
rrr�rrrr�AI�src�s^�jtd��@x8��2dHy3dH}Wn
tk
s<X�d7�qYWWdQRX�d7�dS)Nr�rr8)r2r3r�)r!)rr�rrrr7�s$ z%CoroutineTest.test_for_7.<locals>.foo)r-rmrr:)rr7r)rr�rr�
test_for_7�szCoroutineTest.test_for_7csnd�Gdd�d����fdd�}|jt��.tj��tjd�t|��WdQRXWdQRX|j�d�dS)Nrc@seZdZdd�ZdS)z$CoroutineTest.test_for_8.<locals>.AIcSsdddS)Nrrr)rrrrr��sz.CoroutineTest.test_for_8.<locals>.AI.__aiter__N)r
rrr�rrrrr�src�sFx8��2dHy3dH}Wn
tk
s.X�d7�qYW�d7�dS)Nrr8)r�)r!)rr�rrr7�s$z%CoroutineTest.test_for_8.<locals>.foor5)r-rmr$r%r&rr:)rr7r)rr�r�
test_for_8�s

zCoroutineTest.test_for_8cs\Gdd�d���fdd�}|jt��.tj��tjd�t|��WdQRXWdQRXdS)Nc@seZdZdd�ZdS)z$CoroutineTest.test_for_9.<locals>.AIc�sdddS)Nrrr)rrrrr��sz.CoroutineTest.test_for_9.<locals>.AI.__aiter__N)r
rrr�rrrrr�src�s6x0��2dHy3dH}Wqtk
s&XqYWdS)N)r�)r!)rrrr7�s$z%CoroutineTest.test_for_9.<locals>.foor5)r-r3r$r%r&r)rr7r)rr�
test_for_9�s

zCoroutineTest.test_for_9cs\Gdd�d���fdd�}|jt��.tj��tjd�t|��WdQRXWdQRXdS)Nc@seZdZdd�ZdS)z%CoroutineTest.test_for_10.<locals>.AIc�sdS)Nr)rrrrr��sz/CoroutineTest.test_for_10.<locals>.AI.__aiter__N)r
rrr�rrrrr�src�s6x0��2dHy3dH}Wqtk
s&XqYWdS)N)r�)r!)rrrr7�s$z&CoroutineTest.test_for_10.<locals>.foor5)r-r3r$r%r&r)rr7r)rr�test_for_10�s

zCoroutineTest.test_for_10c
sVGdd�d���fdd�}|jtd��}|�jd�WdQRX|j}|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)r
rrr�r�r	rrrr�F�src�s6x0��2dHy3dH}Wqtk
s&XqYWdS)N)r�)r�)rrrr��s$z'CoroutineTest.test_for_11.<locals>.mainz an invalid object from __anext__)rSrYr�	exceptionrL�	__cause__rm)rr�r��errr)rr�test_for_11�szCoroutineTest.test_for_11c
sVGdd�d���fdd�}|jtd��}|�jd�WdQRX|j}|j|jt�dS)Nc@seZdZdd�Zdd�ZdS)z$CoroutineTest.test_for_12.<locals>.FcSs|S)Nr)rrrrr��sz.CoroutineTest.test_for_12.<locals>.F.__aiter__cSsdddS)Nrrr)rrrrr	�sz.CoroutineTest.test_for_12.<locals>.F.__await__N)r
rrr�r	rrrrr�src�s6x0��2dHy3dH}Wqtk
s&XqYWdS)N)r�)r�)rrrr��s$z'CoroutineTest.test_for_12.<locals>.mainz an invalid object from __aiter__)rSrYrrrLrrm)rr�r�r	r)rr�test_for_12�szCoroutineTest.test_for_12c
shGdd�dt��Gdd�dt��g����fdd�}|j���|�jd�WdQRX|j�dg�dS)Nc@seZdZdS)z*CoroutineTest.test_for_tuple.<locals>.DoneN)r
rrrrrr�Done�src@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)r
rrr!r�r�rrrr�AIter�src�sHx>�dg�2dHy3dH}Wn
tk
s4X�j|�qYW��dS)Nr�)r�r)r!)rrrrrr7s(z)CoroutineTest.test_for_tuple.<locals>.foor�)r�r^r-rr:)rr7r)rrrr�test_for_tuple�s
zCoroutineTest.test_for_tuplec
shGdd�dt��Gdd�dt��g����fdd�}|j���|�jd�WdQRX|j�dg�dS)Nc@seZdZdS)z3CoroutineTest.test_for_stop_iteration.<locals>.DoneN)r
rrrrrrr
src@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)r
rrr!r�r�rrrrrsrc�sFx<�d�2dHy3dH}Wn
tk
s2X�j|�qYW��dS)Nr�)r�r)r!)rrrrrr7s&z2CoroutineTest.test_for_stop_iteration.<locals>.foor�)r�rr-rr:)rr7r)rrrr�test_for_stop_iterations
z%CoroutineTest.test_for_stop_iterationcs�dd���fdd�}�fdd�}�fdd�}�fd	d
�}|jt|��gddgf�|jt|��gddhf�|jt|��gd
d
d�f�|jt|��gddd�f�dS)Nc�s|S)Nr)r!rrrrQ$sz$CoroutineTest.test_comp_1.<locals>.fc�s dd��d��d�gD�IdHS)Nc�sg|]}|IdH�qS)Nr)r[r�rrrr\(sz?CoroutineTest.test_comp_1.<locals>.run_list.<locals>.<listcomp>r�)rr)rQrr�run_list'sz+CoroutineTest.test_comp_1.<locals>.run_listc�s dd��d��d�gD�IdHS)Nc�sh|]}|IdH�qS)Nr)r[r�rrr�	<setcomp>+sz=CoroutineTest.test_comp_1.<locals>.run_set.<locals>.<setcomp>rrrr)rQrr�run_set*sz*CoroutineTest.test_comp_1.<locals>.run_setc�s dd��d��d�gD�IdHS)Nc�si|]}d|IdH�qS)rnNr)r[r�rrr�
<dictcomp>.sz@CoroutineTest.test_comp_1.<locals>.run_dict1.<locals>.<dictcomp>rrrr)rQrr�	run_dict1-sz,CoroutineTest.test_comp_1.<locals>.run_dict1c�s$dd�t�d��d�g�D�IdHS)Nc�si|]\}}|IdH|�qS)Nr)r[r!r�rrrr1sz@CoroutineTest.test_comp_1.<locals>.run_dict2.<locals>.<dictcomp>rr)�	enumerater)rQrr�	run_dict20sz,CoroutineTest.test_comp_1.<locals>.run_dict2rrrn)rr)rr)r:r)rrrrrr)rQr�test_comp_1#szCoroutineTest.test_comp_1cs�dd���fdd�}|jt|��gddddd	gf��fd
d�}|jt|��gdd
dhf��fdd�}|jt|��gdd
hf�dS)Nc�s|S)Nr)r!rrrrQ9sz$CoroutineTest.test_comp_2.<locals>.fc�s0dd��d��d��d��ddg�gD�IdHS)Nc�s g|]}|IdHD]}|�qqS)Nr)r[r��srrrr\=sz?CoroutineTest.test_comp_2.<locals>.run_list.<locals>.<listcomp>��abc�de�fgrr)rQrrr<sz+CoroutineTest.test_comp_2.<locals>.run_listrnr�r�rrc�s,dd���ddg��dg�g�gD�IdHS)Nc�s0h|](}|IdHD]}|IdHD]}|�q qqS)Nr)r[r�r�drrrrEsz=CoroutineTest.test_comp_2.<locals>.run_set.<locals>.<setcomp>r8�r�rr)rQrrrDsz*CoroutineTest.test_comp_2.<locals>.run_setr8r�r c�s&dd���d��d�g�gD�IdHS)Nc�s&h|]}|IdHD]}|IdH�qqS)Nr)r[r�rrrrrPsz>CoroutineTest.test_comp_2.<locals>.run_set2.<locals>.<setcomp>r8r�rr)rQrr�run_set2Osz+CoroutineTest.test_comp_2.<locals>.run_set2)r:r)rrrr!r)rQr�test_comp_28szCoroutineTest.test_comp_2cs�dd���fdd�}|jt|��gddgf��fdd�}|jt|��gddhf��fd	d
�}|jt|��gddd
�f��fdd�}|jt|��gddgf�dS)NcSsx|D]
}|VqWdS)Nr)r�r!rrrrQYs
z$CoroutineTest.test_comp_3.<locals>.fc�s dd��ddg�2dH�IdHS)Nc
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nr)r�)r[r!rrrr\^sz?CoroutineTest.test_comp_3.<locals>.run_list.<locals>.<listcomp>r8r�rr)rQrrr]sz+CoroutineTest.test_comp_3.<locals>.run_listr9r�c�s dd��ddg�2dH�IdHS)Nc
�s2h|y3dH}Wn
tk
s&X|d�qYS)Nr)r�)r[r!rrrrdsz=CoroutineTest.test_comp_3.<locals>.run_set.<locals>.<setcomp>r8r�rr)rQrrrcsz*CoroutineTest.test_comp_3.<locals>.run_setc�s dd��ddg�2dH�IdHS)Nc
�s8i|y3dH}Wn
tk
s,X|d|d�qYS)Nrr)r�)r[r!rrrrjsz?CoroutineTest.test_comp_3.<locals>.run_dict.<locals>.<dictcomp>r8r�rr)rQrr�run_dictisz+CoroutineTest.test_comp_3.<locals>.run_dict��)r9r�c�s2dd��ddg�2dH�}dd�|2dH�IdHS)NcSs4|y3dH}Wn
tk
s&X|dVqYdS)Nr)r�)r[r!rrr�	<genexpr>ps
z=CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<genexpr>r8r�c
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nrl)r�)r[r{rrrr\qsz>CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<listcomp>r)rG)rQrr�run_genosz*CoroutineTest.test_comp_3.<locals>.run_gen�o�y)r:r)rrrr#r'r)rQr�test_comp_3Xs"zCoroutineTest.test_comp_3cs�dd���fdd�}|jt|��gdgf��fdd�}|jt|��gdhf��fdd	�}|jt|��gdd
if��fdd�}|jt|��gd
gf�dS)NcSsx|D]
}|VqWdS)Nr)r�r!rrrrQws
z$CoroutineTest.test_comp_4.<locals>.fc�s dd��ddg�2dH�IdHS)Nc
�s:g|y3dH}Wn
tk
s.X|dkr|d�qYS)Nr8r)r�)r[r!rrrr\|sz?CoroutineTest.test_comp_4.<locals>.run_list.<locals>.<listcomp>r8r�rr)rQrrr{sz+CoroutineTest.test_comp_4.<locals>.run_listr�c�s dd��ddg�2dH�IdHS)Nc
�s:h|y3dH}Wn
tk
s.X|dkr|d�qYS)Nr8r)r�)r[r!rrrr�sz=CoroutineTest.test_comp_4.<locals>.run_set.<locals>.<setcomp>r8r�rr)rQrrr�sz*CoroutineTest.test_comp_4.<locals>.run_setc�s dd��ddg�2dH�IdHS)Nc
�s@i|y3dH}Wn
tk
s4X|dkr|d|d�qYS)Nr8rr)r�)r[r!rrrr�sz?CoroutineTest.test_comp_4.<locals>.run_dict.<locals>.<dictcomp>r8r�rr)rQrrr#�sz+CoroutineTest.test_comp_4.<locals>.run_dictr%c�s2dd��ddg�2dH�}dd�|2dH�IdHS)NcSs<|y3dH}Wn
tk
s.X|dkr|dVqYdS)Nr8r)r�)r[r!rrrr&�s
z=CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<genexpr>r8r�c
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nrl)r�)r[r{rrrr\�sz>CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<listcomp>r)rG)rQrrr'�sz*CoroutineTest.test_comp_4.<locals>.run_genr))r:r)rrrr#r'r)rQr�test_comp_4vs"zCoroutineTest.test_comp_4cs�dd���fdd�}|jt|��gdddgf��fdd	�}|jt|��gdddhf��fd
d�}|jt|��gdd
dd�f��fdd�}|jt|��gdddgf�dS)NcSsx|D]
}|VqWdS)Nr)r�r!rrrrQ�s
z&CoroutineTest.test_comp_4_2.<locals>.fc�s dd��td��2dH�IdHS)Nc
�sJg|y3dH}Wn
tk
s>Xd|ko.dknr|d�qYS)Nrr�r8)r�)r[r!rrrr\�szACoroutineTest.test_comp_4_2.<locals>.run_list.<locals>.<listcomp>�)r?r)rQrrr�sz-CoroutineTest.test_comp_4_2.<locals>.run_listr9r$�
c�s dd��td��2dH�IdHS)Nc
�sJh|y3dH}Wn
tk
s>Xd|ko.dknr|d�qYS)Nrr�r8)r�)r[r!rrrr�sz?CoroutineTest.test_comp_4_2.<locals>.run_set.<locals>.<setcomp>r,)r?r)rQrrr�sz,CoroutineTest.test_comp_4_2.<locals>.run_setc�s dd��td��2dH�IdHS)Nc
�sPi|y3dH}Wn
tk
sDXd|ko.dknr|d|d�qYS)Nrr�rlr8)r�)r[r!rrrr�szACoroutineTest.test_comp_4_2.<locals>.run_dict.<locals>.<dictcomp>r,)r?r)rQrrr#�sz-CoroutineTest.test_comp_4_2.<locals>.run_dictr�rp�g)r9r$r-c�s2dd��td��2dH�}dd�|2dH�IdHS)NcSsL|y3dH}Wn
tk
s>Xd|ko,dknr|dVqYdS)Nrr�r8)r�)r[r!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�)r[r{rrrr\�sz@CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<listcomp>)r?)rG)rQrrr'�sz,CoroutineTest.test_comp_4_2.<locals>.run_genr(�p�q)r:r)rrrr#r'r)rQr�
test_comp_4_2�s"zCoroutineTest.test_comp_4_2cs0dd���fdd�}|jt|��gdgf�dS)NcSsx|D]
}|VqWdS)Nr)r�r!rrrrQ�s
z$CoroutineTest.test_comp_5.<locals>.fc�s$�fdd�ddgddgfD�IdHS)Nc�sXg|]P}|ddkr�|�2dHy3dH}Wn
tk
sJX|dkr |d�q YqS)rr8Nr r)r�)r[Zpairr!)rQrrr\�sz?CoroutineTest.test_comp_5.<locals>.run_list.<locals>.<listcomp>r8r�r �(rr)rQrrr�sz+CoroutineTest.test_comp_5.<locals>.run_listr)r:r)rrr)rQr�test_comp_5�s
zCoroutineTest.test_comp_5cs4dd���fdd�}|jt|��gdddgf�dS)NcSsx|D]
}|VqWdS)Nr)r�r!rrrrQ�s
z$CoroutineTest.test_comp_6.<locals>.fc�s dd��ddg�2dH�IdHS)Nc
�s<g|y3dH}Wn
tk
s0X|D]}|d�q qYS)Nr)r�)r[�seqr!rrrr\�sz?CoroutineTest.test_comp_6.<locals>.run_list.<locals>.<listcomp>r8r�r )r8r�)r rr)rQrrr�sz+CoroutineTest.test_comp_6.<locals>.run_listr9r��)r:r)rrr)rQr�test_comp_6�s
zCoroutineTest.test_comp_6c	s:dd���fdd�}|jtd��t|��WdQRXdS)NcSsdVdVtd��dS)Nrr�aaa)r�rrrrrQ�sz$CoroutineTest.test_comp_7.<locals>.fc�sdd���2dH�IdHS)Nc
�s.g|y3dH}Wn
tk
s"X|�qYS)N)r�)r[r!rrrr\�sz?CoroutineTest.test_comp_7.<locals>.run_list.<locals>.<listcomp>rr)rQrrr�sz+CoroutineTest.test_comp_7.<locals>.run_listr7)rSr�r)rrr)rQr�test_comp_7�szCoroutineTest.test_comp_7cCs(dd�}|jt|��gdddgf�dS)Nc�sdd�dD�S)NcSsg|]}|�qSrr)r[r!rrrr\�sz8CoroutineTest.test_comp_8.<locals>.f.<locals>.<listcomp>rrr�)rrr�rrrrrrQ�sz$CoroutineTest.test_comp_8.<locals>.frrr�)r:r)rrQrrr�test_comp_8�szCoroutineTest.test_comp_8cs2dd���fdd�}|jt|��gddgf�dS)NcSsdVdVdS)NrrrrrrrrG�sz&CoroutineTest.test_comp_9.<locals>.genc�s(dd���2dH�IdH}dd�|D�S)Nc
�s.g|y3dH}Wn
tk
s"X|�qYS)N)r�)r[r!rrrr\�sz8CoroutineTest.test_comp_9.<locals>.f.<locals>.<listcomp>cSsg|]}|�qSrr)r[r!rrrr\�sr)�l)rGrrrQ�sz$CoroutineTest.test_comp_9.<locals>.frr)r:r)rrQr)rGr�test_comp_9�s
zCoroutineTest.test_comp_9cCs*dd�}|jt|��gdddd�f�dS)Nc�sdd�dD�}dd�|D�S)	NcSsh|]}|�qSrr)r[r!rrrr�sz8CoroutineTest.test_comp_10.<locals>.f.<locals>.<setcomp>rrr�cSsi|]
}||�qSrr)r[�xrrrr�sz9CoroutineTest.test_comp_10.<locals>.f.<locals>.<dictcomp>)rrr�r)ZxxrrrrQ�sz%CoroutineTest.test_comp_10.<locals>.frrr�)rrr�)r:r)rrQrrr�test_comp_10�szCoroutineTest.test_comp_10cCsjdd�}|�}|jt��tj|�WdQRX|j�}z$|jt��tj|�WdQRXWd|j�XdS)Nc�sdS)Nrrrrrru�sz%CoroutineTest.test_copy.<locals>.func)r-rY�copyr	rr)rrurr rrr�	test_copy�szCoroutineTest.test_copycCs�dd�}|�}x>ttjd�D],}|jttjf��tj||�WdQRXqW|j�}zDx>ttjd�D],}|jttjf��tj||�WdQRXqhWWd|j�XdS)Nc�sdS)Nrrrrrrusz'CoroutineTest.test_pickle.<locals>.funcr)	r?�pickleZHIGHEST_PROTOCOLr-rYZ
PicklingError�dumpsr	rr)rrur�protor rrr�test_pickleszCoroutineTest.test_picklecCs\dd�}tj��2tj��}tjd�|�tj�WdQRXWdQRX|jd|j��dS)Nc�sdS)Nrrrrrrusz3CoroutineTest.test_fatal_coro_warning.<locals>.funcr5zwas never awaited)r$r%rZcaptured_stderr�filterwarningsr'rw�getvalue)rru�stderrrrr�test_fatal_coro_warnings
z%CoroutineTest.test_fatal_coro_warningN)Tr
rrrJrRrUrXrbrerfrgrirkrtryr}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�rrrrrr
rrrrr"r*r+r1r3r6r8r9r;r=r?rCrGrrrrrF�s�	

	#
		(	


"(@K\ 
	
rFc@seZdZdd�ZdS)�CoroAsyncIOCompatTestcs�tjd��Gdd�dt��g�G��fdd�d������fdd�}�j�}�j|�z*y|j|��Wn�k
r|YnXWd|j��jd�X|j�dd	dg�dS)
N�asyncioc@seZdZdS)z9CoroAsyncIOCompatTest.test_asyncio_1.<locals>.MyExceptionN)r
rrrrrr�MyException!srJcs(eZdZ��fdd�Z��fdd�ZdS)z0CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CMc�s(�jd��jd�IdH�jd�|S)Nrg{�G�z�?r)r�sleep)r)rIrrrr�'s

z;CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aenter__c�s �jd�IdH�j|j�dS)Ng{�G�z�?)rKrr
)r�exc_typeZexc_valZexc_tb)rIrrrr�-sz:CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aexit__N)r
rrr�r�r)rIrrrr�&sr�c
�sB��4IdH�}�jd�IdH��WdQIdHRX�jd�dS)Ng{�G�z�?Zunreachable)rKr)r�)r�rJrIrrrrQ1sz/CoroAsyncIOCompatTest.test_asyncio_1.<locals>.frr)r�
import_moduler�Znew_event_loopZset_event_loopZrun_until_completerrr:)rrQZloopr)r�rJrIrr�test_asyncio_1s


z$CoroAsyncIOCompatTest.test_asyncio_1N)r
rrrNrrrrrHsrHc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�SysSetCoroWrapperTestcs�dd�}d��fdd�}|jtj��tj|�|jtj�|�z(|�}|j��|jt|�gdf�Wdtjd�X|jtj��d�t��|�WdQRX|j	��dS)Nc�sdS)Nrhrrrrrr7Gsz5SysSetCoroWrapperTest.test_set_wrapper_1.<locals>.foocs|�|S)Nr)rG)�wrappedrrr�Ksz6SysSetCoroWrapperTest.test_set_wrapper_1.<locals>.wraprh)
r�r��get_coroutine_wrapper�set_coroutine_wrapperrqrBr:rr(rH)rr7r�rQr)rPr�test_set_wrapper_1Fs 

z(SysSetCoroWrapperTest.test_set_wrapper_1c	CsB|jtj��|jtd��tjd�WdQRX|jtj��dS)Nzcallable expected, got intr)r�r�rQrSrYrR)rrrr�test_set_wrapper_2csz(SysSetCoroWrapperTest.test_set_wrapper_2cCs`dd�}dd�}tj|�z4t��$|jtd��|�WdQRXWdQRXWdtjd�XdS)Nc�sdS)Nrhrrrrrr7jsz5SysSetCoroWrapperTest.test_set_wrapper_3.<locals>.foocSsdd�}||�S)Nc�s
|IdHS)Nr)rrrrr�nszGSysSetCoroWrapperTest.test_set_wrapper_3.<locals>.wrapper.<locals>.wrapr)rr�rrr�wrappermsz9SysSetCoroWrapperTest.test_set_wrapper_3.<locals>.wrapperzLcoroutine wrapper.*\.wrapper at 0x.*attempted to recursively wrap .* wrap .*)r�rRr(rSrT)rr7rUrrr�test_set_wrapper_3is
z(SysSetCoroWrapperTest.test_set_wrapper_3csRtjdd��}d��fdd�}tj|�z|�|j�dd�Wdtjd�XdS)NcSsdS)Nrhrrrrrr7~sz5SysSetCoroWrapperTest.test_set_wrapper_4.<locals>.foocs|�|S)Nr)rG)rPrrr��sz6SysSetCoroWrapperTest.test_set_wrapper_4.<locals>.wrapzCgenerator-based coroutine was wrapped via sys.set_coroutine_wrapper)rrdr�rRrq)rr7r�r)rPr�test_set_wrapper_4}s

z(SysSetCoroWrapperTest.test_set_wrapper_4N)r
rrrSrTrVrWrrrrrODsrOc@s$eZdZdd�Zdd�Zdd�ZdS)�CAPITestcs0ddlm��fdd�}|j|�jd�d�dS)Nr)�	awaitTypec�s�tdg��}|IdHS)Nr)r`)�future)�atrrr7�sz%CAPITest.test_tp_await_1.<locals>.foor)�	_testcapirYr:r)rr7r)r[r�test_tp_await_1�szCAPITest.test_tp_await_1cCs2ddlm}|tdg��}|jt|j��d�dS)Nr)rYr)r\rYr`r:rr	)rr[rZrrr�test_tp_await_2�szCAPITest.test_tp_await_2c
sHddlm��fdd�}|jtd��|j|�jd�d�WdQRXdS)Nr)rYc�s�d�}|IdHS)Nrr)rZ)r[rrr7�sz%CAPITest.test_tp_await_3.<locals>.fooz.__await__.*returned non-iterator of type 'int'r)r\rYrSrYr:r)rr7r)r[r�test_tp_await_3�s

zCAPITest.test_tp_await_3N)r
rrr]r^r_rrrrrX�s	rX�__main__)�
contextlibr>rCr@r�rZunittestr$Ztestrrr
rr"�contextmanagerr(ZTestCaser)r=rFrHrOZcpython_onlyrXr
r�rrrr�<module>sJ=*O