Your IP : 216.73.216.60


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_coroutines.cpython-35.pyc



��YfS��@s|ddlZddlZddlZddlZddlZddlZddlZddlZddlm	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��Zedkrxej�dS)�N)�supportc@s(eZdZdd�Zdd�ZdS)�AsyncYieldFromcCs
||_dS)N)�obj)�selfr�r�9/opt/alt/python35/lib64/python3.5/test/test_coroutines.py�__init__
szAsyncYieldFrom.__init__ccs|jEdHdS)N)r)rrrr�	__await__szAsyncYieldFrom.__await__N)�__name__�
__module__�__qualname__rr	rrrrrsrc@s(eZdZdd�Zdd�ZdS)�
AsyncYieldcCs
||_dS)N)�value)rrrrrrszAsyncYield.__init__ccs|jVdS)N)r)rrrrr	szAsyncYield.__await__N)r
rrrr	rrrrr
sr
cCs�|jtjtjhks!t�g}d}xcy|j|jd��Wq0tk
r�}z"|jru|jdnd}PWYdd}~Xq0Xq0W||fS)Nr)	�	__class__�types�
GeneratorType�
CoroutineType�AssertionError�append�send�
StopIteration�args)�coro�buffer�result�exrrr�	run_asyncs!rcCs�|jtjkst�|j�}g}d}d}x�yD|dr\|jt|��n|j|jd��|d7}Wq9tk
r�}z"|j	r�|j	dnd}PWYdd}~Xq9Xq9W||fS)Nr��)
rrrrr	r�nextrrr)r�awrr�irrrr�run_async__await__*s
r"c	cs4tj��!tjd�dVtj�WdQRXdS)N�ignore)�warnings�catch_warnings�simplefilterr�
gc_collectrrrr�silence_coro_gc=s

r(c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�AsyncBadSyntaxTestc	Cs*|jtd��ddl}WdQRXdS)Nz'await' outsider)�assertRaisesRegex�SyntaxErrorZtest.badsyntax_async1)r�testrrr�test_badsyntax_1Gsz#AsyncBadSyntaxTest.test_badsyntax_1c	Cs*|jtd��ddl}WdQRXdS)Nz'await' outsider)r*r+Ztest.badsyntax_async2)rr,rrr�test_badsyntax_2Ksz#AsyncBadSyntaxTest.test_badsyntax_2c	Cs*|jtd��ddl}WdQRXdS)Nzinvalid syntaxr)r*r+Ztest.badsyntax_async3)rr,rrr�test_badsyntax_3Osz#AsyncBadSyntaxTest.test_badsyntax_3c	Cs*|jtd��ddl}WdQRXdS)Nzinvalid syntaxr)r*r+Ztest.badsyntax_async4)rr,rrr�test_badsyntax_4Ssz#AsyncBadSyntaxTest.test_badsyntax_4c	Cs*|jtd��ddl}WdQRXdS)Nzinvalid syntaxr)r*r+Ztest.badsyntax_async5)rr,rrr�test_badsyntax_5Wsz#AsyncBadSyntaxTest.test_badsyntax_5c	Cs*|jtd��ddl}WdQRXdS)Nz'yield' inside async functionr)r*r+Ztest.badsyntax_async6)rr,rrr�test_badsyntax_6[s
z#AsyncBadSyntaxTest.test_badsyntax_6c	Cs*|jtd��ddl}WdQRXdS)Nz"'yield from' inside async functionr)r*r+Ztest.badsyntax_async7)rr,rrr�test_badsyntax_7as
z#AsyncBadSyntaxTest.test_badsyntax_7c	Cs*|jtd��ddl}WdQRXdS)Nzinvalid syntaxr)r*r+Ztest.badsyntax_async8)rr,rrr�test_badsyntax_8gsz#AsyncBadSyntaxTest.test_badsyntax_8cCsZi}xMddddhD]9}|jtd��tdj|�||�WdQRXqWdS)Nz(await a for a in b)z[await a for a in b]z{await a for a in b}z{await a: c for a in b}zawait.*in comprehenzasync def f():
	{})r*r+�exec�format)r�ns�comprrr�test_badsyntax_9ks
z#AsyncBadSyntaxTest.test_badsyntax_9cCs�ddddddddd	d
ddd
dddddddddddddddg}xO|D]G}|jd|��,|jt��t|dd�WdQRXWdQRXqaWdS) Nz]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>r5)ZsubTest�assertRaisesr+�compile)rZsamplesr:rrr�test_badsyntax_10us>			
#z$AsyncBadSyntaxTest.test_badsyntax_10cCs�dd�}|j|d�d�dd�}|j|d�d�dd�}|j|d�d�d	d�}|j|d�d�d
d�}|j|d�d�dd
�}d}|jtj|��dS)NcSs dd�}dd�}|dS)Nc�sdS)Nrrrrr�foo"sz>AsyncBadSyntaxTest.test_goodsyntax_1.<locals>.foo.<locals>.fooc�sdS)Nrrrrrr>#srr)�awaitr>rrrr>!sz1AsyncBadSyntaxTest.test_goodsyntax_1.<locals>.foo�
�cSs dd�}dd�}|dS)Nc�sdS)Nrrrrrr>)sz>AsyncBadSyntaxTest.test_goodsyntax_1.<locals>.foo.<locals>.fooc�sdS)Nrrrrrr>*srr)r?r>rrrr>(s��cSs dd�}dd�}|dS)Nc�sdS)Nrrrrrr>0sz>AsyncBadSyntaxTest.test_goodsyntax_1.<locals>.foo.<locals>.fooc�sdS)Nrrrrrr>2srr)r?r>rrrr>.scSs dd�}dd�}|dS)�spamc�sdS)Nrrrrrr>9sz>AsyncBadSyntaxTest.test_goodsyntax_1.<locals>.foo.<locals>.fooc�sdS)Nrrrrrr><srr)r?r>rrrr>7scs{dd�}dd�}�fdd�}|�y|�jd�Wn0tk
rv}z|jdSWYdd}~XnXdS)NcSsdS)Nrrrrrr>Bsz>AsyncBadSyntaxTest.test_goodsyntax_1.<locals>.foo.<locals>.foocSsdS)Nrrrrrr>Csc�s�S)Nrr)�await_rr�barDsz>AsyncBadSyntaxTest.test_goodsyntax_1.<locals>.foo.<locals>.barr)rrr)r?r>rFrr)rErr>As�*c�sdd�}tIdHdS)Nc�sdS)Nrrrrr�gMsz:AsyncBadSyntaxTest.test_goodsyntax_1.<locals>.f.<locals>.g)�z)rHrrr�fLsz/AsyncBadSyntaxTest.test_goodsyntax_1.<locals>.fr)�assertEqual�
assertTrue�inspect�iscoroutinefunction)rr>rJr?rrr�test_goodsyntax_1s	z$AsyncBadSyntaxTest.test_goodsyntax_1N)r
rrr-r.r/r0r1r2r3r4r9r=rOrrrrr)Es
�r)c@seZdZdd�ZdS)�TokenizerRegrTestcCs�g}x-td�D]}|jdjd|��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():
    returnr>)	�rangerr6�joinr5rKrLrMrN)rZbufr!r7rrr�test_oneline_defsUs
