HEX
Server: LiteSpeed
System: Linux server.nevid-deploma.com 4.18.0-553.111.1.lve.el8.x86_64 #1 SMP Fri Mar 13 13:42:17 UTC 2026 x86_64
User: smilepac (1037)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cppython/lib/python3.8/test/__pycache__/test_coroutines.cpython-38.pyc
U

.D�g��@s,ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZGdd�d�ZGdd�d�Z
dd	�Zd
d�Zejdd
��ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Ze	jGdd�dej��Zedk�r(e��dS)�N)�support��assert_python_okc@seZdZdd�Zdd�ZdS)�AsyncYieldFromcCs
||_dS�N��obj)�selfr�r
�3/opt/cppython/lib/python3.8/test/test_coroutines.py�__init__szAsyncYieldFrom.__init__ccs|jEdHdSrr�r	r
r
r�	__await__szAsyncYieldFrom.__await__N��__name__�
__module__�__qualname__rrr
r
r
rr
src@seZdZdd�Zdd�ZdS)�
AsyncYieldcCs
||_dSr��value)r	rr
r
rrszAsyncYield.__init__ccs|jVdSrrr
r
r
rrszAsyncYield.__await__Nrr
r
r
rrsrc
Cs||jtjtjhkst�g}d}z|�|�d��Wqtk
rp}z |jrT|jdnd}WY�qtW5d}~XYqXq||fS�Nr)	�	__class__�types�
GeneratorType�
CoroutineType�AssertionError�append�send�
StopIteration�args)�coro�buffer�result�exr
r
r�	run_asyncsr$c
Cs�|jtjkst�|��}g}d}d}z4|dr>|�t|��n|�|�d��|d7}Wq$tk
r�}z |j	rz|j	dnd}WY�q�W5d}~XYq$Xq$||fS)Nr��)
rrrrrr�nextrrr)r �awr!r"�ir#r
r
r�run_async__await__+sr*c	cs0t���t�d�dVt��W5QRXdS)N�ignore)�warnings�catch_warnings�simplefilterr�
gc_collectr
r
r
r�silence_coro_gc>s

r0c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�AsyncBadSyntaxTestc;Cs�ddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;g;}|D]>}|j|d<��(|�t��t|d=d>�W5QRXW5QRXq~dS)?Nz9def foo():
                await something()
            zawait something()z;async def foo():
                yield from []
            z=async def foo():
                await await fut
            zEasync def foo(a=await something()):
                pass
            zEasync def foo(a:await something()):
                pass
            z`async def foo():
                def bar():
                 [i async for i in els]
            z`async def foo():
                def bar():
                 [await i for i in els]
            z�async def foo():
                def bar():
                 [i for i in els
                    async for b in els]
            z�async def foo():
                def bar():
                 [i for i in els
                    for c in b
                    async for b in els]
            z�async def foo():
                def bar():
                 [i for i in els
                    async for b in els
                    for c in b]
            z�async def foo():
                def bar():
                 [i for i in els
                    for b in await els]
            z�async def foo():
                def bar():
                 [i for i in els
                    for b in els
                        if await b]
            z`async def foo():
                def bar():
                 [i for i in await els]
            zeasync def foo():
                def bar():
                 [i for i in els if await i]
            z?def bar():
                 [i async for i in els]
            zBdef bar():
                 {i: i async for i in els}
            z?def bar():
                 {i async for i in els}
            z?def bar():
                 [await i for i in els]
            z`def bar():
                 [i for i in els
                    async for b in els]
            zdef bar():
                 [i for i in els
                    for c in b
                    async for b in els]
            zdef bar():
                 [i for i in els
                    async for b in els
                    for c in b]
            z`def bar():
                 [i for i in els
                    for b in await els]
            z}def bar():
                 [i for i in els
                    for b in els
                        if await b]
            z?def bar():
                 [i for i in await els]
            zDdef bar():
                 [i for i in els if await i]
            z3async def foo():
                await
            z]async def foo():
                   def bar(): pass
                   await = 1
            z^async def foo():

                   def bar(): pass
                   await = 1
            zzasync def foo():
                   def bar(): pass
                   if 1:
                       await = 1
            zxdef foo():
                   async def bar(): pass
                   if 1:
                       await a
            z[def foo():
                   async def bar(): pass
                   await a
            z~def foo():
                   def baz(): pass
                   async def bar(): pass
                   await a
            z�def foo():
                   def baz(): pass
                   # 456
                   async def bar(): pass
                   # 123
                   await a
            z�async def foo():
                   def baz(): pass
                   # 456
                   async def bar(): pass
                   # 123
                   await = 2
            z�def foo():

                   def baz(): pass

                   async def bar(): pass

                   await a
            z�async def foo():

                   def baz(): pass

                   async def bar(): pass

                   await = 2
            zBasync def foo():
                   def async(): pass
            zBasync def foo():
                   def await(): pass
            zXasync def foo():
                   def bar():
                       await
            zKasync def foo():
                   return lambda async: await
            zGasync def foo():
                   return lambda a: await
            z	await a()z>async def foo(a=await b):
                   pass
            z>async def foo(a:await b):
                   pass
            z`def baz():
                   async def foo(a=await b):
                       pass
            z:async def foo(async):
                   pass
            z�async def foo():
                   def bar():
                        def baz():
                            async = 1
            z�async def foo():
                   def bar():
                        def baz():
                            pass
                        async = 1
            z�def foo():
                   async def bar():

                        async def baz():
                            pass

                        def baz():
                            42

                        async = 1
            z�async def foo():
                   def bar():
                        def baz():
                            pass
await foo()
            z�def foo():
                   def bar():
                        async def baz():
                            pass
await foo()
            z:async def foo(await):
                   pass
            z]def foo():

                   async def bar(): pass

                   await a
            z`def foo():
                   async def bar():
                        pass
await a
            z`def foo():
                   async for i in arange(2):
                       pass
            z[def foo():
                   async with resource:
                       pass
            z9async with resource:
                   pass
            z>async for i in arange(2):
                   pass
            ��code�<test>�exec�ZsubTest�assertRaises�SyntaxError�compile�r	Zsamplesr3r
r
r�test_badsyntax_1Hs�		���6z#AsyncBadSyntaxTest.test_badsyntax_1cCs^ddddddddd	g	}|D]>}|j|d
��(|�t��t|dd�W5QRXW5QRXqdS)
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)r2r4r5r6r:r
r
r�test_badsyntax_2�s�"z#AsyncBadSyntaxTest.test_badsyntax_2c	Cs&|�t��tddd�W5QRXdS)Nz	async = 1r4r5)r7r8r9r
r
r
r�test_badsyntax_3�sz#AsyncBadSyntaxTest.test_badsyntax_3cCsVdddddg}|D]>}|j|d��(|�t��t|dd�W5QRXW5QRXqdS)	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
            r2r4r5r6r:r
r
r�test_badsyntax_4�s	
�-z#AsyncBadSyntaxTest.test_badsyntax_4N)rrrr;r<r=r>r
r
r
rr1Fs;'r1c@seZdZdd�ZdS)�TokenizerRegrTestcCs�g}td�D]}|�dj|d��qd�|�}i}t|||�|�|d�d�|d7}i}t|||�|�|d�d�|�t�|d��dS)	Ni�zdef i{i}(): return {i}�r)�
Zi499i�z
async def foo():
    return�foo)	�ranger�format�joinr5�assertEqual�
assertTrue�inspectZiscoroutinefunction)r	�bufr)�nsr
r
r�test_oneline_defs�s
z#TokenizerRegrTest.test_oneline_defsN)rrrrKr
r
r
rr?�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�S)��
CoroutineTestcCsdd�}|�t|d��dS)Ncss
dVdSrr
r
r
r
r�gen��z%CoroutineTest.test_gen_1.<locals>.genr)�assertFalse�hasattr)r	rMr
r
r�
test_gen_1�szCoroutineTest.test_gen_1cCs�dd�}|�}|�|tj�|�t|jjtj@��|�	t|jjtj
@��|�t|jjtj@��|�	t|jjtj
@��|�t
|�gdf�|�t|��gdf�dd�}|�	t|jjtj@��dS)Nc�sdS�N�
r
r
r
r
rrB�sz&CoroutineTest.test_func_1.<locals>.foorScSsdSrr
r
r
r
r�bar	rNz&CoroutineTest.test_func_1.<locals>.bar)�assertIsInstancerrrG�bool�__code__�co_flagsrHZCO_COROUTINErOZCO_GENERATOR�cr_coderFr$r*)r	rB�frTr
r
r�test_func_1�szCoroutineTest.test_func_1c	Cs.dd�}|�td��t|��W5QRXdS)Nc�st�dSr�rr
r
r
rrB
sz&CoroutineTest.test_func_2.<locals>.foozcoroutine raised StopIteration)�assertRaisesRegex�RuntimeErrorr$�r	rBr
r
r�test_func_2s�zCoroutineTest.test_func_2cCs*dd�}|�}|�t|�d�|��dS)Nc�st�dSrr\r
r
r
rrBsz&CoroutineTest.test_func_3.<locals>.fooz^<coroutine object.* at 0x.*>$)�assertRegex�repr�close)r	rBr r
r
r�test_func_3szCoroutineTest.test_func_3c	s�dd�}|�}�fdd�}|��t|�W5QRX|��t|�W5QRX|��t|�W5QRX|��t|�W5QRX|��|D]}q�W5QRX|��dd�|D�W5QRX|��dS)Nc�st�dSrr\r
r
r
rrBsz&CoroutineTest.test_func_4.<locals>.foocs��td�S�Nz"'coroutine' object is not iterable�r]�	TypeErrorr
r
r
r�<lambda>"s�z+CoroutineTest.test_func_4.<locals>.<lambda>cSsg|]}|�qSr
r
��.0r)r
r
r�
<listcomp>6sz-CoroutineTest.test_func_4.<locals>.<listcomp>)�list�tuple�sum�iterrc)r	rBr �checkr)r
r
r�test_func_4s"zCoroutineTest.test_func_4c	s�tjdd����fdd�}�fdd�}|�}|��|D]}q8W5QRX|����D]}��|d�qV��dd	���D�dg���t���d
���tt����d�dS)Ncss
dVdS�Nr&r
r
r
r
rrT;sz&CoroutineTest.test_func_5.<locals>.barc�s��IdHdSrr
r
�rTr
rrB?sz&CoroutineTest.test_func_5.<locals>.foocs��td�Srerfr
r
r
rrhBs�z+CoroutineTest.test_func_5.<locals>.<lambda>r&cSsg|]}|�qSr
r
)rj�elr
r
rrkNsz-CoroutineTest.test_func_5.<locals>.<listcomp>�r&)r�	coroutinercrFrmr'ro)r	rBrpr rtr
)rTr	r�test_func_5:s

