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.opt-2.pyc

3

��2aW��@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�4/opt/alt/python36/lib64/python3.6/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
cCsdg}d}xRy|j|jd��Wq
tk
rV}z|jr@|jdnd}PWYdd}~Xq
Xq
W||fS)Nr)�append�send�
StopIteration�args)�coro�buffer�result�exrrr�	run_asyncsrcCs�|j�}g}d}d}xry4|dr0|jt|��n|j|jd��|d7}Wqtk
r�}z|jrl|jdnd}PWYdd}~XqXqW||fS)Nr��)r	r�nextrrr)r�awrr�irrrr�run_async__await__*src	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*)rr+r%rrr�test_badsyntax_2is
z#AsyncBadSyntaxTest.test_badsyntax_2cCsD|jt��0tj��tjd�tddd�WdQRXWdQRXdS)N�errorz	async = 1z<test>r&)r(r.rr 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'rr r!r&�assertEqual)rr+r%�locrrr�test_goodsyntax_1�s		



z$AsyncBadSyntaxTest.test_goodsyntax_1N)r
rrr,r/r1r7rrrrr$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():
    returnr2)	�ranger�format�joinr&r5�
assertTrue�inspectZiscoroutinefunction)r�bufr�nsrrr�test_oneline_defs�s
z#TokenizerRegrTest.test_oneline_defsN)r
rrrArrrrr8�sr8c@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)rrCrrr�
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)Nr3rrrrrr2�sz&CoroutineTest.test_func_1.<locals>.foor3cSsdS)Nrrrrr�bar�sz&CoroutineTest.test_func_1.<locals>.bar)�assertIsInstance�types�
CoroutineTyper=�bool�__code__�co_flagsr>ZCO_COROUTINErDZCO_GENERATOR�cr_coder5rr)rr2�frGrrr�test_func_1�szCoroutineTest.test_func_1c	Cs.dd�}|jtd��t|��WdQRXdS)Nc�st�dS)N)rrrrrr2sz&CoroutineTest.test_func_2.<locals>.foozcoroutine raised StopIteration)�assertRaisesRegex�RuntimeErrorr)rr2rrr�test_func_2s
zCoroutineTest.test_func_2c
Cs0dd�}t��|jt|��d�WdQRXdS)Nc�st�dS)N)rrrrrr2
sz&CoroutineTest.test_func_3.<locals>.fooz^<coroutine object.* at 0x.*>$)r#�assertRegex�repr)rr2rrr�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)rrrrrr2sz&CoroutineTest.test_func_4.<locals>.foocs�jtd�S)Nz"'coroutine' object is not iterable)rQ�	TypeErrorr)rrr�<lambda>sz+CoroutineTest.test_func_4.<locals>.<lambda>cSsg|]}|�qSrr)�.0rrrr�
<listcomp>(sz-CoroutineTest.test_func_4.<locals>.<listcomp>)�list�tuple�sum�iterr#)rr2�checkrr)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)NrrrrrrrG+sz&CoroutineTest.test_func_5.<locals>.barc�s��IdHdS)Nrr)rGrrr2/sz&CoroutineTest.test_func_5.<locals>.foocs�jtd�S)Nz"'coroutine' object is not iterable)rQrWr)rrrrX2sz+CoroutineTest.test_func_5.<locals>.<lambda>rcSsg|]}|�qSrr)rY�elrrrrZ;sz-CoroutineTest.test_func_5.<locals>.<listcomp>)r)rI�	coroutiner5r\rr^)rr2r_rar)rGrr�test_func_5*szCoroutineTest.test_func_5c	shtjdd����fdd�}|�}|j|jd�d�|j|jd�d�|jt��|jd�WdQRXdS)NcssdVdVdS)NrrrrrrrrG@sz&CoroutineTest.test_func_6.<locals>.barc�s��IdHdS)Nrr)rGrrr2Esz&CoroutineTest.test_func_6.<locals>.foorr)rIrbr5rr(r)rr2rOr)rGr�test_func_6?szCoroutineTest.test_func_6csLdd���fdd�}t��(|jtd��t|��WdQRXWdQRXdS)Nc�sdS)Nr3rrrrrrGOsz&CoroutineTest.test_func_7.<locals>.barc3s��EdHdS)Nrr)rGrrr2Rsz&CoroutineTest.test_func_7.<locals>.foozCcannot 'yield from' a coroutine object in a non-coroutine generator)r#rQrWr[)rr2r)rGr�test_func_7NszCoroutineTest.test_func_7cs4tj�fdd��}dd��|jt|��gdf�dS)Nc3s��EdHS)Nrr)r2rrrG\sz&CoroutineTest.test_func_8.<locals>.barc�sdS)N�spamrrrrrr2`sz&CoroutineTest.test_func_8.<locals>.foorf)rIrbr5r)rrGr)r2r�test_func_8[szCoroutineTest.test_func_8c	Cs2dd�}|jtd��|�tj�WdQRXdS)Nc�sdS)Nrrrrrr2fsz&CoroutineTest.test_func_9.<locals>.fooz0coroutine '.*test_func_9.*foo' was never awaited)r-�RuntimeWarningrr")rr2rrr�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)�NrrrCqsz'CoroutineTest.test_func_10.<locals>.genc�s��IdHdS)Nrr)rCrrr2}sz'CoroutineTest.test_func_10.<locals>.foor3rjr�f)rIrbr	�assertIsr^rr5r�closer(rk�throw)rr2rrr)rmrCr�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	rUrp)rrsrrrr�test_func_11�szCoroutineTest.test_func_11c	s8�fdd�}|��|jtd���jd�WdQRXdS)Nc�s�jd�}tIdHdS)N)rr2)r)�merr�g�s
z%CoroutineTest.test_func_12.<locals>.gzcoroutine already executing)rQ�
ValueErrorr)rryr)rxr�test_func_12�s
zCoroutineTest.test_func_12c	Cs0dd�}|jtd��|�jd�WdQRXdS)Nc�sdS)Nrrrrrry�sz%CoroutineTest.test_func_13.<locals>.gz5can't send non-None value to a just-started coroutinerf)rQrWr)rryrrr�test_func_13�s
zCoroutineTest.test_func_13c	sNtjdd����fdd�}|�}|jd�|jtd��|j�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)rIrbrrQrRrp)rr�cr)rCr�test_func_14�s
zCoroutineTest.test_func_14cCsfdd�}dd�}|�}|jtd��||�jd�WdQRX|jtd��||�jd�WdQRXdS)Nc�sdS)Nrfrrrrr�spammer�sz+CoroutineTest.test_func_15.<locals>.spammerc�s
|IdHS)Nr)rrrr�reader�sz*CoroutineTest.test_func_15.<locals>.readerrfz&cannot reuse already awaited coroutine)rQrrrR)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)Nrfrr)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)rIrbrrQ�	ExceptionrqrR)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)Nrfrrrrrrb�sz-CoroutineTest.test_func_17.<locals>.coroutinerfz&cannot reuse already awaited coroutiner�)rQrrrRrqr�rp)rrbrrrr�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)Nrfrrrrrrbsz-CoroutineTest.test_func_18.<locals>.coroutinerfz&cannot reuse already awaited coroutiner�)
r	r^rQrrrRrrqr�rp)rrbrZ
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)r}r)�CHKrrr2.s