z#TokenizerRegrTest.test_oneline_defsN)r
rrrTrrrrrPSsrPc@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�S)��
CoroutineTestcCs&dd�}|jt|d��dS)Ncss	dVdS)Nrrrrr�genlsz%CoroutineTest.test_gen_1.<locals>.genr	)�assertFalse�hasattr)rrVrrr�
test_gen_1kszCoroutineTest.test_gen_1cCsdd�}|�}|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)Nr@rrrrrr>psz&CoroutineTest.test_func_1.<locals>.foor@cSsdS)NrrrrrrF}sz&CoroutineTest.test_func_1.<locals>.bar)�assertIsInstancerrrL�bool�__code__�co_flagsrMZCO_COROUTINErWZCO_GENERATOR�cr_coderKrr")rr>rJrFrrr�test_func_1os	    zCoroutineTest.test_func_1c	Cs7dd�}|jtd��t|��WdQRXdS)Nc�s
t�dS)N)rrrrrr>�sz&CoroutineTest.test_func_2.<locals>.foozcoroutine raised StopIteration)r*�RuntimeErrorr)rr>rrr�test_func_2�s
zCoroutineTest.test_func_2c
Cs:dd�}t��|jt|��d�WdQRXdS)Nc�s
t�dS)N)rrrrrr>�sz&CoroutineTest.test_func_3.<locals>.fooz^<coroutine object.* at 0x.*>$)r(�assertRegex�repr)rr>rrr�test_func_3�s
zCoroutineTest.test_func_3c:sdd�}�fdd�}|��t|��WdQRX|��t|��WdQRX|��t|��WdQRX|��t|��WdQRXt��*|��x|�D]}q�WWdQRXWdQRXt��*|��dd�|�D�WdQRXWdQRXdS)Nc�s
t�dS)N)rrrrrr>�sz&CoroutineTest.test_func_4.<locals>.foocs�jtd�S)Nz"'coroutine' object is not iterable)r*�	TypeErrorr)rrr�<lambda>�sz+CoroutineTest.test_func_4.<locals>.<lambda>cSsg|]}|�qSrr)�.0r!rrr�
<listcomp>�s	z-CoroutineTest.test_func_4.<locals>.<listcomp>)�list�tuple�sum�iterr()rr>�checkr!r)rr�test_func_4�s



zCoroutineTest.test_func_4cs�tjdd����fdd�}�fdd�}|��x|�D]}qMWWdQRXx!��D]}�j|d�qhW�jdd	���D�dg��jt���d
��jtt����d�dS)Ncss	dVdS)NrrrrrrrF�sz&CoroutineTest.test_func_5.<locals>.barc�s��IdHdS)Nrr)rFrrr>�sz&CoroutineTest.test_func_5.<locals>.foocs�jtd�S)Nz"'coroutine' object is not iterable)r*rer)rrrrf�sz+CoroutineTest.test_func_5.<locals>.<lambda>rcSsg|]}|�qSrr)rg�elrrrrh�s	z-CoroutineTest.test_func_5.<locals>.<listcomp>)r)r�	coroutinerKrjrrl)rr>rmror)rFrr�test_func_5�s
#zCoroutineTest.test_func_5c	s�tjdd����fdd�}|�}|j|jd�d�|j|jd�d�|jt��|jd�WdQRXdS)NcssdVdVdS)NrrrrrrrrF�sz&CoroutineTest.test_func_6.<locals>.barc�s��IdHdS)Nrr)rFrrr>�sz&CoroutineTest.test_func_6.<locals>.foorr)rrprKrr;r)rr>rJr)rFr�test_func_6�s	zCoroutineTest.test_func_6csZdd���fdd�}t��,|jtd��t|��WdQRXWdQRXdS)Nc�sdS)Nr@rrrrrrF�sz&CoroutineTest.test_func_7.<locals>.barc3s��EdHdS)Nrr)rFrrr>�sz&CoroutineTest.test_func_7.<locals>.foozCcannot 'yield from' a coroutine object in a non-coroutine generator)r(r*reri)rr>r)rFr�test_func_7�s
zCoroutineTest.test_func_7csJtj�fdd��}dd��|jt|��gdf�dS)Nc3s��EdHS)Nrr)r>rrrF�sz&CoroutineTest.test_func_8.<locals>.barc�sdS)NrDrrrrrr>�sz&CoroutineTest.test_func_8.<locals>.foorD)rrprKr)rrFr)r>r�test_func_8�szCoroutineTest.test_func_8c	Cs;dd�}|jtd��|�tj�WdQRXdS)Nc�sdS)Nrrrrrr>�sz&CoroutineTest.test_func_9.<locals>.fooz0coroutine '.*test_func_9.*foo' was never awaited)�assertWarnsRegex�RuntimeWarningrr')rr>rrr�test_func_9�s

zCoroutineTest.test_func_9csd�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)
Nrc3sLz:ydV}|dVWntk
r8�d7��YnXWd�d7�XdS)Nr�dr)�ZeroDivisionError)�a)�NrrrV�s


z'CoroutineTest.test_func_10.<locals>.genc�s��IdHdS)Nrr)rVrrr>�sz'CoroutineTest.test_func_10.<locals>.foor@rxr�f)rrpr	�assertIsrlrrKr�closer;ry�throw)rr>rr r)r{rVr�test_func_10�s"	

	
zCoroutineTest.test_func_10cCsqdd�}|�}|jdt|��|jdt|j���|jdt|j���|j�dS)Nc�sdS)Nrrrrr�funcsz(CoroutineTest.test_func_11.<locals>.funcr	�__iter__Zcoroutine_wrapper)�assertIn�dirr	rcr~)rr�rrrr�test_func_11s	zCoroutineTest.test_func_11c	sF�fdd�}|��|jtd���jd�WdQRXdS)Nc�s�jd�}tIdHdS)N)rr>)r!)�merrrHsz%CoroutineTest.test_func_12.<locals>.gzcoroutine already executing)r*�
ValueErrorr)rrHr)r�r�test_func_12s
		