zCoroutineTest.test_func_5c	shtjdd����fdd�}|�}|�|�d�d�|�|�d�d�|�t��|�d�W5QRXdS)NcssdVdVdS�Nr&r%r
r
r
r
rrTSsz&CoroutineTest.test_func_6.<locals>.barc�s��IdHdSrr
r
rsr
rrBXsz&CoroutineTest.test_func_6.<locals>.foor&r%)rrvrFrr7r)r	rBrZr
rsr�test_func_6Rs
zCoroutineTest.test_func_6c	sHdd�}|���fdd�}|�td��t|��W5QRX���dS)Nc�sdSrRr
r
r
r
rrTbsz&CoroutineTest.test_func_7.<locals>.barc3s�EdHdSrr
r
�r r
rrBfsz&CoroutineTest.test_func_7.<locals>.foozCcannot 'yield from' a coroutine object in a non-coroutine generator)r]rgrlrc�r	rTrBr
rzr�test_func_7as�zCoroutineTest.test_func_7csBtj�fdd��}dd�}|��|�t|��gdf����dS)Nc3s
�EdHSrr
r
rzr
rrTrsz&CoroutineTest.test_func_8.<locals>.barc�sdS�N�spamr
r
r
r
rrBvsz&CoroutineTest.test_func_8.<locals>.foor~)rrvrFr$rcr{r
rzr�test_func_8qszCoroutineTest.test_func_8c
Cstdd�}|�td��|�t��W5QRX|�td��0|�t��|�D]}qNW5QRXt��W5QRXdS)Nc�sdSrr
r
r
r
rrB~sz&CoroutineTest.test_func_9.<locals>.fooz0coroutine '.*test_func_9.*foo' was never awaited)ZassertWarnsRegex�RuntimeWarningrr/r7rg)r	rB�_r
r
r�test_func_9}s��
zCoroutineTest.test_func_9c	s�d�tj�fdd����fdd�}|�}|��}|�|t|��t|�|�|�d�d�|��d�|��|��d�|�}|��}t|�|�	t
��|�t
dd�W5QRX|��d	�dS)
Nrc3sHz8zdV}|dVWntk
r4�d7��YnXW5�d7�XdS)Nr&r%�d��ZeroDivisionError��a)�Nr
rrM�sz'CoroutineTest.test_func_10.<locals>.genc�s��IdHdSrr
r
�rMr
rrB�sz'CoroutineTest.test_func_10.<locals>.foorSr�r&�f)rrvr�assertIsror'rFrrcr7r��throw)r	rBr r(r
)r�rMr�test_func_10�s$zCoroutineTest.test_func_10cCsRdd�}|�}|�dt|��|�dt|����|�dt|����|��dS)Nc�sdSrr
r
r
r
r�func�rNz(CoroutineTest.test_func_11.<locals>.funcr�__iter__Zcoroutine_wrapper)�assertIn�dirrrbrc)r	r�r r
r
r�test_func_11�szCoroutineTest.test_func_11c	s8�fdd�}|��|�td����d�W5QRXdS)Nc�s��d�}tIdHdSr)rrBr@��mer
r�g�s
z%CoroutineTest.test_func_12.<locals>.gzcoroutine already executing)r]�
ValueErrorr)r	r�r
r�r�test_func_12�s�zCoroutineTest.test_func_12c	Cs<dd�}|�}|�td��|�d�W5QRX|��dS)Nc�sdSrr
r
r
r
rr��sz%CoroutineTest.test_func_13.<locals>.gz5can't send non-None value to a just-started coroutiner~)r]rgrrc)r	r�r r
r
r�test_func_13�s�zCoroutineTest.test_func_13c	sNtjdd����fdd�}|�}|�d�|�td��|��W5QRXdS)Ncss
dVdSrr
r
r
r
rrM�sz'CoroutineTest.test_func_14.<locals>.genc�s6z��IdHWn tk
r0��IdHYnXdSr��
GeneratorExitr
r�r
rr �sz(CoroutineTest.test_func_14.<locals>.corozcoroutine ignored GeneratorExit)rrvrr]r^rc)r	r �cr
r�r�test_func_14�s

�zCoroutineTest.test_func_14c	Csfdd�}dd�}|�}|�td��||��d�W5QRX|�td��||��d�W5QRXdS)Nc�sdSr}r
r
r
r
r�spammer�sz+CoroutineTest.test_func_15.<locals>.spammerc�s
|IdHSrr
rzr
r
r�reader�sz*CoroutineTest.test_func_15.<locals>.readerr~�&cannot reuse already awaited coroutine)r]rrr^)r	r�r�Zspammer_coror
r
r�test_func_15�s�zCoroutineTest.test_func_15c	s�tjdd����fdd�}�fdd�}|�}||�}|�d�|�d�|�td��|�td��W5QRX||�}|�d�|�td��|�d�W5QRX|�td��|�td	��W5QRXdS)
Ncss
dVdSrr
r
r
r
r�nop�sz'CoroutineTest.test_func_16.<locals>.nopc�s��IdHdSr}r
r
�r�r
rr�sz(CoroutineTest.test_func_16.<locals>.sendc�s��IdH|IdHSrr
rzr�r
r�read�sz(CoroutineTest.test_func_16.<locals>.read�hamr��wat)rrvrr]�	Exceptionr�r^)r	rr�r�r�r
r�r�test_func_16�s(



��zCoroutineTest.test_func_16c	Cs�dd�}|�}|�td��|�d�W5QRX|�td��|�d�W5QRX|�td��|�td��W5QRX|��|��dS)Nc�sdSr}r
r
r
r
rrvsz-CoroutineTest.test_func_17.<locals>.coroutiner~r�r�)r]rrr^r�r�rc)r	rvr r
r
r�test_func_17s��zCoroutineTest.test_func_17c	Cs�dd�}|�}|��}t|�}|�td��|�d�W5QRX|�td��|�d�W5QRX|�td��t|�W5QRX|�td��|�td��W5QRX|�td��|�td��W5QRX|�	�|�	�dS)Nc�sdSr}r
r
r
r
rrv.sz-CoroutineTest.test_func_18.<locals>.coroutiner~r�r�)
rror]rrr^r'r�r�rc)r	rvr Z
await_iter�itr
r
r�test_func_18+s0����zCoroutineTest.test_func_18cs�d�tj�fdd����fdd�}|�}|�d�|�d�|��d�|��|��d�td�D]}|��|��d�qddS)Nrc3s2dVz
dVWntk
r,�d7�YnXdSrrr�r
)�CHKr
rrBVs

z'CoroutineTest.test_func_19.<locals>.fooc�s��IdHdSrr
r
)rBr
rrv_sz-CoroutineTest.test_func_19.<locals>.coroutiner&�)rrvrrFrcrC)r	rvr r�r
)r�rBr�test_func_19Ss