z'CoroutineTest.test_func_19.<locals>.fooc�s��IdHdS)Nrr)r2rrrb7sz-CoroutineTest.test_func_19.<locals>.coroutiner�)rIrbrr5rpr:)rrbr�_r)r�r2r�test_func_19+s	

zCoroutineTest.test_func_19cCs&dd�}t|��}|j|gdf�dS)Nc�sdS)Nr3)r3rrrrrr2Jsz7CoroutineTest.test_coro_wrapper_send_tuple.<locals>.foor3)r3)rr5)rr2rrrr�test_coro_wrapper_send_tupleIs
z*CoroutineTest.test_coro_wrapper_send_tuplecCs8dd�}t|��}|j|dt�|j|djd�dS)Nc�std�S)Nr3)rrrrrr2Qsz?CoroutineTest.test_coro_wrapper_send_stop_iterator.<locals>.foorr3)rrHrr5r)rr2rrrr�$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)r5r>�getcoroutinestateZCORO_RUNNING�assertIsNone�cr_awaitr)�coro_brrrrlYs
z&CoroutineTest.test_cr_await.<locals>.ac�s��IdHdS)Nrr)rlrrr~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>.brl)rIrbr5r>r�ZCORO_CREATEDr�r�rZCORO_SUSPENDED�gi_code�co_namer(rZCORO_CLOSED)rr�r)rlr~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rbc�sdS)NrrrrrrOsz(CoroutineTest.test_corotype_1.<locals>.fzcoroutine object)rIrJrur�__doc__rprq�__dict__r5r
rU)rZctrOr~rrr�test_corotype_1vszCoroutineTest.test_corotype_1c	Cs.dd�}|jtd��t|��WdQRXdS)Nc�sdIdHdS)Nrrrrrrr2�sz'CoroutineTest.test_await_1.<locals>.foozobject int can.t.*await)rQrWr)rr2rrr�test_await_1�szCoroutineTest.test_await_1c	Cs.dd�}|jtd��t|��WdQRXdS)Nc�sgIdHdS)Nrrrrrr2�sz'CoroutineTest.test_await_2.<locals>.foozobject list can.t.*await)rQrWr)rr2rrr�test_await_2�szCoroutineTest.test_await_2cCsDdd�}|jt|��dddgdf�|jt|��dddgdf�dS)Nc�stdddg�IdHdS)Nrrr�)rrrrrr2�sz'CoroutineTest.test_await_3.<locals>.foorrr�)r5rr)rr2rrr�test_await_3�szCoroutineTest.test_await_3cs.dd���fdd�}|jt|��gdf�dS)Nc�sdS)N�*rrrrrrG�sz'CoroutineTest.test_await_4.<locals>.barc�s��IdHS)Nrr)rGrrr2�sz'CoroutineTest.test_await_4.<locals>.foor�)r5r)rr2r)rGr�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�rrr2�sz'CoroutineTest.test_await_5.<locals>.fooz(__await__.*returned non-iterator of type)rQrWr)rr2r)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�rrr2�sz'CoroutineTest.test_await_6.<locals>.foor�)r5r)rr2r)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�rjr)rrrrr	�sz7CoroutineTest.test_await_7.<locals>.Awaitable.__await__N)r
rrr	rrrrr��sr�c�s��IdHS)Nrr)r�rrr2�sz'CoroutineTest.test_await_7.<locals>.foor�rj)r5r)rr2r)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�rrr2�sz'CoroutineTest.test_await_8.<locals>.fooz4object Awaitable can't be used in 'await' expression)rQrWr)rr2r)r�r�test_await_8�s