zCoroutineTest.test_func_12c	Cs:dd�}|jtd��|�jd�WdQRXdS)Nc�sdS)NrrrrrrH%sz%CoroutineTest.test_func_13.<locals>.gz5can't send non-None value to a just-started coroutinerD)r*rer)rrHrrr�test_func_13$s

zCoroutineTest.test_func_13c	setjdd����fdd�}|�}|jd�|jtd��|j�WdQRXdS)Ncss	dVdS)NrrrrrrV.sz'CoroutineTest.test_func_14.<locals>.genc�s5y��IdHWntk
r0��IdHYnXdS)N)�
GeneratorExitr)rVrrr1s
z(CoroutineTest.test_func_14.<locals>.corozcoroutine ignored GeneratorExit)rrprr*r`r~)rr�cr)rVr�test_func_14-s	
	
zCoroutineTest.test_func_14cCsdd�}dd�}|�}|jtd��||�jd�WdQRX|jtd��||�jd�WdQRXdS)Nc�sdS)NrDrrrrr�spammer?sz+CoroutineTest.test_func_15.<locals>.spammerc�s	|IdHS)Nr)rrrr�readerAsz*CoroutineTest.test_func_15.<locals>.readerrDz&cannot reuse already awaited coroutine)r*rrr`)rr�r�Zspammer_cororrr�test_func_15<s		
zCoroutineTest.test_func_15cstjdd����fdd�}�fdd�}|�}||�}|jd�|jd�|jtd��|jtd��WdQRX||�}|jd�|jtd��|jd�WdQRX|jtd��|jtd	��WdQRXdS)
Ncss	dVdS)Nrrrrr�nopPsz'CoroutineTest.test_func_16.<locals>.nopc�s��IdHdS)NrDrr)r�rrrSsz(CoroutineTest.test_func_16.<locals>.sendc�s��IdH|IdHS)Nr)r)r�rr�readVsz(CoroutineTest.test_func_16.<locals>.read�hamz&cannot reuse already awaited coroutine�wat)rrprr*�	Exceptionrr`)rrr�r�r�r)r�r�test_func_16Ms"	


	
	
zCoroutineTest.test_func_16cCs�dd�}|�}|jtd��|jd�WdQRX|jtd��|jd�WdQRX|jtd��|jtd��WdQRX|j�|j�dS)Nc�sdS)NrDrrrrrrposz-CoroutineTest.test_func_17.<locals>.coroutinerDz&cannot reuse already awaited coroutiner�)r*rrr`rr�r~)rrprrrr�test_func_17ls		
	

zCoroutineTest.test_func_17c&Csdd�}|�}|j�}t|�}|jtd��|jd�WdQRX|jtd��|jd�WdQRX|jtd��t|�WdQRX|jtd��|jtd��WdQRX|jtd��|jtd��WdQRX|j	�|j	�dS)Nc�sdS)NrDrrrrrrp�sz-CoroutineTest.test_func_18.<locals>.coroutinerDz&cannot reuse already awaited coroutiner�)
r	rlr*rrr`rrr�r~)rrprZ
await_iter�itrrr�test_func_18�s(		
	
	
	

zCoroutineTest.test_func_18cs�d�tj�fdd����fdd�}|�}|jd�|jd�|j�d�|j�|j�d�x.td�D] }|j�|j�d�q�WdS)Nrc3s1dVy	dVWntk
r,�d7�YnXdS)Nr)r�r)�CHKrrr>�s
	
z'CoroutineTest.test_func_19.<locals>.fooc�s��IdHdS)Nrr)r>rrrp�sz-CoroutineTest.test_func_19.<locals>.coroutiner�)rrprrKr~rR)rrpr�_r)r�r>r�test_func_19�s		



zCoroutineTest.test_func_19cCs5dd�}t|��}|j|gdf�dS)Nc�sdS)Nr@)r@rrrrrr>�sz7CoroutineTest.test_coro_wrapper_send_tuple.<locals>.foor@)r@)r"rK)rr>rrrr�test_coro_wrapper_send_tuple�sz*CoroutineTest.test_coro_wrapper_send_tuplecCsJdd�}t|��}|j|dt�|j|djd�dS)Nc�s
td�S)Nr@)rrrrrr>�sz?CoroutineTest.test_coro_wrapper_send_stop_iterator.<locals>.foorr@)r"rZrrKr)rr>rrrr�$test_coro_wrapper_send_stop_iterator�sz2CoroutineTest.test_coro_wrapper_send_stop_iteratorc
stj��fdd����fdd�����fdd�}|���jtj��tj��j�j��jd��jtj��tj	��j�jjj
jd��jt
���jd�WdQRX�jtj��tj��j�j�dS)Nc3sa�jtj��tj��j�j�dV�jtj��tj��j�j�dS)N)rKrM�getcoroutinestateZCORO_RUNNING�assertIsNone�cr_awaitr)�coro_brrrrz�s
z&CoroutineTest.test_cr_await.<locals>.ac�s��IdHdS)Nrr)rzrrr��sz&CoroutineTest.test_cr_await.<locals>.cc�s0�j�j���IdH�j�j�dS)N)r�r�r)r�r�rrr�b�sz&CoroutineTest.test_cr_await.<locals>.brz)rrprKrMr�ZCORO_CREATEDr�r�rZCORO_SUSPENDED�gi_code�co_namer;rZCORO_CLOSED)rr�r)rzr�r�rr�
test_cr_await�s	
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rpc�sdS)NrrrrrrJ�sz(CoroutineTest.test_corotype_1.<locals>.fzcoroutine object)rrr�r�__doc__r~r�__dict__rKr
rc)rZctrJr�rrr�test_corotype_1�s		zCoroutineTest.test_corotype_1c	Cs7dd�}|jtd��t|��WdQRXdS)Nc�s
dIdHdS)Nrrrrrrr>sz'CoroutineTest.test_await_1.<locals>.foozobject int can.t.*await)r*rer)rr>rrr�test_await_1szCoroutineTest.test_await_1c	Cs7dd�}|jtd��t|��WdQRXdS)Nc�s
gIdHdS)Nrrrrrr>sz'CoroutineTest.test_await_2.<locals>.foozobject list can.t.*await)r*rer)rr>rrr�test_await_2szCoroutineTest.test_await_2cCs`dd�}|jt|��dddgdf�|jt|��dddgdf�dS)Nc�stdddg�IdHdS)Nrrr�)rrrrrr>sz'CoroutineTest.test_await_3.<locals>.foorrr�)rKrr")rr>rrr�test_await_3s(zCoroutineTest.test_await_3csAdd���fdd�}|jt|��gdf�dS)Nc�sdS)NrGrrrrrrFsz'CoroutineTest.test_await_4.<locals>.barc�s��IdHS)Nrr)rFrrr>sz'CoroutineTest.test_await_4.<locals>.foorG)rKr)rr>r)rFr�test_await_4szCoroutineTest.test_await_4c	sPGdd�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"sr�c�s��IdHS)Nrr)r�rrr>&sz'CoroutineTest.test_await_5.<locals>.fooz(__await__.*returned non-iterator of type)r*rer)rr>r)r�r�test_await_5!s