zCoroutineTest.test_func_19cCs&dd�}t|��}|�|gdf�dS)Nc�sdS)N�rSr
r
r
r
rrBrsz7CoroutineTest.test_coro_wrapper_send_tuple.<locals>.foor�)r*rF�r	rBr"r
r
r�test_coro_wrapper_send_tupleqs
z*CoroutineTest.test_coro_wrapper_send_tuplecCs8dd�}t|��}|�|dt�|�|djd�dS)Nc�std�SrRr\r
r
r
rrBysz?CoroutineTest.test_coro_wrapper_send_stop_iterator.<locals>.foor&rS)r*rUrrFrr�r
r
r�$test_coro_wrapper_send_stop_iteratorxs
z2CoroutineTest.test_coro_wrapper_send_stop_iteratorc	s�tj��fdd����fdd�����fdd�}|����t���tj����j���d���t���tj	����jjj
jd���t
����d�W5QRX��t���tj����j�dS)Nc3sJ��t���tj����j�dV��t���tj����j�dSr)rFrH�getcoroutinestateZCORO_RUNNING�assertIsNone�cr_awaitr
)�coro_br	r
rr��s
z&CoroutineTest.test_cr_await.<locals>.ac�s��IdHdSrr
r
r�r
rr��sz&CoroutineTest.test_cr_await.<locals>.cc�s(���j���IdH���j�dSr)r�r�r
)r�r�r	r
r�b�sz&CoroutineTest.test_cr_await.<locals>.br�)rrvrFrHr�ZCORO_CREATEDr�r�rZCORO_SUSPENDED�gi_code�co_namer7rZCORO_CLOSED)r	r�r
)r�r�r�r	r�
test_cr_await�s
zCoroutineTest.test_cr_awaitcCs�tj}|�d|jj�|�d|jj�|�d|jj�|�d|jdj�|�d|jdj�|�|j	d�dd	�}|�}|�d
t
|��|��dS)Nzinto coroutinezinside coroutinezin coroutinezof the coroutinerrrvc�sdSrr
r
r
r
rrZ�rNz(CoroutineTest.test_corotype_1.<locals>.fzcoroutine object)rrr�r�__doc__rcr��__dict__rFrrb)r	�ctrZr�r
r
r�test_corotype_1�szCoroutineTest.test_corotype_1c	Cs.dd�}|�td��t|��W5QRXdS)Nc�sdIdHdSrrr
r
r
r
rrB�sz'CoroutineTest.test_await_1.<locals>.foozobject int can.t.*await�r]rgr$r_r
r
r�test_await_1�szCoroutineTest.test_await_1c	Cs.dd�}|�td��t|��W5QRXdS)Nc�sgIdHdSrr
r
r
r
rrB�sz'CoroutineTest.test_await_2.<locals>.foozobject list can.t.*awaitr�r_r
r
r�test_await_2�szCoroutineTest.test_await_2cCsDdd�}|�t|��dddgdf�|�t|��dddgdf�dS)Nc�stdddg�IdHdS)Nr&r%r�)rr
r
r
rrB�sz'CoroutineTest.test_await_3.<locals>.foor&r%r�)rFr$r*r_r
r
r�test_await_3�szCoroutineTest.test_await_3cs.dd���fdd�}|�t|��gdf�dS)Nc�sdS�N�*r
r
r
r
rrT�sz'CoroutineTest.test_await_4.<locals>.barc�s��IdHSrr
r
rsr
rrB�sz'CoroutineTest.test_await_4.<locals>.foor��rFr$r_r
rsr�test_await_4�szCoroutineTest.test_await_4c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)Nc@seZdZdd�ZdS)z-CoroutineTest.test_await_5.<locals>.AwaitablecSsdSrr
r
r
r
rr�sz7CoroutineTest.test_await_5.<locals>.Awaitable.__await__N�rrrrr
r
r
r�	Awaitable�sr�c�s��IdHSrr
r
�r�r
rrB�sz'CoroutineTest.test_await_5.<locals>.foo�(__await__.*returned non-iterator of typer�r_r
r�r�test_await_5�s�zCoroutineTest.test_await_5cs6Gdd�d���fdd�}|�t|��dgdf�dS)Nc@seZdZdd�ZdS)z-CoroutineTest.test_await_6.<locals>.AwaitablecSs
tdg�S)N�4�ror
r
r
rr�sz7CoroutineTest.test_await_6.<locals>.Awaitable.__await__Nr�r
r
r
rr��sr�c�s��IdHSrr
r
r�r
rrB�sz'CoroutineTest.test_await_6.<locals>.foor�r�r_r
r�r�test_await_6�szCoroutineTest.test_await_6cs6Gdd�d���fdd�}|�t|��dgdf�dS)Nc@seZdZdd�ZdS)z-CoroutineTest.test_await_7.<locals>.Awaitablecss
dVdS)Nr�r�r
r
r
r
rr�sz7CoroutineTest.test_await_7.<locals>.Awaitable.__await__Nr�r
r
r
rr��sr�c�s��IdHSrr
r
r�r
rrB�sz'CoroutineTest.test_await_7.<locals>.foor�r�r�r_r
r�r�test_await_7�szCoroutineTest.test_await_7c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)Nc@seZdZdS)z-CoroutineTest.test_await_8.<locals>.AwaitableN�rrrr
r
r
rr��sr�c�s��IdHSrr
r
r�r
rrB�rNz'CoroutineTest.test_await_8.<locals>.fooz4object Awaitable can't be used in 'await' expressionr�r_r
r�r�test_await_8�s�zCoroutineTest.test_await_8cs^�fdd��dd����fdd�}�fdd�}|�t|��gd	f�|�t|��gd
f�dS)Ncs�Srr
r
rsr
r�wrap�sz(CoroutineTest.test_await_9.<locals>.wrapc�sdSr�r
r
r
r
rrT�sz'CoroutineTest.test_await_9.<locals>.barc�spd�fdd�i}G�fdd�d�}��IdH���IdH|d���IdH��IdHd|���IdHS)Nr�cs�Srr
r
�r�r
rrh�rNz9CoroutineTest.test_await_9.<locals>.foo.<locals>.<lambda>cseZdZ�ZdS)z3CoroutineTest.test_await_9.<locals>.foo.<locals>.DBN)rrrr�r
r�r
r�DBsr���)r�)Zdbr��rTr�r
rrB�s,��z'CoroutineTest.test_await_9.<locals>.fooc�s��IdHSrr
r
rsr
r�foo2sz(CoroutineTest.test_await_9.<locals>.foo2i��i���r��r	rBr�r
r�r�test_await_9�s	zCoroutineTest.test_await_9cs:dd���fdd���fdd�}|�t|��gdf�dS)Nc�sdSr�r
r
r
r
r�baz
sz(CoroutineTest.test_await_10.<locals>.bazc�s��Srr
r
)r�r
rrTsz(CoroutineTest.test_await_10.<locals>.barc�s��IdHIdHSrr
r
rsr
rrBsz(CoroutineTest.test_await_10.<locals>.foor�r�r_r
)rTr�r�
test_await_10szCoroutineTest.test_await_10csDdd��dd����fdd�}�fdd�}|�t|��gd	f�dS)
NcSs|Srr
��valr
r
r�identsz*CoroutineTest.test_await_11.<locals>.identc�sdSr}r
r
r
r
rrTsz(CoroutineTest.test_await_11.<locals>.barc�s���IdHd�S)Nr�r
r
�rTr�r
rrBsz(CoroutineTest.test_await_11.<locals>.fooc�s��IdHdfS)Nr�r
r
rsr
rr�"sz)CoroutineTest.test_await_11.<locals>.foo2)r~r�r�r�r
r�r�
test_await_11s
zCoroutineTest.test_await_11c	sZdd�}|��G�fdd�d���fdd�}|�td��t|��W5QRX���dS)Nc�sdSr}r
r
r
r
rr (sz)CoroutineTest.test_await_12.<locals>.corocseZdZ�fdd�ZdS)z.CoroutineTest.test_await_12.<locals>.Awaitablecs�Srr
r
�r�r
rr-sz8CoroutineTest.test_await_12.<locals>.Awaitable.__await__Nr�r
r�r
rr�,sr�c�s��IdHSrr
r
r�r
rrB0sz(CoroutineTest.test_await_12.<locals>.fooz"__await__\(\) returned a coroutine)r]rgr$rc)r	r rBr
)r�r�r�
test_await_12's�zCoroutineTest.test_await_12c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)Nc@seZdZdd�ZdS)z.CoroutineTest.test_await_13.<locals>.AwaitablecSs|Srr
r
r
r
rr;sz8CoroutineTest.test_await_13.<locals>.Awaitable.__await__Nr�r
r
r
rr�:sr�c�s��IdHSrr
r
r�r
rrB>sz(CoroutineTest.test_await_13.<locals>.foor�r�r_r
r�r�
test_await_139s�zCoroutineTest.test_await_13c	s�Gdd�d��Gdd�d��Gdd�dt����fdd����fd	d
�}|�}|�d�|�td��|�d�W5QRX|�}|�d�|����|�t�W5QRXdS)Nc@seZdZdd�Zdd�ZdS)z,CoroutineTest.test_await_14.<locals>.WrappercSs|jtjkst�||_dSr)rrrrr )r	r r
r
rrIsz5CoroutineTest.test_await_14.<locals>.Wrapper.__init__cSs
|j��Sr)r rr
r
r
rrLsz6CoroutineTest.test_await_14.<locals>.Wrapper.__await__Nrr
r
r
r�WrapperGsr�c@seZdZdd�ZdS)z/CoroutineTest.test_await_14.<locals>.FutureLikecssdVSrr
r
r
r
rrPsz9CoroutineTest.test_await_14.<locals>.FutureLike.__await__Nr�r
r
r
r�
FutureLikeOsr�c@seZdZdS)z+CoroutineTest.test_await_14.<locals>.MarkerNr�r
r
r
r�MarkerSsr�c�s,z��IdHWStk
r&��YnXdSrr�r
)r�r�r
r�coro1Vsz*CoroutineTest.test_await_14.<locals>.coro1c�s����IdHSrr
r
)r�r�r
r�coro2[sz*CoroutineTest.test_await_14.<locals>.coro2r~)r�rr]rr7r�r�)r	r�r�r
)r�r�r�r�r�
test_await_14Fs