zCoroutineTest.test_await_8cs^�fdd��dd����fdd�}�fdd�}|jt|��gd	f�|jt|��gdf�dS)Ncs�S)Nrr)rGrr�wrap�sz(CoroutineTest.test_await_9.<locals>.wrapc�sdS)Nr�rrrrrrG�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�rrrX�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�)rGr�rrr2�sz'CoroutineTest.test_await_9.<locals>.fooc�s��IdHS)Nrr)rGrr�foo2�sz(CoroutineTest.test_await_9.<locals>.foo2i��r�i���)r5r)rr2r�r)rGr�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�rrrG�sz(CoroutineTest.test_await_10.<locals>.barc�s��IdHIdHS)Nrr)rGrrr2�sz(CoroutineTest.test_await_10.<locals>.foor�)r5r)rr2r)rGr�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)NrfrrrrrrG�sz(CoroutineTest.test_await_11.<locals>.barc�s���IdHd�S)N)r�rr)rGr�rrr2�sz(CoroutineTest.test_await_11.<locals>.fooc�s��IdHdfS)Nr�rr)rGrrr��sz)CoroutineTest.test_await_11.<locals>.foo2rfr�)rfr�)r5r)rr2r�r)rGr�r�
test_await_11�s
zCoroutineTest.test_await_11c	sLdd��G�fdd�d���fdd�}|jtd��t|��WdQRXdS)Nc�sdS)Nrfrrrrrrsz)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�rrr2	sz(CoroutineTest.test_await_12.<locals>.fooz"__await__\(\) returned a coroutine)rQrWr)rr2r)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�rrr2sz(CoroutineTest.test_await_13.<locals>.fooz(__await__.*returned non-iterator of type)rQrWr)rr2r)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
||_dS)N)r)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)rkr)r�r�rr�coro1.sz*CoroutineTest.test_await_14.<locals>.coro1c�s����IdHS)Nrr)r�r�rr�coro23sz*CoroutineTest.test_await_14.<locals>.coro2rf)r�rrQrr(rqrk)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�rrrbEsz.CoroutineTest.test_await_15.<locals>.coroutinec�s|IdHdS)Nr)rrrr�waiterHsz+CoroutineTest.test_await_15.<locals>.waiterz"coroutine is being awaited already)rIrbrrQrR)rrbr�rr)r�r�
test_await_15@s
zCoroutineTest.test_await_15cs2dd���fdd�}t|��\}}|j|j�dS)Nc�st�S)N)rzrrrrrOUsz&CoroutineTest.test_await_16.<locals>.fc	�s yt�Wn��IdHSdS)N)�KeyErrorr)rOrrryXsz&CoroutineTest.test_await_16.<locals>.g)rr��__context__)rryr�rr)rOr�
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�)rlr�)r�rrr2ss$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�)rlr~)r�rrr2�s$)r�r�r�)rr5r(rk)rr2rOrr�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�rrr2�sz&CoroutineTest.test_with_2.<locals>.foor�)rQ�AttributeErrorr)rr2r)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�rrr2�sz&CoroutineTest.test_with_3.<locals>.foor�)rQr�r)rr2r)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�rrr2�sz&CoroutineTest.test_with_4.<locals>.foor�)rQr�r)rr2r)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
�s$��4IdH�WdQIdHRXdS)Nrr)r�rrrs�sz'CoroutineTest.test_with_5.<locals>.func)r(�AssertionErrorr)rrsr)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�rrr2�sz&CoroutineTest.test_with_6.<locals>.foozV'async with' received an object from __aenter__ that does not implement __await__: int)rQrWr)rr2r)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�rrr2�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)	rrWrTrr=r��
isinstancerk�fail)rr2r�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��CNTrrr2�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�rrr2src�s@x:td�D].}��4IdH��d7�w
WdQIdHRXq
WdS)Nrr)r:)r)r�r�rrr2sr�c
�s,��4IdH��d7�dSQIdHRXdS)Nrrr)r�r�rrr2#s�)rQrWrr5)rr2r)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�rrr2:sz&CoroutineTest.test_with_9.<locals>.foor)r(rkrr5)rr2r)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)rRr)r�r�rrr2Nsz'CoroutineTest.test_with_10.<locals>.fooz*exception from __aexit__ did not propagate)rrkr=r�r�rRr�)rr2r�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)rRr)r�r�rrr2hsz'CoroutineTest.test_with_11.<locals>.fooz+exception from __aenter__ did not propagate)rr�r=r�r�)rr2r�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)ro�	__class__rR)�cm)r�r�rrrr2~sz'CoroutineTest.test_with_12.<locals>.foo)r)rr2r)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�rrr2�sz'CoroutineTest.test_with_13.<locals>.foor)r(rkrr5)rr2r)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)Nrr3rj)rr
�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)r-r.r�r)Zi1Zi2)r�rrrr�test1�s(z'CoroutineTest.test_for_1.<locals>.test1rcSsg|]}|d�qS)rjr)rYrrrrrZ�sz,CoroutineTest.test_for_1.<locals>.<listcomp>r4cSsg|]}|d�qS)rr)rYrrrrrZ�s�ec�s~�jtd��^xV��2dHy3dH}Wn
tk
sPX�j|d�|ddkrPqYW�jd�WdQRX�jd�dS)Nr�r�zwhat?�end)r-r.r�r)r)r�rrrr�test2�s$z'CoroutineTest.test_for_1.<locals>.test2rrj��cSsg|]}|�qSrr)rYrrrrrZ�s�r�c�s~�jtd��^xV��2dHy3dH}Wn
tk
sPX|ddkr@q�j|d�qYW�jd�WdQRX�jd�dS)Nr�rr�zwhat?r�)r-r.r�r)r)r�rrrr�test3�s$z'CoroutineTest.test_for_1.<locals>.test3r�cSsg|]}|d�qS)rjr)rYrrrrrZ�scSsg|]}|�qSrr)rYrrrrrZ�szwhat?)rr5r:)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)�tuprrr2�s"z%CoroutineTest.test_for_2.<locals>.fooz/async for' requires an object.*__aiter__.*tuple)rrr�)�sys�getrefcountrQrWrr5)r�refs_beforer2r)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)�aiterrrr2�s"z%CoroutineTest.test_for_3.<locals>.fooz4async for' received an invalid object.*__aiter.*\: I)r�r�rQrWrr5)rr�r�r2r)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�rrr2s"z%CoroutineTest.test_for_4.<locals>.fooz7async for' received an invalid object.*__anext__.*tuple)r�r�rQrWrr5)rr�r�r2r)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)r-r.r�r�)r)r�rrrr2(s$z%CoroutineTest.test_for_5.<locals>.fooz3async for' received an invalid object.*__anext.*int)rQrWr)rr2r)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)Nr3r)rr�)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>.mainr0i��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)Nrjri���i�)r�)r)r�r�r�rrr�ys$$i��9)r�r�rr r!rr5)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�rr3)r-r.r�)r)rr�rrrr2�s$ z%CoroutineTest.test_for_7.<locals>.foo)r(rkrr5)rr2r)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)Nrr3)r�)r)rr�rrr2�s$z%CoroutineTest.test_for_8.<locals>.foor0)r(rkrr r!rr5)rr2r)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)rrrr2�s$z%CoroutineTest.test_for_9.<locals>.foor0)r(r.rr r!r)rr2r)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)rrrr2�s$z&CoroutineTest.test_for_10.<locals>.foor0)r(r.rr r!r)rr2r)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__)rQrWr�	exceptionrH�	__cause__rk)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__)rQrWrrrHrrk)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rr�r�rrrr�AIter�src�sHx>�dg�2dHy3dH}Wn
tk
s4X�j|�qYW��dS)Nr�)r�r)r)rrrrrr2s(z)CoroutineTest.test_for_tuple.<locals>.foor�)r�r\r(rr5)rr2r)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)rr�r)rrrrr�sz>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__anext__N)r
rrrr�r�rrrrrsrc�sFx<�d�2dHy3dH}Wn
tk
s2X�j|�qYW��dS)Nr�)r�r)r)rrrrrr2s&z2CoroutineTest.test_for_stop_iteration.<locals>.foor�)r�rr(rr5)rr2r)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)rrrrrO$sz$CoroutineTest.test_comp_1.<locals>.fc�s dd��d��d�gD�IdHS)Nc�sg|]}|IdH�qS)Nr)rYr~rrrrZ(sz?CoroutineTest.test_comp_1.<locals>.run_list.<locals>.<listcomp>r�)rr)rOrr�run_list'sz+CoroutineTest.test_comp_1.<locals>.run_listc�s dd��d��d�gD�IdHS)Nc�sh|]}|IdH�qS)Nr)rYr~rrr�	<setcomp>+sz=CoroutineTest.test_comp_1.<locals>.run_set.<locals>.<setcomp>rrrr)rOrr�run_set*sz*CoroutineTest.test_comp_1.<locals>.run_setc�s dd��d��d�gD�IdHS)Nc�si|]}d|IdH�qS)rlNr)rYr~rrr�
<dictcomp>.sz@CoroutineTest.test_comp_1.<locals>.run_dict1.<locals>.<dictcomp>rrrr)rOrr�	run_dict1-sz,CoroutineTest.test_comp_1.<locals>.run_dict1c�s$dd�t�d��d�g�D�IdHS)Nc�si|]\}}|IdH|�qS)Nr)rYrr~rrrr1sz@CoroutineTest.test_comp_1.<locals>.run_dict2.<locals>.<dictcomp>rr)�	enumerater)rOrr�	run_dict20sz,CoroutineTest.test_comp_1.<locals>.run_dict2rrrl)rr)rr)r5r)rrrrrr)rOr�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)rrrrrO9sz$CoroutineTest.test_comp_2.<locals>.fc�s0dd��d��d��d��ddg�gD�IdHS)Nc�s g|]}|IdHD]}|�qqS)Nr)rYr~�srrrrZ=sz?CoroutineTest.test_comp_2.<locals>.run_list.<locals>.<listcomp>��abc�de�fgrr)rOrrr<sz+CoroutineTest.test_comp_2.<locals>.run_listrlr�r~rrc�s,dd���ddg��dg�g�gD�IdHS)Nc�s0h|](}|IdHD]}|IdHD]}|�q qqS)Nr)rYr~r�drrrrEsz=CoroutineTest.test_comp_2.<locals>.run_set.<locals>.<setcomp>r3�r�rr)rOrrrDsz*CoroutineTest.test_comp_2.<locals>.run_setr3r�r c�s&dd���d��d�g�gD�IdHS)Nc�s&h|]}|IdHD]}|IdH�qqS)Nr)rYr~rrrrrPsz>CoroutineTest.test_comp_2.<locals>.run_set2.<locals>.<setcomp>r3r�rr)rOrr�run_set2Osz+CoroutineTest.test_comp_2.<locals>.run_set2)r5r)rrrr!r)rOr�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�rrrrrOYs
z$CoroutineTest.test_comp_3.<locals>.fc�s dd��ddg�2dH�IdHS)Nc
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nr)r�)rYrrrrrZ^sz?CoroutineTest.test_comp_3.<locals>.run_list.<locals>.<listcomp>r3r�rr)rOrrr]sz+CoroutineTest.test_comp_3.<locals>.run_listr4r�c�s dd��ddg�2dH�IdHS)Nc
�s2h|y3dH}Wn
tk
s&X|d�qYS)Nr)r�)rYrrrrrdsz=CoroutineTest.test_comp_3.<locals>.run_set.<locals>.<setcomp>r3r�rr)rOrrrcsz*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�)rYrrrrrjsz?CoroutineTest.test_comp_3.<locals>.run_dict.<locals>.<dictcomp>r3r�rr)rOrr�run_dictisz+CoroutineTest.test_comp_3.<locals>.run_dict��)r4r�c�s2dd��ddg�2dH�}dd�|2dH�IdHS)NcSs4|y3dH}Wn
tk
s&X|dVqYdS)Nr)r�)rYrrrr�	<genexpr>ps
z=CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<genexpr>r3r�c
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nrj)r�)rYryrrrrZqsz>CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<listcomp>r)rC)rOrr�run_genosz*CoroutineTest.test_comp_3.<locals>.run_gen�o�y)r5r)rrrr#r'r)rOr�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�rrrrrOws
z$CoroutineTest.test_comp_4.<locals>.fc�s dd��ddg�2dH�IdHS)Nc
�s:g|y3dH}Wn
tk
s.X|dkr|d�qYS)Nr3r)r�)rYrrrrrZ|sz?CoroutineTest.test_comp_4.<locals>.run_list.<locals>.<listcomp>r3r�rr)rOrrr{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)Nr3r)r�)rYrrrrr�sz=CoroutineTest.test_comp_4.<locals>.run_set.<locals>.<setcomp>r3r�rr)rOrrr�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)Nr3rr)r�)rYrrrrr�sz?CoroutineTest.test_comp_4.<locals>.run_dict.<locals>.<dictcomp>r3r�rr)rOrrr#�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)Nr3r)r�)rYrrrrr&�s
z=CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<genexpr>r3r�c
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nrj)r�)rYryrrrrZ�sz>CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<listcomp>r)rC)rOrrr'�sz*CoroutineTest.test_comp_4.<locals>.run_genr))r5r)rrrr#r'r)rOr�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�rrrrrO�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�r3)r�)rYrrrrrZ�szACoroutineTest.test_comp_4_2.<locals>.run_list.<locals>.<listcomp>�)r:r)rOrrr�sz-CoroutineTest.test_comp_4_2.<locals>.run_listr4r$�
c�s dd��td��2dH�IdHS)Nc
�sJh|y3dH}Wn
tk
s>Xd|ko.dknr|d�qYS)Nrr�r3)r�)rYrrrrr�sz?CoroutineTest.test_comp_4_2.<locals>.run_set.<locals>.<setcomp>r,)r:r)rOrrr�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�rjr3)r�)rYrrrrr�szACoroutineTest.test_comp_4_2.<locals>.run_dict.<locals>.<dictcomp>r,)r:r)rOrrr#�sz-CoroutineTest.test_comp_4_2.<locals>.run_dictr�rn�g)r4r$r-c�s2dd��td��2dH�}dd�|2dH�IdHS)NcSsL|y3dH}Wn
tk
s>Xd|ko,dknr|dVqYdS)Nrr�r3)r�)rYrrrrr&�s
z?CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<genexpr>r,c
�s2g|y3dH}Wn
tk
s&X|d�qYS)Nrj)r�)rYryrrrrZ�sz@CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<listcomp>)r:)rC)rOrrr'�sz,CoroutineTest.test_comp_4_2.<locals>.run_genr(�p�q)r5r)rrrr#r'r)rOr�
test_comp_4_2�s"zCoroutineTest.test_comp_4_2cs0dd���fdd�}|jt|��gdgf�dS)NcSsx|D]
}|VqWdS)Nr)r�rrrrrO�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)rr3Nr r)r�)rYZpairr)rOrrrZ�sz?CoroutineTest.test_comp_5.<locals>.run_list.<locals>.<listcomp>r3r�r �(rr)rOrrr�sz+CoroutineTest.test_comp_5.<locals>.run_listr)r5r)rrr)rOr�test_comp_5�s
zCoroutineTest.test_comp_5cs4dd���fdd�}|jt|��gdddgf�dS)NcSsx|D]
}|VqWdS)Nr)r�rrrrrO�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�)rY�seqrrrrrZ�sz?CoroutineTest.test_comp_6.<locals>.run_list.<locals>.<listcomp>r3r�r )r3r�)r rr)rOrrr�sz+CoroutineTest.test_comp_6.<locals>.run_listr4r��)r5r)rrr)rOr�test_comp_6�s
zCoroutineTest.test_comp_6c	s:dd���fdd�}|jtd��t|��WdQRXdS)NcSsdVdVtd��dS)Nrr�aaa)r�rrrrrO�sz$CoroutineTest.test_comp_7.<locals>.fc�sdd���2dH�IdHS)Nc
�s.g|y3dH}Wn
tk
s"X|�qYS)N)r�)rYrrrrrZ�sz?CoroutineTest.test_comp_7.<locals>.run_list.<locals>.<listcomp>rr)rOrrr�sz+CoroutineTest.test_comp_7.<locals>.run_listr7)rQr�r)rrr)rOr�test_comp_7�szCoroutineTest.test_comp_7cCs(dd�}|jt|��gdddgf�dS)Nc�sdd�dD�S)NcSsg|]}|�qSrr)rYrrrrrZ�sz8CoroutineTest.test_comp_8.<locals>.f.<locals>.<listcomp>rrr�)rrr�rrrrrrO�sz$CoroutineTest.test_comp_8.<locals>.frrr�)r5r)rrOrrr�test_comp_8�szCoroutineTest.test_comp_8cs2dd���fdd�}|jt|��gddgf�dS)NcSsdVdVdS)NrrrrrrrrC�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�)rYrrrrrZ�sz8CoroutineTest.test_comp_9.<locals>.f.<locals>.<listcomp>cSsg|]}|�qSrr)rYrrrrrZ�sr)�l)rCrrrO�sz$CoroutineTest.test_comp_9.<locals>.frr)r5r)rrOr)rCr�test_comp_9�s
zCoroutineTest.test_comp_9cCs*dd�}|jt|��gdddd�f�dS)Nc�sdd�dD�}dd�|D�S)	NcSsh|]}|�qSrr)rYrrrrr�sz8CoroutineTest.test_comp_10.<locals>.f.<locals>.<setcomp>rrr�cSsi|]
}||�qSrr)rY�xrrrr�sz9CoroutineTest.test_comp_10.<locals>.f.<locals>.<dictcomp>)rrr�r)ZxxrrrrO�sz%CoroutineTest.test_comp_10.<locals>.frrr�)rrr�)r5r)rrOrrr�test_comp_10�szCoroutineTest.test_comp_10cCsjdd�}|�}|jt��tj|�WdQRX|j�}z$|jt��tj|�WdQRXWd|j�XdS)Nc�sdS)Nrrrrrrs�sz%CoroutineTest.test_copy.<locals>.func)r(rW�copyr	rp)rrsrrrrr�	test_copy�szCoroutineTest.test_copycCs�dd�}|�}x>ttjd�D],}|jttjf��tj||�WdQRXqW|j�}zDx>ttjd�D],}|jttjf��tj||�WdQRXqhWWd|j�XdS)Nc�sdS)Nrrrrrrssz'CoroutineTest.test_pickle.<locals>.funcr)	r:�pickleZHIGHEST_PROTOCOLr(rWZ
PicklingError�dumpsr	rp)rrsr�protorrrr�test_pickleszCoroutineTest.test_picklecCs\dd�}tj��2tj��}tjd�|�tj�WdQRXWdQRX|jd|j��dS)Nc�sdS)Nrrrrrrssz3CoroutineTest.test_fatal_coro_warning.<locals>.funcr0zwas never awaited)rr rZcaptured_stderr�filterwarningsr"ru�getvalue)rrs�stderrrrr�test_fatal_coro_warnings
z%CoroutineTest.test_fatal_coro_warningN)Tr
rrrFrPrSrVr`rcrdrergrirrrwr{r|rr�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?rCrGrrrrrB�s�	

	#
		(	


"(@K\ 
	
rBc@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�rJrIrrrrO1sz/CoroAsyncIOCompatTest.test_asyncio_1.<locals>.frr)r�
import_moduler�Znew_event_loopZset_event_loopZrun_until_completerpr5)rrOZloopr)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)Nrfrrrrrr2Gsz5SysSetCoroWrapperTest.test_set_wrapper_1.<locals>.foocs|�|S)Nr)rC)�wrappedrrr�Ksz6SysSetCoroWrapperTest.test_set_wrapper_1.<locals>.wraprf)
r�r��get_coroutine_wrapper�set_coroutine_wrapperror=r5rr#rD)rr2r�rOr)rPr�test_set_wrapper_1Fs 

z(SysSetCoroWrapperTest.test_set_wrapper_1c	CsB|jtj��|jtd��tjd�WdQRX|jtj��dS)Nzcallable expected, got intr)r�r�rQrQrWrR)rrrr�test_set_wrapper_2csz(SysSetCoroWrapperTest.test_set_wrapper_2cCs`dd�}dd�}tj|�z4t��$|jtd��|�WdQRXWdQRXWdtjd�XdS)Nc�sdS)Nrfrrrrrr2jsz5SysSetCoroWrapperTest.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#rQrR)rr2rUrrr�test_set_wrapper_3is
z(SysSetCoroWrapperTest.test_set_wrapper_3csRtjdd��}d��fdd�}tj|�z|�|j�dd�Wdtjd�XdS)NcSsdS)Nrfrrrrrr2~sz5SysSetCoroWrapperTest.test_set_wrapper_4.<locals>.foocs|�|S)Nr)rC)rPrrr��sz6SysSetCoroWrapperTest.test_set_wrapper_4.<locals>.wrapzCgenerator-based coroutine was wrapped via sys.set_coroutine_wrapper)rIrbr�rRro)rr2r�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)�atrrr2�sz%CAPITest.test_tp_await_1.<locals>.foor)�	_testcapirYr5r)rr2r)r[r�test_tp_await_1�szCAPITest.test_tp_await_1cCs2ddlm}|tdg��}|jt|j��d�dS)Nr)rYr)r\rYr^r5rr	)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[rrr2�sz%CAPITest.test_tp_await_3.<locals>.fooz.__await__.*returned non-iterator of type 'int'r)r\rYrQrWr5r)rr2r)r[r�test_tp_await_3�s

zCAPITest.test_tp_await_3N)r
rrr]r^r_rrrrrX�s	rX�__main__)�
contextlibr>r>r@r�rIZunittestrZtestrrr
rr�contextmanagerr#ZTestCaser$r8rBrHrOZcpython_onlyrXr
r�rrrr�<module>sJ=*O