zCoroutineTest.test_await_5csKGdd�d���fdd�}|jt|��dgdf�dS)Nc@seZdZdd�ZdS)z-CoroutineTest.test_await_6.<locals>.AwaitablecSs
tdg�S)N�4)rl)rrrrr	0sz7CoroutineTest.test_await_6.<locals>.Awaitable.__await__N)r
rrr	rrrrr�/sr�c�s��IdHS)Nrr)r�rrr>3sz'CoroutineTest.test_await_6.<locals>.foor�)rKr)rr>r)r�r�test_await_6.szCoroutineTest.test_await_6csKGdd�d���fdd�}|jt|��dgdf�dS)Nc@seZdZdd�ZdS)z-CoroutineTest.test_await_7.<locals>.Awaitablecss	dVdS)NrGrxr)rrrrr	:sz7CoroutineTest.test_await_7.<locals>.Awaitable.__await__N)r
rrr	rrrrr�9sr�c�s��IdHS)Nrr)r�rrr>>sz'CoroutineTest.test_await_7.<locals>.foorGrx)rKr)rr>r)r�r�test_await_78szCoroutineTest.test_await_7c	sPGdd�d���fdd�}|jtd��t|��WdQRXdS)Nc@seZdZdS)z-CoroutineTest.test_await_8.<locals>.AwaitableN)r
rrrrrrr�Dsr�c�s��IdHS)Nrr)r�rrr>Gsz'CoroutineTest.test_await_8.<locals>.fooz4object Awaitable can't be used in 'await' expression)r*rer)rr>r)r�r�test_await_8Cs

zCoroutineTest.test_await_8cs��fdd��dd����fdd�}�fdd�}|jt|��gd	f�|jt|��gdf�dS)Ncs�S)Nrr)rFrr�wrapOsz(CoroutineTest.test_await_9.<locals>.wrapc�sdS)NrGrrrrrrFRsz'CoroutineTest.test_await_9.<locals>.barc�s���}d�fdd�i}G�fdd�d�}��IdH���IdH|d���IdH��IdHd|j��IdHS)Nr�cs�S)Nrr)r�rrrfXsz9CoroutineTest.test_await_9.<locals>.foo.<locals>.<lambda>cseZdZ�ZdS)z3CoroutineTest.test_await_9.<locals>.foo.<locals>.DBN)r
rrr�r)r�rr�DBZsr�i�)r�)r�Zdbr�)rFr�rrr>Us	z'CoroutineTest.test_await_9.<locals>.fooc�s
��IdHS)Nrr)rFrr�foo2`sz(CoroutineTest.test_await_9.<locals>.foo2i��rGi���)rKr)rr>r�r)rFr�r�test_await_9NszCoroutineTest.test_await_9csSdd���fdd���fdd�}|jt|��gdf�dS)Nc�sdS)NrGrrrrr�bazgsz(CoroutineTest.test_await_10.<locals>.bazc�s��S)Nrr)r�rrrFjsz(CoroutineTest.test_await_10.<locals>.barc�s��IdHIdHS)Nrr)rFrrr>msz(CoroutineTest.test_await_10.<locals>.foorG)rKr)rr>r)rFr�r�
test_await_10fszCoroutineTest.test_await_10csbdd��dd����fdd�}�fdd�}|jt|��gdf�dS)NcSs|S)Nr)�valrrr�identssz*CoroutineTest.test_await_11.<locals>.identc�sdS)NrDrrrrrrFvsz(CoroutineTest.test_await_11.<locals>.barc�s�d��IdH�S)Nr�rr)rFr�rrr>ysz(CoroutineTest.test_await_11.<locals>.fooc�s��IdHdfS)Nr�rr)rFrrr�|sz)CoroutineTest.test_await_11.<locals>.foo2rDr�)rDr�)rKr)rr>r�r)rFr�r�
test_await_11rs
zCoroutineTest.test_await_11c	sbdd��G�fdd�d���fdd�}|jtd��t|��WdQRXdS)Nc�sdS)NrDrrrrrr�sz)CoroutineTest.test_await_12.<locals>.corocs"eZdZ�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��sr�c�s��IdHS)Nrr)r�rrr>�sz(CoroutineTest.test_await_12.<locals>.fooz"__await__\(\) returned a coroutine)r*rer)rr>r)r�rr�
test_await_12�s
zCoroutineTest.test_await_12c	sPGdd�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��sr�c�s��IdHS)Nrr)r�rrr>�sz(CoroutineTest.test_await_13.<locals>.fooz(__await__.*returned non-iterator of type)r*rer)rr>r)r�r�
test_await_13�s

zCoroutineTest.test_await_13cs�Gdd�d��Gdd�d��Gdd�dt����fdd����fd	d
�}|�}|jd�|jtd��|jd�WdQRX|�}|jd�|j���|jt�WdQRXdS)Nc@s(eZdZdd�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�Wrapper�sr�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�sr�c@seZdZdS)z+CoroutineTest.test_await_14.<locals>.MarkerN)r
rrrrrr�Marker�sr�c�s/y��IdHSWntk
r*��YnXdS)N)ryr)r�r�rr�coro1�s
z*CoroutineTest.test_await_14.<locals>.coro1c�s����IdHS)Nrr)r�r�rr�coro2�sz*CoroutineTest.test_await_14.<locals>.coro2rD)r�rr*rr;rry)rr�r�r)r�r�r�r�r�
test_await_14�s	
	
zCoroutineTest.test_await_14c	sztjdd����fdd�}dd�}|�}|jd�|jtd��||�jd�WdQRXdS)Ncss	dVdS)Nrrrrrr��sz(CoroutineTest.test_await_15.<locals>.nopc�s��IdHdS)Nrr)r�rrrp�sz.CoroutineTest.test_await_15.<locals>.coroutinec�s
|IdHdS)Nr)rrrr�waiter�sz+CoroutineTest.test_await_15.<locals>.waiterz"coroutine is being awaited already)rrprr*r`)rrpr�rr)r�r�
test_await_15�s	
	