zCoroutineTest.test_await_14c	s\tjdd����fdd�}dd�}|�}|�d�|�td��||��d�W5QRXdS)Ncss
dVdSrr
r
r
r
rr�isz(CoroutineTest.test_await_15.<locals>.nopc�s��IdHdSrr
r
r�r
rrvmsz.CoroutineTest.test_await_15.<locals>.coroutinec�s|IdHdSrr
rzr
r
r�waiterpsz+CoroutineTest.test_await_15.<locals>.waiterz"coroutine is being awaited already)rrvrr]r^)r	rvr�r r
r�r�
test_await_15hs

�zCoroutineTest.test_await_15cs2dd���fdd�}t|��\}}|�|j�dS)Nc�st�Sr)r�r
r
r
rrZ}sz&CoroutineTest.test_await_16.<locals>.fc�s&zt�Wn��IdHYSXdSr)�KeyErrorr
�rZr
rr��sz&CoroutineTest.test_await_16.<locals>.g)r$r��__context__)r	r�r�r"r
r�r�
test_await_16zszCoroutineTest.test_await_16cszGdd�d���fdd�}|�}t|�\}}|�|ddddd	d
ddd
g	��fdd�}|�t��t|��W5QRXdS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)z*CoroutineTest.test_with_1.<locals>.ManagercSs
||_dSr)�name)r	r�r
r
rr�sz3CoroutineTest.test_with_1.<locals>.Manager.__init__c�s"td|jd|jg�IdH|S)Nzenter-1-zenter-2-�rr�r
r
r
r�
__aenter__�s
�z5CoroutineTest.test_with_1.<locals>.Manager.__aenter__c�s0td|jd|jg�IdH|jdkr,dSdS)Nzexit-1-zexit-2-�BTr��r	rr
r
r�	__aexit__�s

�
z4CoroutineTest.test_with_1.<locals>.Manager.__aexit__N)rrrrr�r�r
r
r
r�Manager�sr�c�sj�d�4IdH�J}�d�4IdH�(}td|j|jfg�IdHddW5QIdHRXW5QIdHRXdS)N�Ar��managersr&rr�)r�r��r�r
rrB�s$z&CoroutineTest.test_with_1.<locals>.fooz	enter-1-Az	enter-2-Az	enter-1-Bz	enter-2-B)r�r�r�zexit-1-Bzexit-2-Bzexit-1-Azexit-2-Ac�sj�d�4IdH�J}�d�4IdH�(}td|j|jfg�IdHddW5QIdHRXW5QIdHRXdS)Nr��Cr�r&rr�)r�r�r�r
rrB�s$)r$rFr7r�)r	rBrZr"r�r
r�r�test_with_1�s"��zCoroutineTest.test_with_1c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)Nc@seZdZdd�ZdS)z%CoroutineTest.test_with_2.<locals>.CMcSsdSrr
r
r
r
rr��sz0CoroutineTest.test_with_2.<locals>.CM.__aenter__N)rrrr�r
r
r
r�CM�sr�c
�s$��4IdH�W5QIdHRXdSrr
r
�r�r
rrB�sz&CoroutineTest.test_with_2.<locals>.foor��r]�AttributeErrorr$r_r
r�r�test_with_2�szCoroutineTest.test_with_2c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)Nc@seZdZdd�ZdS)z%CoroutineTest.test_with_3.<locals>.CMcSsdSrr
r
r
r
rr��sz/CoroutineTest.test_with_3.<locals>.CM.__aexit__N)rrrr�r
r
r
rr��sr�c
�s$��4IdH�W5QIdHRXdSrr
r
r�r
rrB�sz&CoroutineTest.test_with_3.<locals>.foor�r�r_r
r�r�test_with_3�szCoroutineTest.test_with_3c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_4.<locals>.CMcSsdSrr
r
r
r
r�	__enter__�sz/CoroutineTest.test_with_4.<locals>.CM.__enter__cSsdSrr
r
r
r
r�__exit__�sz.CoroutineTest.test_with_4.<locals>.CM.__exit__N)rrrrrr
r
r
rr��sr�c
�s$��4IdH�W5QIdHRXdSrr
r
r�r
rrB�sz&CoroutineTest.test_with_4.<locals>.foor�r�r_r
r�r�test_with_4�szCoroutineTest.test_with_4c	s>Gdd�d���fdd�}|�t��t|��W5QRXdS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_5.<locals>.CMc�s|Srr
r
r
r
rr��sz0CoroutineTest.test_with_5.<locals>.CM.__aenter__c�sdSrr
)r	�excr
r
rr��sz/CoroutineTest.test_with_5.<locals>.CM.__aexit__N�rrrr�r�r
r
r
rr��sr�c
�s0��4IdH�ddkst�W5QIdHRXdS)Nrur&)rr
r�r
rr��sz'CoroutineTest.test_with_5.<locals>.func)r7rr$)r	r�r
r�r�test_with_5�szCoroutineTest.test_with_5c	s@Gdd�d���fdd�}|�td��t|��W5QRXdS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_6.<locals>.CMcSsdS)N�{r
r
r
r
rr��sz0CoroutineTest.test_with_6.<locals>.CM.__aenter__cWsdS�Ni�r
�r	�er
r
rr��sz/CoroutineTest.test_with_6.<locals>.CM.__aexit__Nrr
r
r
rr��sr�c
�s$��4IdH�W5QIdHRXdSrr
r
r�r
rrB�sz&CoroutineTest.test_with_6.<locals>.foozV'async with' received an object from __aenter__ that does not implement __await__: intr�r_r
r�r�test_with_6�s�zCoroutineTest.test_with_6c
s�Gdd�d���fdd�}zt|��WnVtk
r~}z8|�|jdd�|�|jdk	�|�t|jt��W5d}~XYnX|�d�dS)Nc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_7.<locals>.CMc�s|Srr
r
r
r
rr�sz0CoroutineTest.test_with_7.<locals>.CM.__aenter__cWsdS)Ni�r
r	r
r
rr�sz/CoroutineTest.test_with_7.<locals>.CM.__aexit__Nrr
r
r
rr��sr�c
�s,��4IdH�ddW5QIdHRXdS�Nr&rr
r
r�r
rrBsz&CoroutineTest.test_with_7.<locals>.foor�U'async with' received an object from __aexit__ that does not implement __await__: intz1invalid asynchronous context manager did not fail)	r$rgrarrGr��
isinstancer��fail�r	rBrr
r�r�test_with_7�s�$zCoroutineTest.test_with_7c	sd�Gdd�d����fdd�}|�td��t|��W5QRX|��d���fdd�}|�td��t|��W5QRX|��d	���fd
d�}|�td��t|��W5QRX|��d���fdd�}|�td��t|��W5QRX|��d
�dS)Nrc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_8.<locals>.CMc�s|Srr
r
r
r
rr�sz0CoroutineTest.test_with_8.<locals>.CM.__aenter__cWsdSrr
r	r
r
rr�sz/CoroutineTest.test_with_8.<locals>.CM.__aexit__Nrr
r
r
rr�sr�c
�s,��4IdH��d7�W5QIdHRXdSrrr
r
�r��CNTr
rrB#sz&CoroutineTest.test_with_8.<locals>.foor
r&c�sNtd�D]@}��4IdH�"�d7�W5QIdHR�qJW5QIdHRXqdS�Nr%r&�rCr@rr
rrB/sr%c�sLtd�D]>}��4IdH� �d7�W5QIdHR�qW5QIdHRXqdSrrr@rr
rrB=sr�c
�s<��4IdH��d7�W5QIdHR�dSQIdHRXdSrrr
r
rr
rrBKs�)r]rgr$rFr_r
rr�test_with_8s<����zCoroutineTest.test_with_8c	sPd�Gdd�d����fdd�}|�t��t|��W5QRX|��d�dS)Nrc@seZdZdd�Zdd�ZdS)z%CoroutineTest.test_with_9.<locals>.CMc�s|Srr
r
r
r
rr�\sz0CoroutineTest.test_with_9.<locals>.CM.__aenter__c�sdddSrr
r	r
r
rr�_sz/CoroutineTest.test_with_9.<locals>.CM.__aexit__Nrr
r
r
rr�[sr�c
�s,��4IdH��d7�W5QIdHRXdSrrr
r
rr
rrBbsz&CoroutineTest.test_with_9.<locals>.foor&�r7r�r$rFr_r
rr�test_with_9XszCoroutineTest.test_with_9c
s�d�Gdd�d����fdd�}zt|��WnXtk
r�}z:|�|jdk	�|�t|jt��|�t|jjt��W5d}~XYnX|�d�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_10.<locals>.CMc�s|Srr
r
r
r
rr�psz1CoroutineTest.test_with_10.<locals>.CM.__aenter__c�sdddSrr
r	r
r
rr�ssz0CoroutineTest.test_with_10.<locals>.CM.__aexit__Nrr
r
r
rr�osr�c�sH��4IdH�*��4IdH�
t�W5QIdHRXW5QIdHRXdSr�r^r
rr
rrBvsz'CoroutineTest.test_with_10.<locals>.fooz*exception from __aexit__ did not propagate)r$r�rGr�rr^rrr
rr�test_with_10ls�zCoroutineTest.test_with_10c
spd�Gdd�d����fdd�}zt|��Wn2tk
r`}z|�|jdk�W5d}~XYnX|�d�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_11.<locals>.CMc�st�dSr)�NotImplementedErrorr
r
r
rr��sz1CoroutineTest.test_with_11.<locals>.CM.__aenter__c�sdddSrr
r	r
r
rr��sz0CoroutineTest.test_with_11.<locals>.CM.__aexit__Nrr
r
r
rr��sr�c
�s(��4IdH�
t�W5QIdHRXdSrrr
rr
rrB�sz'CoroutineTest.test_with_11.<locals>.fooz+exception from __aenter__ did not propagate)r$rrGr�rrr
rr�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|Srr
r
r
r
rr��sz1CoroutineTest.test_with_12.<locals>.CM.__aenter__c�sdS�NTr
r	r
r
rr��sz0CoroutineTest.test_with_12.<locals>.CM.__aexit__Nrr
r
r
rr��sr�c
�s6��4IdH�}��|j��t�W5QIdHRXdSr)r�rr^��cm�r�rr	r
rrB�sz'CoroutineTest.test_with_12.<locals>.foo)r$r_r
r!r�test_with_12�szCoroutineTest.test_with_12c	sPd�Gdd�d����fdd�}|�t��t|��W5QRX|��d�dS)Nrc@seZdZdd�Zdd�ZdS)z&CoroutineTest.test_with_13.<locals>.CMc�sdddSrr
r
r
r
rr��sz1CoroutineTest.test_with_13.<locals>.CM.__aenter__c�sdSrr
r	r
r
rr��sz0CoroutineTest.test_with_13.<locals>.CM.__aexit__Nrr
r
r
rr��sr�c
�s<�d7���4IdH��d7�W5QIdHRX�d7�dS)Nr&r��'r
r
rr
rrB�sz'CoroutineTest.test_with_13.<locals>.foor&rr_r
rr�test_with_13�szCoroutineTest.test_with_13csHd�G�fdd�d��g���fdd�}t|��\}}|��d�|�|dd�tdd	�D��|��d
d�tdd�D��g���fdd
�}t|��\}}|��d�|�|ddg�|��dd�tdd�D�dg�g���fdd�}t|��\}}|��d�|�|dd�tdd	�D��|��dd�tdd�D�ddg�dS)Nrcs(eZdZdd�Z�fdd�Zdd�ZdS)z+CoroutineTest.test_for_1.<locals>.AsyncItercSs
d|_dSrr@r
r
r
rr�sz4CoroutineTest.test_for_1.<locals>.AsyncIter.__init__cs�d7�|Srrr
r
��aiter_callsr
r�	__aiter__�sz5CoroutineTest.test_for_1.<locals>.AsyncIter.__aiter__c�sF|jd7_|jds,t|jd�IdH|jdkr:t�|j|jfS)Nr&rSr�)r)r�StopAsyncIterationr
r
r
r�	__anext__�s

z5CoroutineTest.test_for_1.<locals>.AsyncIter.__anext__N�rrrrr'r)r
r%r
r�	AsyncIter�sr+c�s,��2z3dHW\}}��||�q6dSr�r)Zi1Zi2�r+r!r
r�test1�sz'CoroutineTest.test_for_1.<locals>.test1r&cSsg|]}|d�qS�r�r
rir
r
rrk�sz,CoroutineTest.test_for_1.<locals>.<listcomp>�cSsg|]}|d�qS)r%r
rir
r
rrk�s�ec�sL��2z*3dHW}��|d�|ddkrq>q6��d���d�dS�Nr��what?�endr,r@r-r
r�test2�s
z'CoroutineTest.test_for_1.<locals>.test2r%r���cSsg|]}|�qSr
r
rir
r
rrk�s�r5c�sJ��2z(3dHW}|ddkr q��|d�q6��d���d�dSr2r,r@r-r
r�test3�s
z'CoroutineTest.test_for_1.<locals>.test3r�cSsg|]}|d�qSr/r
rir
r
rrkscSsg|]}|�qSr
r
rir
r
rrksr4)r$rFrC)r	r.Zyieldedr�r6r9r
)r+r&r!r�
test_for_1�s,
"
�zCoroutineTest.test_for_1c	sRd�t���}�fdd�}|�td��t|��W5QRX|�t���|�dS)N�r&r%r�c�s �2z3dHW}td�q6dS�Nznever going to happen��printr@��tupr
rrBsz%CoroutineTest.test_for_2.<locals>.fooz/async for' requires an object.*__aiter__.*tuple��sys�getrefcountr]rgr$rF)r	�refs_beforerBr
r?r�
test_for_2s
�zCoroutineTest.test_for_2c	sbGdd�d�}|��t���}�fdd�}|�td��t|��W5QRX|�t���|�dS)Nc@seZdZdd�ZdS)z#CoroutineTest.test_for_3.<locals>.IcSs|Srr
r
r
r
rr'sz-CoroutineTest.test_for_3.<locals>.I.__aiter__N�rrrr'r
r
r
r�IsrGc�s �2z3dHW}td�q6dSr<r=r@�Zaiterr
rrB"sz%CoroutineTest.test_for_3.<locals>.fooz!that does not implement __anext__rA�r	rGrDrBr
rHr�
test_for_3s
�zCoroutineTest.test_for_3c	sbGdd�d�}|��t���}�fdd�}|�td��t|��W5QRX|�t���|�dS)Nc@seZdZdd�Zdd�ZdS)z#CoroutineTest.test_for_4.<locals>.IcSs|Srr
r
r
r
rr'0sz-CoroutineTest.test_for_4.<locals>.I.__aiter__cSsdS)Nr
r
r
r
r
rr)3sz-CoroutineTest.test_for_4.<locals>.I.__anext__N)rrrr'r)r
r
r
rrG/srGc�s �2z3dHW}td�q6dSr<r=r@rHr
rrB9sz%CoroutineTest.test_for_4.<locals>.fooz7async for' received an invalid object.*__anext__.*tuplerArIr
rHr�
test_for_4.s
�zCoroutineTest.test_for_4c	s�d�G�fdd�d��Gdd�d��������t���}t���}���fdd�}t���t�d�t|��W5QRX|��d	�|�t���|�|�t���|����fd
d�}t|��|��d����fdd�}t|��|��d
�dS)Nrcs$eZdZ�fdd�Z�fdd�ZdS)z)CoroutineTest.test_for_6.<locals>.Managerc�s�d7�dS)Nr#r
r
�rGr
rr�Isz4CoroutineTest.test_for_6.<locals>.Manager.__aenter__c�s�d7�dS)Ni��r
r�rLr
rr�Msz3CoroutineTest.test_for_6.<locals>.Manager.__aexit__Nrr
rLr
rr�Hsr�c@s$eZdZdd�Zdd�Zdd�ZdS)z*CoroutineTest.test_for_6.<locals>.IterablecSs
d|_dSrr@r
r
r
rrRsz3CoroutineTest.test_for_6.<locals>.Iterable.__init__cSs|Srr
r
r
r
rr'Usz4CoroutineTest.test_for_6.<locals>.Iterable.__aiter__c�s"|jdkrt�|jd7_|jS�NrSr&)r)r(r
r
r
rr)Xs
z4CoroutineTest.test_for_6.<locals>.Iterable.__anext__Nr*r
r
r
r�IterableQsrNc
�sF�4IdH�"�2z3dHW}�d7�q6W5QIdHRX�d7�dS�Nr&r�r
r@)rG�iterable�managerr
r�mainesz&CoroutineTest.test_for_6.<locals>.main�errori��c
�s���4IdH�$��2z3dHW}�d7�q6W5QIdHRX�d7���4IdH�$��2z3dHW}�d7�q\6W5QIdHRX�d7�dSrOr
r@�rGrNr�r
rrRysi�c
�s���4IdH�4�d7���2z3dHW}�d7�q6�d7�W5QIdHRX�d7���4IdH�4�d7���2z3dHW}�d7�qt6�d7�W5QIdHRX�d7�dS)Nr�r&i���r�r
r@rTr
rrR�si��9)rBrCr,r-r.r$rF)r	Zmrefs_beforeZirefs_beforerRr
)rGrNr�rPrQr�
test_for_6Es(	





zCoroutineTest.test_for_6c	sPd�Gdd�d����fdd�}|�t��t|��W5QRX|��d�dS)Nrc@seZdZdd�ZdS)z$CoroutineTest.test_for_7.<locals>.AIcSsdddSrr
r
r
r
rr'�sz.CoroutineTest.test_for_7.<locals>.AI.__aiter__NrFr
r
r
r�AI�srVc�s*��2z3dHW}�d7�q6�d7�dS�Nr&rSr
r@�rVrr
rrB�sz%CoroutineTest.test_for_7.<locals>.foorr_r
rXr�
test_for_7�szCoroutineTest.test_for_7c
snd�Gdd�d����fdd�}|�t��.t���t�d�t|��W5QRXW5QRX|��d�dS)Nrc@seZdZdd�ZdS)z$CoroutineTest.test_for_8.<locals>.AIcSsdddSrr
r
r
r
rr'�sz.CoroutineTest.test_for_8.<locals>.AI.__aiter__NrFr
r
r
rrV�srVc�s*��2z3dHW}�d7�q6�d7�dSrWr
r@rXr
rrB�sz%CoroutineTest.test_for_8.<locals>.foorS)r7r�r,r-r.r$rFr_r
rXr�
test_for_8�s

zCoroutineTest.test_for_8c	sVGdd�d���fdd�}|�td��}|��d�W5QRX|j}|�|jt�dS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)z$CoroutineTest.test_for_11.<locals>.FcSs|Srr
r
r
r
rr'�sz.CoroutineTest.test_for_11.<locals>.F.__aiter__cSs|Srr
r
r
r
rr)�sz.CoroutineTest.test_for_11.<locals>.F.__anext__cSsdddSrr
r
r
r
rr�sz.CoroutineTest.test_for_11.<locals>.F.__await__N)rrrr'r)rr
r
r
r�F�sr[c�s��2z3dHW}q6dSrr
)r��r[r
rrR�sz'CoroutineTest.test_for_11.<locals>.mainz an invalid object from __anext__)r]rgr�	exceptionrU�	__cause__r�)r	rRr��errr
r\r�test_for_11�s�zCoroutineTest.test_for_11c	shGdd�dt��Gdd�dt��g����fdd�}|����|��d�W5QRX|��dg�dS)Nc@seZdZdS)z*CoroutineTest.test_for_tuple.<locals>.DoneNr�r
r
r
r�Done�srac@s eZdZdZdd�Zdd�ZdS)z+CoroutineTest.test_for_tuple.<locals>.AIterrcSs|Srr
r
r
r
rr'�sz5CoroutineTest.test_for_tuple.<locals>.AIter.__aiter__c�s.|jt|�krt�|jd7_||jdSrr)r)�lenr(r
r
r
rr)�sz5CoroutineTest.test_for_tuple.<locals>.AIter.__anext__N�rrrr)r'r)r
r
r
r�AIter�srdc�s,�dg�2z3dHW}��|�q
6��dSr�r,r@�rdrar"r
rrB�sz)CoroutineTest.test_for_tuple.<locals>.foor�)r�rmr7rrFr_r
rer�test_for_tuple�s
zCoroutineTest.test_for_tuplec	shGdd�dt��Gdd�dt��g����fdd�}|����|��d�W5QRX|��dg�dS)Nc@seZdZdS)z3CoroutineTest.test_for_stop_iteration.<locals>.DoneNr�r
r
r
rra�srac@s eZdZdZdd�Zdd�ZdS)z4CoroutineTest.test_for_stop_iteration.<locals>.AIterrcSs|Srr
r
r
r
rr'�sz>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__aiter__c�s|jr
t�|jd7_|jSrr)r)r(rr
r
r
rr)�sz>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__anext__Nrcr
r
r
rrd�srdc�s*�d�2z3dHW}��|�q6��dSr�r,r@rer
rrB�sz2CoroutineTest.test_for_stop_iteration.<locals>.foor�)r�rr7rrFr_r
rer�test_for_stop_iteration�s
z%CoroutineTest.test_for_stop_iterationcs�dd���fdd�}�fdd�}�fdd�}�fd	d
�}|�t|��gddgf�|�t|��gddhf�|�t|��gd
d
d�f�|�t|��gddd�f�dS)Nc�s|Srr
r@r
r
rrZsz$CoroutineTest.test_comp_1.<locals>.fc�s dd��d��d�fD�IdHS)Nc�sg|]}|IdH�qSrr
�rjr�r
r
rrksz?CoroutineTest.test_comp_1.<locals>.run_list.<locals>.<listcomp>r&�)r
r
r�r
r�run_listsz+CoroutineTest.test_comp_1.<locals>.run_listc�s dd��d��d�fD�IdHS)Nc�sh|]}|IdH�qSrr
rhr
r
r�	<setcomp>sz=CoroutineTest.test_comp_1.<locals>.run_set.<locals>.<setcomp>r&rir
r
r�r
r�run_set
sz*CoroutineTest.test_comp_1.<locals>.run_setc�s dd��d��d�fD�IdHS)Nc�si|]}|IdHd�qS)Nr�r
rhr
r
r�
<dictcomp>sz@CoroutineTest.test_comp_1.<locals>.run_dict1.<locals>.<dictcomp>r&rir
r
r�r
r�	run_dict1
sz,CoroutineTest.test_comp_1.<locals>.run_dict1c�s$dd�t�d��d�g�D�IdHS)Nc�si|]\}}||IdH�qSrr
)rjr)r�r
r
rrmsz@CoroutineTest.test_comp_1.<locals>.run_dict2.<locals>.<dictcomp>r&ri)�	enumerater
r�r
r�	run_dict2sz,CoroutineTest.test_comp_1.<locals>.run_dict2r&rir�)r&ri)rr&r�)r	rjrlrnrpr
r�r�test_comp_1szCoroutineTest.test_comp_1c	s�dd���fdd�}|�t|��gddddd	gf��fd
d�}|�t|��gdd
dhf��fdd�}|�t|��gdd
hf�dS)Nc�s|Srr
r@r
r
rrZsz$CoroutineTest.test_comp_2.<locals>.fc�s0dd��d��d��d��ddg�fD�IdHS)Nc�s g|]}|IdHD]}|�qqSrr
�rjr��sr
r
rrks�z?CoroutineTest.test_comp_2.<locals>.run_list.<locals>.<listcomp>��abc�de�fgr
r
r�r
rrjsz+CoroutineTest.test_comp_2.<locals>.run_listr�r�r�rvrwc�s,dd���ddg��dg�g�fD�IdHS)Nc�s0h|](}|IdHD]}|IdHD]}|�q qqSrr
)rjr�rs�dr
r
rrk%s�z=CoroutineTest.test_comp_2.<locals>.run_set.<locals>.<setcomp>rS�r3r
r
r�r
rrl$s
��z*CoroutineTest.test_comp_2.<locals>.run_setrSr3ryc�s&dd���d��d�g�fD�IdHS)Nc�s&h|]}|IdHD]}|IdH�qqSrr
rrr
r
rrk0s�z>CoroutineTest.test_comp_2.<locals>.run_set2.<locals>.<setcomp>rSr3r
r
r�r
r�run_set2/s�z+CoroutineTest.test_comp_2.<locals>.run_set2r�)r	rjrlrzr
r�r�test_comp_2s ��
�zCoroutineTest.test_comp_2cs�dd���fdd�}|�t|��gddgf��fdd�}|�t|��gddhf��fd	d
�}|�t|��gddd
�f��fdd�}|�t|��gddgf�dS)NcSs|D]
}|VqdSrr
�r�r)r
r
rrZ9sz$CoroutineTest.test_comp_3.<locals>.fc�sdd��ddg�2�IdHS)Nc�sg|z3dHW}|d�q6Srrr
rir
r
rrk>sz?CoroutineTest.test_comp_3.<locals>.run_list.<locals>.<listcomp>rSr3r
r
r�r
rrj=sz+CoroutineTest.test_comp_3.<locals>.run_listr0r8c�sdd��ddg�2�IdHS)Nc�sh|z3dHW}|d�q6Srrr
rir
r
rrkDsz=CoroutineTest.test_comp_3.<locals>.run_set.<locals>.<setcomp>rSr3r
r
r�r
rrlCsz*CoroutineTest.test_comp_3.<locals>.run_setc�sdd��ddg�2�IdHS)Nc�s$i|z3dHW}|d|d�q6Srxr
rir
r
rrmJsz?CoroutineTest.test_comp_3.<locals>.run_dict.<locals>.<dictcomp>rSr3r
r
r�r
r�run_dictIsz+CoroutineTest.test_comp_3.<locals>.run_dict��)r0r8c�s*dd��ddg�2�}dd�|2�IdHS)NcSs |z3dHW}|dVq6dSrrr
rir
r
r�	<genexpr>Psz=CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<genexpr>rSr3c�sg|z3dHW}|d�q6S�Nr�r
�rjr�r
r
rrkQsz>CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<listcomp>r
r�r�r
r�run_genOsz*CoroutineTest.test_comp_3.<locals>.run_gen�o�yr��r	rjrlr}r�r
r�r�test_comp_38s*
�
��
�zCoroutineTest.test_comp_3cs�dd���fdd�}|�t|��gdgf��fdd�}|�t|��gdhf��fdd	�}|�t|��gdd
if��fdd�}|�t|��gd
gf�dS)NcSs|D]
}|VqdSrr
r|r
r
rrZWsz$CoroutineTest.test_comp_4.<locals>.fc�sdd��ddg�2�IdHS)Nc�s&g|z3dHW}|dkr|d�q6SrMr
rir
r
rrk\sz?CoroutineTest.test_comp_4.<locals>.run_list.<locals>.<listcomp>rSr3r
r
r�r
rrj[sz+CoroutineTest.test_comp_4.<locals>.run_listr8c�sdd��ddg�2�IdHS)Nc�s&h|z3dHW}|dkr|d�q6SrMr
rir
r
rrkbsz=CoroutineTest.test_comp_4.<locals>.run_set.<locals>.<setcomp>rSr3r
r
r�r
rrlasz*CoroutineTest.test_comp_4.<locals>.run_setc�sdd��ddg�2�IdHS)Nc�s,i|z"3dHW}|dkr|d|d�q6S)NrSr&r%r
rir
r
rrmhsz?CoroutineTest.test_comp_4.<locals>.run_dict.<locals>.<dictcomp>rSr3r
r
r�r
rr}gsz+CoroutineTest.test_comp_4.<locals>.run_dictrc�s*dd��ddg�2�}dd�|2�IdHS)NcSs(|z3dHW}|dkr|dVq6dSrMr
rir
r
rr�nsz=CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<genexpr>rSr3c�sg|z3dHW}|d�q6Sr�r
r�r
r
rrkosz>CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<listcomp>r
r�r�r
rr�msz*CoroutineTest.test_comp_4.<locals>.run_genr�r�r�r
r�r�test_comp_4Vs*��
��zCoroutineTest.test_comp_4cs�dd���fdd�}|�t|��gdddgf��fdd	�}|�t|��gdddhf��fd
d�}|�t|��gdd
dd�f��fdd�}|�t|��gdddgf�dS)NcSs|D]
}|VqdSrr
r|r
r
rrZusz&CoroutineTest.test_comp_4_2.<locals>.fc�sdd��td��2�IdHS)Nc�s6g|z,3dHW}d|kr$dkrnq|d�q6S�NrrrSr
rir
r
rrkzs

zACoroutineTest.test_comp_4_2.<locals>.run_list.<locals>.<listcomp>�rr
r�r
rrjysz-CoroutineTest.test_comp_4_2.<locals>.run_listr0r~�
c�sdd��td��2�IdHS)Nc�s6h|z,3dHW}d|kr$dkrnq|d�q6Sr�r
rir
r
rrk�s

z?CoroutineTest.test_comp_4_2.<locals>.run_set.<locals>.<setcomp>r�rr
r�r
rrlsz,CoroutineTest.test_comp_4_2.<locals>.run_setc�sdd��td��2�IdHS)Nc�s<i|z23dHW}d|kr$dkrnq|d|d�q6S)NrrrSr�r
rir
r
rrm�s
zACoroutineTest.test_comp_4_2.<locals>.run_dict.<locals>.<dictcomp>r�rr
r�r
rr}�sz-CoroutineTest.test_comp_4_2.<locals>.run_dictr1r��g)r0r~r�c�s*dd��td��2�}dd�|2�IdHS)NcSs8|z.3dHW}d|kr"dkrnq|dVq6dSr�r
rir
r
rr��s

z?CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<genexpr>r�c�sg|z3dHW}|d�q6Sr�r
r�r
r
rrk�sz@CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<listcomp>rr�r�r
rr��sz,CoroutineTest.test_comp_4_2.<locals>.run_genr��p�qr�r�r
r�r�
test_comp_4_2ts*����zCoroutineTest.test_comp_4_2cs0dd���fdd�}|�t|��gdgf�dS)NcSs|D]
}|VqdSrr
r|r
r
rrZ�sz$CoroutineTest.test_comp_5.<locals>.fc�s$�fdd�ddgddgfD�IdHS)Nc	�s@g|]8}|ddkr�|�2z3dHW}|dkr|d�q6qS)rrSNryr&r
)rjZpairr)r�r
rrk�s�z?CoroutineTest.test_comp_5.<locals>.run_list.<locals>.<listcomp>rSr3ry�(r
r
r�r
rrj�sz+CoroutineTest.test_comp_5.<locals>.run_listrir��r	rjr
r�r�test_comp_5�s�zCoroutineTest.test_comp_5cs4dd���fdd�}|�t|��gdddgf�dS)NcSs|D]
}|VqdSrr
r|r
r
rrZ�sz$CoroutineTest.test_comp_6.<locals>.fc�sdd��ddg�2�IdHS)Nc�s(g|z3dHW}|D]}|d�qq6Srrr
)rj�seqr)r
r
rrk�s�z?CoroutineTest.test_comp_6.<locals>.run_list.<locals>.<listcomp>)rSr3)ryr
r
r�r
rrj�sz+CoroutineTest.test_comp_6.<locals>.run_listr0r8�r�r�r
r�r�test_comp_6�s�zCoroutineTest.test_comp_6c	s:dd���fdd�}|�td��t|��W5QRXdS)NcSsdVdVtd��dS)Nr&r%�aaa)r�r
r
r
rrZ�sz$CoroutineTest.test_comp_7.<locals>.fc�sdd���2�IdHS)Nc�sg|z3dHW}|�q6Srr
rir
r
rrk�sz?CoroutineTest.test_comp_7.<locals>.run_list.<locals>.<listcomp>r
r
r�r
rrj�sz+CoroutineTest.test_comp_7.<locals>.run_listr�)r]r�r$r�r
r�r�test_comp_7�szCoroutineTest.test_comp_7cCs(dd�}|�t|��gdddgf�dS)Nc�sdd�dD�S)NcSsg|]}|�qSr
r
rir
r
rrk�sz8CoroutineTest.test_comp_8.<locals>.f.<locals>.<listcomp>r;r
r
r
r
rrZ�sz$CoroutineTest.test_comp_8.<locals>.fr&r%r�r��r	rZr
r
r�test_comp_8�s
�zCoroutineTest.test_comp_8cs2dd���fdd�}|�t|��gddgf�dS)NcSsdVdVdSrxr
r
r
r
rrM�sz&CoroutineTest.test_comp_9.<locals>.genc�s$dd���2�IdH}dd�|D�S)Nc�sg|z3dHW}|�q6Srr
rir
r
rrk�sz8CoroutineTest.test_comp_9.<locals>.f.<locals>.<listcomp>cSsg|]}|�qSr
r
rir
r
rrk�sr
)�lr�r
rrZ�sz$CoroutineTest.test_comp_9.<locals>.fr&r%r�r�r
r�r�test_comp_9�s
�zCoroutineTest.test_comp_9cCs*dd�}|�t|��gdddd�f�dS)Nc�sdd�dD�}dd�|D�S)NcSsh|]}|�qSr
r
rir
r
rrk�sz8CoroutineTest.test_comp_10.<locals>.f.<locals>.<setcomp>r;cSsi|]
}||�qSr
r
)rj�xr
r
rrm�sz9CoroutineTest.test_comp_10.<locals>.f.<locals>.<dictcomp>r
)Zxxr
r
rrZ�sz%CoroutineTest.test_comp_10.<locals>.fr&r%r�r;r�r�r
r
r�test_comp_10�s
�zCoroutineTest.test_comp_10c	Csjdd�}|�}|�t��t�|�W5QRX|��}z$|�t��t�|�W5QRXW5|��XdS)Nc�sdSrr
r
r
r
rr��rNz%CoroutineTest.test_copy.<locals>.func)r7rg�copyrrc)r	r�r r(r
r
r�	test_copy�szCoroutineTest.test_copyc
Cs�dd�}|�}ttjd�D],}|�ttjf��t�||�W5QRXq|��}z@ttjd�D],}|�ttjf��t�||�W5QRXqbW5|��XdS)Nc�sdSrr
r
r
r
rr��rNz'CoroutineTest.test_pickle.<locals>.funcr&)	rC�pickle�HIGHEST_PROTOCOLr7rg�
PicklingError�dumpsrrc)r	r�r �protor(r
r
r�test_pickle�szCoroutineTest.test_picklec
Cs�dd�}t���ft���R}t�d�|�}t|�}d}t��|�dt|j	j
��|�t|j	j�|�W5QRXW5QRXdS)Nc�sdSrr
r
r
r
rr��rNz3CoroutineTest.test_fatal_coro_warning.<locals>.funcrSzwas never awaited)
r,r-r�catch_unraisable_exception�filterwarningsrbr/r��str�
unraisable�	exc_valuerF�object)r	r�r r �	coro_reprr
r
r�test_fatal_coro_warning�s
�
z%CoroutineTest.test_fatal_coro_warningcs�Gdd�d�}|��dd�����fdd�}��t|��gdf����fdd	�}��t|��gdf����fd
d�}��t|��gdf�dS)Nc@seZdZdd�ZdS)zMCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.BadTargetcSstd��dSr��r()r	�keyrr
r
r�__setitem__szYCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.BadTarget.__setitem__N)rrrr�r
r
r
r�	BadTargetsr�cSs
dVdSrRr
r
r
r
r�sourceszJCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.sourcec	�sD��t�� }��2z3dHW�d<q6W5QRX��|jjd�dS)Nr�r�r5�r7r(rFr]rr�r	r��tgtr
r�run_fors
zKCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_forr5c
�sL��t��(}�fdd���2�IdHW5QR�SQRX��|jjd�dS)Nc�sg|z3dHW�d<d�q6Srr
�rj�r�r
rrksz`CoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_list.<locals>.<listcomp>r�r5r�rr�r
rrjs,zLCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_listc	�sd�fdd���2�}|�d�}��t��}|IdHW5QRX��|jjt���|jjjd�dS)Ncs |z3dHW�d<dVq6dSrr
r�r�r
rr�sz^CoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_gen.<locals>.<genexpr>r�r5�	�asendr7r^rUr]r^r(rFr�rMr�r r�r
rr�s
zKCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_genr�)r	r�r�rjr�r
r�r�,test_for_assign_raising_stop_async_iteration�sz:CoroutineTest.test_for_assign_raising_stop_async_iterationcs�Gdd�d���fdd����fdd�}��t|��gdf���fdd	�}��t|��gdf���fd
d�}��t|��gdf�dS)Nc@seZdZdd�ZdS)zQCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.BadIterablecSstd��dSr�r�r
r
r
rr�"szZCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.BadIterable.__iter__N)rrrr�r
r
r
r�BadIterable!sr�cs��VdSrr
r
)r�r
r�badpairs$szNCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.badpairsc	�sD��t�� }��2z3dHW\}}q6W5QRX��|jjd�dS)Nr�r5r�)r r)�j�r�r	r
rr�'s
zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_forr5c
�sH��t��$}dd���2�IdHW5QR�SQRX��|jjd�dS)Nc�sg|z3dHW\}}d�q6Srr
�rjr)r�r
r
rrk1szbCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_list.<locals>.<listcomp>r�r5r�rr�r
rrj/s(zNCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_listc	�s`dd���2�}|�d�}��t��}|IdHW5QRX��|jjt���|jjjd�dS)NcSs |z3dHW\}}dVq6dSrr
r�r
r
rr�7sz`CoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_gen.<locals>.<genexpr>r�r5r�r�r�r
rr�6s
zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_genr�)r	r�rjr�r
)r�r�r	r�.test_for_assign_raising_stop_async_iteration_2 sz<CoroutineTest.test_for_assign_raising_stop_async_iteration_2N)RrrrrQr[r`rdrqrwryr|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�rrrrrrrrrr"r$r:rErJrKrUrYrZr`rfrgrqr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rrL�s�	#
	(	


"(@H\ 
	
!rLc@seZdZdd�ZdS)�CoroAsyncIOCompatTestc	s�t�d��Gdd�dt��g�G��fdd�d������fdd�}���}��|�z*z|�|��Wn�k
r|YnXW5|����d�X|��dd	dg�dS)
N�asyncioc@seZdZdS)z9CoroAsyncIOCompatTest.test_asyncio_1.<locals>.MyExceptionNr�r
r
r
r�MyExceptionHsr�cs(eZdZ��fdd�Z��fdd�ZdS)z0CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CMc�s(��d���d�IdH��d�|S)Nr&�{�G�z�?r%)r�sleepr
�r�r!r
rr�Ns