zCoroutineTest.test_await_15csGdd���fdd�}t|��\}}|j|j�dS)Nc�st�S)N)r�rrrrrJ�sz&CoroutineTest.test_await_16.<locals>.fc	�s%y
t�Wn��IdHSYnXdS)N)�KeyErrorr)rJrrrH�s
z&CoroutineTest.test_await_16.<locals>.g)rr��__context__)rrHr�rr)rJr�
test_await_16�szCoroutineTest.test_await_16cs�Gdd�d���fdd�}|�}t|�\}}|j|ddddddd
ddg	��fdd�}|jt��t|��WdQRXdS)Nc@s4eZdZdd�Zdd�Zdd�ZdS)z*CoroutineTest.test_with_1.<locals>.ManagercSs
||_dS)N)�name)rr�rrrr�sz3CoroutineTest.test_with_1.<locals>.Manager.__init__c�s'td|jd|jg�IdH|S)Nzenter-1-zenter-2-)rr�)rrrr�
__aenter__�s
z5CoroutineTest.test_with_1.<locals>.Manager.__aenter__c�s:td|jd|jg�IdH|jdkr6dSdS)Nzexit-1-zexit-2-�BT)rr�)rrrrr�	__aexit__�s
z4CoroutineTest.test_with_1.<locals>.Manager.__aexit__N)r
rrrr�r�rrrr�Manager�sr�c�so�d�4IdH�Q}�d�4IdH�0}td|j|jfg�IdHddWdQIdHRXWdQIdHRXdS)N�Ar��managersrr)rr�)rzr�)r�rrr>�s*!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�so�d�4IdH�Q}�d�4IdH�0}td|j|jfg�IdHddWdQIdHRXWdQIdHRXdS)Nr��Cr�rr)rr�)rzr�)r�rrr>s*!)r�r�r�)rrKr;ry)rr>rJrr�r)r�r�test_with_1�s	zCoroutineTest.test_with_1c	sPGdd�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
sr�c
�s ��4IdH�WdQIdHRXdS)Nrr)r�rrr>sz&CoroutineTest.test_with_2.<locals>.foor�)r*�AttributeErrorr)rr>r)r�r�test_with_2	szCoroutineTest.test_with_2c	sPGdd�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�sr�c
�s ��4IdH�WdQIdHRXdS)Nrr)r�rrr>sz&CoroutineTest.test_with_3.<locals>.foor�)r*r�r)rr>r)r�r�test_with_3szCoroutineTest.test_with_3c	sPGdd�d���fdd�}|jtd��t|��WdQRXdS)Nc@s(eZdZdd�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�"sr�c
�s ��4IdH�WdQIdHRXdS)Nrr)r�rrr>)sz&CoroutineTest.test_with_4.<locals>.foor�)r*r�r)rr>r)r�r�test_with_4!szCoroutineTest.test_with_4c	sMGdd�d���fdd�}|jt��t|��WdQRXdS)Nc@s(eZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_5.<locals>.CMc�s|S)Nr)rrrrr�6sz0CoroutineTest.test_with_5.<locals>.CM.__aenter__c�sdS)Nr)r�excrrrr�9sz/CoroutineTest.test_with_5.<locals>.CM.__aexit__N)r
rrr�r�rrrrr�5sr�c
�s2��4IdH�ddks"t�WdQIdHRXdS)Nr)r)rr)r�rrr�<sz'CoroutineTest.test_with_5.<locals>.func)r;rr)rr�r)r�r�test_with_50szCoroutineTest.test_with_5c	sPGdd�d���fdd�}|jtd��t|��WdQRXdS)Nc@s(eZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_6.<locals>.CMcSsdS)N�{r)rrrrr�Esz0CoroutineTest.test_with_6.<locals>.CM.__aenter__cWsdS)Ni�r)r�errrr�Hsz/CoroutineTest.test_with_6.<locals>.CM.__aexit__N)r
rrr�r�rrrrr�Dsr�c
�s ��4IdH�WdQIdHRXdS)Nrr)r�rrr>Ksz&CoroutineTest.test_with_6.<locals>.fooz.object int can't be used in 'await' expression)r*rer)rr>r)r�r�test_with_6Cs

zCoroutineTest.test_with_6cs�Gdd�d���fdd�}yt|��Wnktk
r�}zK|j|jdd�|j|jdk	�|jt|jt��WYdd}~XnX|jd�dS)Nc@s(eZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_7.<locals>.CMc�s|S)Nr)rrrrr�Vsz0CoroutineTest.test_with_7.<locals>.CM.__aenter__cWsdS)Ni�r)rr�rrrr�Ysz/CoroutineTest.test_with_7.<locals>.CM.__aexit__N)r
rrr�r�rrrrr�Usr�c
�s(��4IdH�
ddWdQIdHRXdS)Nrrrr)r�rrr>\sz&CoroutineTest.test_with_7.<locals>.foorz.object int can't be used in 'await' expressionz1invalid asynchronous context manager did not fail)	rrerbrrLr��
isinstancery�fail)rr>r�r)r�r�test_with_7Ts,zCoroutineTest.test_with_7c
sid�Gdd�d����fdd�}|jtd��t|��WdQRX|j�d�dS)Nrc@s(eZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_8.<locals>.CMc�s|S)Nr)rrrrr�osz0CoroutineTest.test_with_8.<locals>.CM.__aenter__cWsdS)Ni�r)rr�rrrr�rsz/CoroutineTest.test_with_8.<locals>.CM.__aexit__N)r
rrr�r�rrrrr�nsr�c
�s*��4IdH��d7�WdQIdHRXdS)Nrrr)r��CNTrrr>usz&CoroutineTest.test_with_8.<locals>.fooz.object int can't be used in 'await' expressionr)r*rerrK)rr>r)r�r�r�test_with_8ks
zCoroutineTest.test_with_8c
sfd�Gdd�d����fdd�}|jt��t|��WdQRX|j�d�dS)Nrc@s(eZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_9.<locals>.CMc�s|S)Nr)rrrrr��sz0CoroutineTest.test_with_9.<locals>.CM.__aenter__c�sdddS)Nrrr)rr�rrrr��sz/CoroutineTest.test_with_9.<locals>.CM.__aexit__N)r
rrr�r�rrrrr��sr�c
�s*��4IdH��d7�WdQIdHRXdS)Nrrr)r�r�rrr>�sz&CoroutineTest.test_with_9.<locals>.foor)r;ryrrK)rr>r)r�r�r�test_with_9�szCoroutineTest.test_with_9cs�d�Gdd�d����fdd�}yt|��Wnptk
r�}zP|j|jdk	�|jt|jt��|jt|jjt��WYdd}~XnX|jd�dS)Nrc@s(eZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_10.<locals>.CMc�s|S)Nr)rrrrr��sz1CoroutineTest.test_with_10.<locals>.CM.__aenter__c�sdddS)Nrrr)rr�rrrr��sz0CoroutineTest.test_with_10.<locals>.CM.__aexit__N)r
rrr�r�rrrrr��sr�c�sB��4IdH�'��4IdH�t�WdQIdHRXWdQIdHRXdS)N)r`r)r�r�rrr>�sz'CoroutineTest.test_with_10.<locals>.fooz*exception from __aexit__ did not propagate)rryrLr�r�r`r�)rr>r�r)r�r�r�test_with_10�szCoroutineTest.test_with_10cs�d�Gdd�d����fdd�}yt|��Wn;tk
r|}z|j|jdk�WYdd}~XnX|jd�dS)Nrc@s(eZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_11.<locals>.CMc�s
t�dS)N)�NotImplementedError)rrrrr��sz1CoroutineTest.test_with_11.<locals>.CM.__aenter__c�sdddS)Nrrr)rr�rrrr��sz0CoroutineTest.test_with_11.<locals>.CM.__aexit__N)r
rrr�r�rrrrr��sr�c
�s&��4IdH�t�WdQIdHRXdS)N)r`r)r�r�rrr>�sz'CoroutineTest.test_with_11.<locals>.fooz+exception from __aenter__ did not propagate)rr�rLr�r�)rr>r�r)r�r�r�test_with_11�s)zCoroutineTest.test_with_11csBd�Gdd�d�����fdd�}t|��dS)Nrc@s(eZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_12.<locals>.CMc�s|S)Nr)rrrrr��sz1CoroutineTest.test_with_12.<locals>.CM.__aenter__c�sdS)NTr)rr�rrrr��sz0CoroutineTest.test_with_12.<locals>.CM.__aexit__N)r
rrr�r�rrrrr��sr�c
�s;��4IdH� }�j|j��t�WdQIdHRXdS)N)r}rr`)�cm)r�r�rrrr>�sz'CoroutineTest.test_with_12.<locals>.foo)r)rr>r)r�r�rr�test_with_12�szCoroutineTest.test_with_12c
sfd�Gdd�d����fdd�}|jt��t|��WdQRX|j�d�dS)Nrc@s(eZdZdd�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��sr�c
�s>�d7���4IdH��d7�WdQIdHRX�d7�dS)Nri�i'rr)r�r�rrr>�s
z'CoroutineTest.test_with_13.<locals>.foor)r;ryrrK)rr>r)r�r�r�test_with_13�szCoroutineTest.test_with_13cs�d�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__�s
z5CoroutineTest.test_for_1.<locals>.AsyncIter.__aiter__c�sW|jd7_|jds2t|jd�IdH|jdkrGt�|j|jfS)Nrr@rx)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�sl�jtd��SxK��2dHy3dH\}}Wntk
rHYWqaX�j||�q!WqaWdQRXdS)N�legacy)ru�PendingDeprecationWarningr�r)Zi1Zi2)r�rrrr�test1s6z'CoroutineTest.test_for_1.<locals>.test1rcSsg|]}|d�qS)rxr)rgr!rrrrhs	z,CoroutineTest.test_for_1.<locals>.<listcomp>rAcSsg|]}|d�qS)rr)rgr!rrrrhs	�ec�s��jtd��kxc��2dHy3dH}Wntk
rBYWqlX�j|d�|ddkr!Pq!Wqy�jd�WdQRX�jd�dS)Nr�rrBzwhat?�end)rur�r�r)r!)r�rrrr�test2s0z'CoroutineTest.test_for_1.<locals>.test2rrx��cSsg|]}|�qSrr)rgr!rrrrh#s	�r�c�s��jtd��mxe��2dHy3dH}Wntk
rBYWqnX|ddkrVq!�j|d�q!Wq{�jd�WdQRX�jd�dS)Nr�rrBzwhat?r�)rur�r�r)r!)r�rrrr�test3's0z'CoroutineTest.test_for_1.<locals>.test3r�cSsg|]}|d�qS)rxr)rgr!rrrrh5s	cSsg|]}|�qSrr)rgr!rrrrh6s	zwhat?)rrKrR)rr�Zyieldedr�r�r�r)r�r�rrr�
test_for_1�s*&&-&"zCoroutineTest.test_for_1c
skd�tj��}�fdd�}|jtd��t|��WdQRX|jtj��|�dS)Nrrr�c�sBx;�2dHy3dH}Wntk
r,YWq>Xtd�qWq>dS)Nznever going to happen)r��print)r!)�tuprrr>=s-z%CoroutineTest.test_for_2.<locals>.fooz/async for' requires an object.*__aiter__.*tuple)rrr�)�sys�getrefcountr*rerrK)r�refs_beforer>r)r�r�
test_for_29s
zCoroutineTest.test_for_2c
s�Gdd�d�}|��tj��}�fdd�}|jtd��t|��WdQRX|jtj��|�dS)Nc@seZdZdd�ZdS)z#CoroutineTest.test_for_3.<locals>.IcSs|S)Nr)rrrrr�Jsz-CoroutineTest.test_for_3.<locals>.I.__aiter__N)r
rrr�rrrr�IIsrc�sBx;�2dHy3dH}Wntk
r,YWq>Xtd�qWq>dS)Nznever going to happen)r�r�)r!)�aiterrrr>Ps-z%CoroutineTest.test_for_3.<locals>.fooz4async for' received an invalid object.*__aiter.*\: I)r�r�r*rerrK)rrr�r>r)rr�
test_for_3Hs	
zCoroutineTest.test_for_3c
s�Gdd�d�}|��tj��}�fdd�}|jtd��t|��WdQRX|jtj��|�dS)Nc@s(eZdZdd�Zdd�ZdS)z#CoroutineTest.test_for_4.<locals>.IcSs|S)Nr)rrrrr�^sz-CoroutineTest.test_for_4.<locals>.I.__aiter__cSsfS)Nr)rrrrr�asz-CoroutineTest.test_for_4.<locals>.I.__anext__N)r
rrr�r�rrrrr]src�sBx;�2dHy3dH}Wntk
r,YWq>Xtd�qWq>dS)Nznever going to happen)r�r�)r!)rrrr>gs-z%CoroutineTest.test_for_4.<locals>.fooz7async for' received an invalid object.*__anext__.*tuple)r�r�r*rerrK)rrr�r>r)rr�
test_for_4\s	
zCoroutineTest.test_for_4c	sSGdd�d����fdd�}�jtd��t|��WdQRXdS)Nc@s(eZdZdd�Zdd�ZdS)z#CoroutineTest.test_for_5.<locals>.Ic�s|S)Nr)rrrrr�usz-CoroutineTest.test_for_5.<locals>.I.__aiter__cSsdS)Nr�r)rrrrr�xsz-CoroutineTest.test_for_5.<locals>.I.__anext__N)r
rrr�r�rrrrrtsrc�s_�jtd��Fx>��2dHy3dH}Wntk
rBYWqTXtd�q!WqTWdQRXdS)Nr�znever going to happen)rur�r�r�)r!)rrrrr>{s0z%CoroutineTest.test_for_5.<locals>.fooz3async for' received an invalid object.*__anext.*int)r*rer)rr>r)rrr�
test_for_5ss
zCoroutineTest.test_for_5c
sXd�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)Nrcs4eZdZ�fdd�Z�fdd�ZdS)z)CoroutineTest.test_for_6.<locals>.Managerc�s�d7�dS)Ni'r)r)rrrr��sz4CoroutineTest.test_for_6.<locals>.Manager.__aenter__c�s�d7�dS)Ni��r)rr)rrrr��sz3CoroutineTest.test_for_6.<locals>.Manager.__aexit__N)r
rrr�r�r)rrrr��sr�c@s4eZdZdd�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��sz4CoroutineTest.test_for_6.<locals>.Iterable.__aiter__c�s+|jdkrt�|jd7_|jS)Nr@r)r!r�)rrrrr��sz4CoroutineTest.test_for_6.<locals>.Iterable.__anext__N)r
rrrr�r�rrrr�Iterable�src�se�4IdH�Cx;�2dHy3dH}Wntk
r9YWqKX�d7�qWqKWdQIdHRX�d7�dS)Nri�)r�)r!)r�iterable�managerrr�main�s
-z&CoroutineTest.test_for_6.<locals>.main�errori��c!�s���4IdH�Fx>��2dHy3dH}Wntk
r?YWqQX�d7�qWqQWdQIdHRX�d7���4IdH�Fx>��2dHy3dH}Wntk
r�YWq�X�d7�q�Wq�WdQIdHRX�d7�dS)Nri�)r�)r!)rrr�rrr�s0
0i�c!�s���4IdH�Z�d7�xH��2dHy3dH}Wntk
rIYWq[X�d7�q(Wqe�d7�WdQIdHRX�d7���4IdH�Z�d7�xH��2dHy3dH}Wntk
r�YWq�X�d7�q�Wq��d7�WdQIdHRX�d7�dS)Nrxri���i�)r�)r!)rrr�rrr�s
0

0i��9)r�r�r$r%r&rrK)rZmrefs_beforeZirefs_beforerr)rrr�rrr�
test_for_6�s(			




zCoroutineTest.test_for_6c
sid�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�src�si�jtd��Fx>��2dHy3dH}Wntk
rBYWqTX�d7�q!WqTWdQRX�d7�dS)Nr�rr@)rur�r�)r!)rr�rrrr>�s0z%CoroutineTest.test_for_7.<locals>.foo)r;ryrrK)rr>r)rr�rr�
test_for_7�szCoroutineTest.test_for_7cs�d�Gdd�d����fdd�}|jt��3tj��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�src�sOx>��2dHy3dH}Wntk
r/YWqAX�d7�qWqA�d7�dS)Nrr@)r�)r!)rr�rrr>�s0z%CoroutineTest.test_for_8.<locals>.foor	)r;ryr$r%r&rrK)rr>r)rr�r�
test_for_8�s

zCoroutineTest.test_for_8csnGdd�d���fdd�}|jt��3tj��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�rrrrrsrc�s;x4��2dHy3dH}Wqtk
r/YWq7XqWq7dS)N)r�)r!)rrrr>
s0z%CoroutineTest.test_for_9.<locals>.foor	)r;r�r$r%r&r)rr>r)rr�
test_for_9s

zCoroutineTest.test_for_9csnGdd�d���fdd�}|jt��3tj��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�rrrrrsrc�s;x4��2dHy3dH}Wqtk
r/YWq7XqWq7dS)N)r�)r!)rrrr>s0z&CoroutineTest.test_for_10.<locals>.foor	)r;r�r$r%r&r)rr>r)rr�test_for_10s

zCoroutineTest.test_for_10c
s�Gdd�dt��Gdd�dt��g����fdd�}|j���|�jd�WdQRX|j�dg�dS)Nc@seZdZdS)z*CoroutineTest.test_for_tuple.<locals>.DoneN)r
rrrrrr�Done#src@s.eZdZdZdd�Zdd�ZdS)z+CoroutineTest.test_for_tuple.<locals>.AIterrcSs|S)Nr)rrrrr�'sz5CoroutineTest.test_for_tuple.<locals>.AIter.__aiter__c�s9|jt|�krt�|jd7_||jdS)Nr)r!�lenr�)rrrrr�)sz5CoroutineTest.test_for_tuple.<locals>.AIter.__anext__N)r
rrr!r�r�rrrr�AIter%src�sTxG�dg�2dHy3dH}Wntk
r5YWqJX�j|�qWqJ��dS)NrG)r�r)r!)rrrrrr>0s6z)CoroutineTest.test_for_tuple.<locals>.foorG)r�rjr;rrK)rr>r)rrrr�test_for_tuple"s
zCoroutineTest.test_for_tuplec
s�Gdd�dt��Gdd�dt��g����fdd�}|j���|�jd�WdQRX|j�dg�dS)Nc@seZdZdS)z3CoroutineTest.test_for_stop_iteration.<locals>.DoneN)r
rrrrrrr:src@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%|jrt�|jd7_|jS)Nr)r!r�r)rrrrr�@s	z>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__anext__N)r
rrr!r�r�rrrrr<src�sQxD�d�2dHy3dH}Wntk
r2YWqGX�j|�qWqG��dS)NrG)r�r)r!)rrrrrr>Gs3z2CoroutineTest.test_for_stop_iteration.<locals>.foorG)r�rr;rrK)rr>r)rrrr�test_for_stop_iteration9s
z%CoroutineTest.test_for_stop_iterationcCsdd�}|�}|jt��tj|�WdQRX|j�}z(|jt��tj|�WdQRXWd|j�XdS)Nc�sdS)Nrrrrrr�Qsz%CoroutineTest.test_copy.<locals>.func)r;re�copyr	r~)rr�rr rrr�	test_copyPs	zCoroutineTest.test_copycCs�dd�}|�}xKttjd�D]6}|jttjf��tj||�WdQRXq)W|j�}zRxKttjd�D]6}|jttjf��tj||�WdQRXq�WWd|j�XdS)Nc�sdS)Nrrrrrr�^sz'CoroutineTest.test_pickle.<locals>.funcr)	rR�pickleZHIGHEST_PROTOCOLr;reZ
PicklingError�dumpsr	r~)rr�r�protor rrr�test_pickle]s	zCoroutineTest.test_picklecCsndd�}tj��9tj��%}tjd�|�tj�WdQRXWdQRX|jd|j��dS)Nc�sdS)Nrrrrrr�nsz3CoroutineTest.test_fatal_coro_warning.<locals>.funcr	zwas never awaited)r$r%rZcaptured_stderr�filterwarningsr'r��getvalue)rr��stderrrrr�test_fatal_coro_warningls
z%CoroutineTest.test_fatal_coro_warningN)Gr
rrrYr_rardrnrqrrrsrtrwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
rr
rrrrrrrrrrrrUis�	

	#
		(	


"(K\
rUc@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@seZdZdS)z9CoroAsyncIOCompatTest.test_asyncio_1.<locals>.MyExceptionN)r
rrrrrr�MyException}sr!cs:eZdZ��fdd�Z��fdd�ZdS)z0CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CMc�s0�jd��jd�IdH�jd�|S)Nrg{�G�z�?r)r�sleep)r)r rrrr��s

z;CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aenter__c�s&�jd�IdH�j|j�dS)Ng{�G�z�?)r"rr
)r�exc_typeZexc_valZexc_tb)r rrrr��sz:CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aexit__N)r
rrr�r�r)r rrrr��sr�c
�sG��4IdH�}�jd�IdH��WdQIdHRX�jd�dS)Ng{�G�z�?Zunreachable)r"r)r�)r�r!r rrrrJ�sz/CoroAsyncIOCompatTest.test_asyncio_1.<locals>.frr)r�
import_moduler�Znew_event_loopZset_event_loopZrun_until_completer~rK)rrJZloopr)r�r!r rr�test_asyncio_1xs

	
z$CoroAsyncIOCompatTest.test_asyncio_1N)r
rrr%rrrrrvsrc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�SysSetCoroWrapperTestcs�dd�}d��fdd�}|jtj��tj|�|jtj�|�z6|�}|j��|jt|�gdf�Wdtjd�X|jtj��d�t��|�WdQRX|j	��dS)Nc�sdS)NrDrrrrrr>�sz5SysSetCoroWrapperTest.test_set_wrapper_1.<locals>.foocs
|�|S)Nr)rV)�wrappedrrr��sz6SysSetCoroWrapperTest.test_set_wrapper_1.<locals>.wraprD)
r�r��get_coroutine_wrapper�set_coroutine_wrapperr}rLrKrr(rW)rr>r�rJr)r'r�test_set_wrapper_1�s 
	
 
z(SysSetCoroWrapperTest.test_set_wrapper_1c	CsQ|jtj��|jtd��tjd�WdQRX|jtj��dS)Nzcallable expected, got intr)r�r�r(r*rer))rrrr�test_set_wrapper_2�sz(SysSetCoroWrapperTest.test_set_wrapper_2cCspdd�}dd�}tj|�z6t��&|jtd��|�WdQRXWdQRXWdtjd�XdS)Nc�sdS)NrDrrrrrr>�sz5SysSetCoroWrapperTest.test_set_wrapper_3.<locals>.foocSsdd�}||�S)Nc�s	|IdHS)Nr)rrrrr��szGSysSetCoroWrapperTest.test_set_wrapper_3.<locals>.wrapper.<locals>.wrapr)rr�rrr�wrapper�sz9SysSetCoroWrapperTest.test_set_wrapper_3.<locals>.wrapperzLcoroutine wrapper.*\.wrapper at 0x.*attempted to recursively wrap .* wrap .*)r�r)r(r*r`)rr>r,rrr�test_set_wrapper_3�s