z;CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aenter__c�s ��d�IdH��|j�dS)Nr�)r�rr)r	�exc_type�exc_val�exc_tbr�r
rr�Tsz:CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aexit__Nrr
r�r
rr�Msr�c
�sB��4IdH�}��d�IdH��W5QIdHRX��d�dS)Nr�Zunreachable)r�rr��r�r�r�r!r
rrZXsz/CoroAsyncIOCompatTest.test_asyncio_1.<locals>.fr&r%)	r�
import_moduler�Znew_event_loopZset_event_looprcZset_event_loop_policyZrun_until_completerF)r	rZZloopr
r�r�test_asyncio_1Cs


z$CoroAsyncIOCompatTest.test_asyncio_1N)rrrr�r
r
r
rr�Asr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�OriginTrackingTestcCst�t��j�}|j|jfSr)rHZgetframeinfo�currentframe�f_back�filename�lineno)r	�infor
r
r�herelszOriginTrackingTest.herec	s�t��}�z�dd��t�d���t��d�t�����}��|j�W5QRXt�d���t��d����\}}t����� }��|j||ddff�W5QRXt�d���t��d���fdd�}���\}}|�\\}}}t�|��(��|j||d	f||ddff�W5QRXt�d
�t�����,}��	dt
|j�k�oZd
kn�W5QRX��t��t�d�W5QRX��t��d
�W5t�|�XdS)Nc�sdSrr
r
r
r
r�corofnssz7OriginTrackingTest.test_origin_tracking.<locals>.corofnrr&�test_origin_trackingr%cs�����fSr)r�r
�r�r	r
r�nested�sz7OriginTrackingTest.test_origin_tracking.<locals>.nestedr�r����)
rB�#get_coroutine_origin_tracking_depth�#set_coroutine_origin_tracking_depthrF�
contextlib�closingr��	cr_originr�rGrbr7r�)r	�
orig_depthr Zfnamer�r�Znested_fnameZ
nested_linenor
r�rr�ps@

�
��
0z'OriginTrackingTest.test_origin_trackingc
s�dd�����\}}�fdd��|d7}���\}}�fdd��|d7}��fdd	�}t��}z�|d
d�j�d��}|d
d�d�j�d�dd|�d|�d�dg��|dd�d�j�d�dd|�d|�d�dd|�d|�d�dg��W5t�|�XdS)Nc�sdSrr
r
r
r
rr��sz?OriginTrackingTest.test_origin_tracking_warning.<locals>.corofncs��Srr
r
)r�r
r�a1�sz;OriginTrackingTest.test_origin_tracking_warning.<locals>.a1r%cs��Srr
r
)r�r
r�a2�sz;OriginTrackingTest.test_origin_tracking_warning.<locals>.a2c	sDt�|���t��}��t��W5QRX��|t|j��dSr)	rBr�ZassertWarnsr�rr/rFr��warning)�depth�msgr )r�r	r
rrp�s

z>OriginTrackingTest.test_origin_tracking_warning.<locals>.checkrzcoroutine 'z' was never awaitedr&rtz' was never awaited
z-Coroutine created at (most recent call last)
z  File "z", line z, in a1
z$    return corofn()  # comment in a1z, in a2
z!    return a1()  # comment in a2
)r�rBr�r�rrE)r	Za1_filenameZ	a1_linenoZa2_filenameZ	a2_linenorpr�r�r
)r�r�r�r	r�test_origin_tracking_warning�s4��
z/OriginTrackingTest.test_origin_tracking_warningc
Cs�dd�}tj}z�dd�t_t���\}t�dtf��B|�}t|�}~t��|�t|j	j
�|�|�|j	jt�W5QRXW5QRXt`t�dtf��|�t��W5QRXW5|t_XdS)Nc�sdSrr
r
r
r
rr��szLOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.corofncSsddSrr
rzr
r
rrh�rNzNOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.<lambda>zcoroutine .* was never awaited)
r,�_warn_unawaited_coroutinerr�Zcheck_warningsr�rbr/rFr�r�r�r�)r	r�Zorig_wucr r r�r
r
r�)test_unawaited_warning_when_module_broken�s,

��$�z<OriginTrackingTest.test_unawaited_warning_when_module_brokenN)rrrr�r�r�r�r
r
r
rr�ks.*r�c@seZdZdd�ZdS)�"UnawaitedWarningDuringShutdownTestcCs.d}td|�d}td|�d}td|�dS)Nz7import asyncio
async def f(): pass
asyncio.gather(f())
z-cz.import sys
async def f(): pass
sys.coro = f()
zYimport sys
async def f(): pass
sys.corocycle = [f()]
sys.corocycle.append(sys.corocycle)
r)r	r3r
r
r�&test_unawaited_warning_during_shutdown�s

zIUnawaitedWarningDuringShutdownTest.test_unawaited_warning_during_shutdownN)rrrr�r
r
r
rr��sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�CAPITestcs0ddlm��fdd�}|�|��d�d�dS)Nr��	awaitTypec�s�tdg��}|IdHSrrr���future��atr
rrB	sz%CAPITest.test_tp_await_1.<locals>.foor&)�	_testcapir�rFrr_r
r�r�test_tp_await_1	szCAPITest.test_tp_await_1cCs2ddlm}|tdg��}|�t|���d�dS)Nrr�r&)r�r�rorFr'r)r	r�r�r
r
r�test_tp_await_2
	szCAPITest.test_tp_await_2c	sHddlm��fdd�}|�td��|�|��d�d�W5QRXdS)Nrr�c�s�d�}|IdHSrrr
r�r�r
rrB	sz%CAPITest.test_tp_await_3.<locals>.fooz.__await__.*returned non-iterator of type 'int'r&)r�r�r]rgrFrr_r
r�r�test_tp_await_3	s�zCAPITest.test_tp_await_3N)rrrr�r�r�r
r
r
rr��s	r��__main__)r�r�rHr�rBrZunittestr,�testrZtest.support.script_helperrrrr$r*�contextmanagerr0ZTestCaser1r?rLr�r�r�Zcpython_onlyr�rrRr
r
r
r�<module>sP
X*