z(SysSetCoroWrapperTest.test_set_wrapper_3csmtjdd��}d��fdd�}tj|�z|�|j�dd�Wdtjd�XdS)NcSsdS)NrDrrrrrr>�sz5SysSetCoroWrapperTest.test_set_wrapper_4.<locals>.foocs
|�|S)Nr)rV)r'rrr��sz6SysSetCoroWrapperTest.test_set_wrapper_4.<locals>.wrapzCgenerator-based coroutine was wrapped via sys.set_coroutine_wrapper)rrpr�r)r})rr>r�r)r'r�test_set_wrapper_4�s
z(SysSetCoroWrapperTest.test_set_wrapper_4N)r
rrr*r+r-r.rrrrr&�sr&c@s4eZdZdd�Zdd�Zdd�ZdS)�CAPITestcsBddlm��fdd�}|j|�jd�d�dS)Nr)�	awaitTypec�s�tdg��}|IdHS)Nr)rl)�future)�atrrr>�sz%CAPITest.test_tp_await_1.<locals>.foor)�	_testcapir0rKr)rr>r)r2r�test_tp_await_1�szCAPITest.test_tp_await_1cCsEddlm}|tdg��}|jt|j��d�dS)Nr)r0r)r3r0rlrKrr	)rr2r1rrr�test_tp_await_2�szCAPITest.test_tp_await_2c
s\ddlm��fdd�}|jtd��!|j|�jd�d�WdQRXdS)Nr)r0c�s�d�}|IdHS)Nrr)r1)r2rrr>sz%CAPITest.test_tp_await_3.<locals>.fooz.__await__.*returned non-iterator of type 'int'r)r3r0r*rerKr)rr>r)r2r�test_tp_await_3s

zCAPITest.test_tp_await_3N)r
rrr4r5r6rrrrr/�s	r/�__main__)�
contextlibrrMrr�rZunittestr$r,rrr
rr"�contextmanagerr(ZTestCaser)rPrUrr&Zcpython_onlyr/r
rrrrr�<module>s8������*O