
    daf                       d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	m
Z
 d dlmZ d dlmZ d dlmZ  G d d      Z G d d	      Zd
 Zd Zd Ze j*                  d        Z G d dej.                        Z G d dej.                        Z G d dej.                        Z ej6                  e
j8                  xs e
j:                  d       G d dej.                               Z G d dej.                        Z G d dej.                        Z e
jB                   G d dej.                               Z"e#dk(  r ejH                          yy)    N)support)import_helper)warnings_helperassert_python_okc                       e Zd Zd Zd Zy)AsyncYieldFromc                     || _         y Nobj)selfr   s     //root/Python-3.12.4/Lib/test/test_coroutines.py__init__zAsyncYieldFrom.__init__   s	        c              #   8   K   | j                   E d {    y 7 wr   r   r   s    r   	__await__zAsyncYieldFrom.__await__   s     88s   N__name__
__module____qualname__r   r    r   r   r	   r	      s    r   r	   c                       e Zd Zd Zd Zy)
AsyncYieldc                     || _         y r   value)r   r   s     r   r   zAsyncYield.__init__   s	    
r   c              #   (   K   | j                    y wr   r   r   s    r   r   zAsyncYield.__await__   s     jjs   Nr   r   r   r   r   r      s    r   r   c                $   K   | D ]  }| 	 yw)z0Convert an iterable to an asynchronous iterator.Nr   )iterablexs     r   	asynciterr#       s         c                    | j                   t        j                  t        j                  hv sJ g }d }	 	 |j	                  | j                  d              "# t        $ r*}|j                  r|j                  d   nd }Y d }~||fS d }~ww xY wNr   )	__class__typesGeneratorTypeCoroutineTypeappendsendStopIterationargs)corobufferresultexs       r   	run_asyncr3   &   s    >>e1153F3FGGGGFF
	MM$))D/*   	#%77RWWQZF6>	s    A 	B	BB	c                 f   | j                   t        j                  u sJ | j                         }g }d }d}	 	 |dz  r|j	                  t        |             n |j	                  |j                  d              |dz  }G# t        $ r*}|j                  r|j                  d   nd }Y d }~||fS d }~ww xY w)Nr         )	r'   r(   r*   r   r+   nextr,   r-   r.   )r/   awr0   r1   ir2   s         r   run_async__await__r:   4   s    >>U00000		BFF	A
	1ud2h'bggdm,FA   	#%77RWWQZF6>	s   AA= =	B0B++B0c               #      K   t        j                         5  t        j                  d       d  t        j                          d d d        y # 1 sw Y   y xY ww)Nignore)warningscatch_warningssimplefilterr   
gc_collectr   r   r   silence_coro_gcrA   G   sC     		 	 	" h'  s   A.A	AAAc                   $    e Zd Zd Zd Zd Zd Zy)AsyncBadSyntaxTestc                     g d}|D ]H  }| j                  |      5  | j                  t              5  t        |dd       d d d        d d d        J y # 1 sw Y   xY w# 1 sw Y   axY w)N)>z9def foo():
                await something()
            zawait 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]
            zasync def foo():
                def bar():
                 [i for i in els
                    async for b in els]
            zasync def foo():
                def bar():
                 [i for i in els
                    for c in b
                    async for b in els]
            zasync def foo():
                def bar():
                 [i for i in els
                    async for b in els
                    for c in b]
            zkasync def foo():
                def bar():
                 [[async for i in b] for b in els]
            zasync def foo():
                def bar():
                 [i for i in els
                    for b in await els]
            zasync 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]
            zdef bar():
                 [i for i in els
                    for c in b
                    async for b in els]
            zdef 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]
            zMdef bar():
                 [[i async for i in a] for a in elts]
            z1[[i async for i in a] for a in elts]
            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
            zdef foo():
                   def baz(): pass
                   # 456
                   async def bar(): pass
                   # 123
                   await a
            zasync def foo():
                   def baz(): pass
                   # 456
                   async def bar(): pass
                   # 123
                   await = 2
            zdef foo():

                   def baz(): pass

                   async def bar(): pass

                   await a
            zasync 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
            zasync def foo():
                   def bar():
                        def baz():
                            async = 1
            zasync def foo():
                   def bar():
                        def baz():
                            pass
                        async = 1
            zdef foo():
                   async def bar():

                        async def baz():
                            pass

                        def baz():
                            42

                        async = 1
            zasync def foo():
                   def bar():
                        def baz():
                            pass
await foo()
            zdef 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subTestassertRaisesSyntaxErrorcompiler   samplesrF   s      r   test_badsyntax_1z#AsyncBadSyntaxTest.test_badsyntax_1Q   sr    ~@
  	0D4( 0$*;*;K*H 0h/0 0 0	00 0 0 0"   AA AAAA(	c                     g d}|D ]H  }| j                  |      5  | j                  t              5  t        |dd       d d d        d d d        J y # 1 sw Y   xY w# 1 sw Y   axY w)N)	z1def foo():
                await = 1
            z9class Bar:
                def async(): pass
            z1class Bar:
                async = 1
            z.class async:
                pass
            z.class await:
                pass
            zimport math as awaitz!def async():
                passz2def foo(*, await=1):
                passasync = 1zprint(await=1)rE   rG   rH   rI   rN   s      r   test_badsyntax_2z#AsyncBadSyntaxTest.test_badsyntax_2  sq     
D  	0D4( 0$*;*;K*H 0h/0 0 0	00 0 0 0rQ   c                 r    | j                  t              5  t        ddd       d d d        y # 1 sw Y   y xY w)Nz	async = 1rG   rH   )rK   rL   rM   r   s    r   test_badsyntax_3z#AsyncBadSyntaxTest.test_badsyntax_3  s1    {+ 	3K62	3 	3 	3s   -6c                     g d}|D ]H  }| j                  |      5  | j                  t              5  t        |dd       d d d        d d d        J y # 1 sw Y   xY w# 1 sw Y   axY w)N)zdef foo(await):
                async def foo(): pass
                async def foo():
                    pass
                return await + 1
            zdef foo(await):
                async def foo(): pass
                async def foo(): pass
                return await + 1
            zdef foo(await):

                async def foo(): pass

                async def foo(): pass

                return await + 1
            zdef 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
            rE   rG   rH   rI   rN   s      r   test_badsyntax_4z#AsyncBadSyntaxTest.test_badsyntax_4  sq    +
Z  	0D4( 0$*;*;K*H 0h/0 0 0	00 0 0 0rQ   N)r   r   r   rP   rS   rU   rW   r   r   r   rC   rC   O   s    C0J
%0N300r   rC   c                       e Zd Zd Zy)TokenizerRegrTestc                    g }t        d      D ]#  }|j                  dj                  |             % dj                  |      }i }t	        |||       | j                   |d          d       |dz  }i }t	        |||       | j                   |d          d       | j                  t        j                  |d                y )	Ni  zdef i{i}(): return {i}r9   
i499i  z
async def foo():
    returnfoo)	ranger+   formatjoinrH   assertEqual
assertTrueinspectiscoroutinefunction)r   bufr9   nss       r   test_oneline_defsz#TokenizerRegrTest.test_oneline_defs  s    s 	=AJJ/666;<	=iin S"bFs+ 	//S"bFs+33BuI>?r   N)r   r   r   rh   r   r   r   rY   rY     s    @r   rY   c                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9d8 Z:d9 Z;d: Z<d; Z=d< Z>d= Z?d> Z@d? ZAd@ ZBdA ZCdB ZDdC ZEdD ZFdE ZGdF ZHdG ZIdH ZJdI ZKdJ ZLdK ZMdL ZNdM ZOdN ZPdO ZQdP ZRdQ ZSdR ZTdS ZUdT ZVyU)VCoroutineTestc                 @    d }| j                  t        |d             y )Nc               3      K   d  y wr   r   r   r   r   genz%CoroutineTest.test_gen_1.<locals>.gen  s     5   r   )assertFalsehasattr)r   rm   s     r   
test_gen_1zCoroutineTest.test_gen_1  s    k23r   c                 R   d } |       }| j                  |t        j                         | j                  t	        |j
                  j                  t        j                  z               | j                  t	        |j
                  j                  t        j                  z               | j                  t	        |j                  j                  t        j                  z               | j                  t	        |j                  j                  t        j                  z               | j                  t        |      g df       | j                  t         |             g df       d }| j                  t	        |j
                  j                  t        j                  z               y )Nc                     K   ywN
   r   r   r   r   r^   z&CoroutineTest.test_func_1.<locals>.foo  	        ru   c                       y r   r   r   r   r   barz&CoroutineTest.test_func_1.<locals>.bar  s    4r   )assertIsInstancer(   r*   rc   bool__code__co_flagsrd   CO_COROUTINEro   CO_GENERATORcr_coderb   r3   r:   r   r^   fry   s       r   test_func_1zCoroutineTest.test_func_1  s!   	 Ea!4!45S\\22W5I5IIJKcll33g6J6JJKLQYY//'2F2FFGHaii0073G3GGHI1Bx0+CE2RH=cll33g6J6JJKLr   c                     d }| j                  t        d      5  t         |              d d d        y # 1 sw Y   y xY w)Nc                     K   t         wr   r-   r   r   r   r^   z&CoroutineTest.test_func_2.<locals>.foo"          	zcoroutine raised StopIteration)assertRaisesRegexRuntimeErrorr3   r   r^   s     r   test_func_2zCoroutineTest.test_func_2!  s?    	  ##>@ 	 ce	 	 	   4=c                 n    d } |       }| j                  t        |      d       |j                          y )Nc                     K   t         wr   r   r   r   r   r^   z&CoroutineTest.test_func_3.<locals>.foo+  r   r   z^<coroutine object.* at 0x.*>$)assertRegexreprclose)r   r^   r/   s      r   test_func_3zCoroutineTest.test_func_3*  s.    	  ud%EF

r   c                 &    d } |       } fd} |       5  t        |       d d d         |       5  t        |       d d d         |       5  t        |       d d d         |       5  t        |       d d d         |       5  |D ]  } 	 d d d         |       5  |D cg c]  }| c} d d d        |j	                          y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   vxY w# 1 sw Y   jxY wc c}w # 1 sw Y   [xY w)Nc                     K   t         wr   r   r   r   r   r^   z&CoroutineTest.test_func_4.<locals>.foo3  r   r   c                  0     j                  t        d      S Nz"'coroutine' object is not iterabler   	TypeErrorr   s   r   <lambda>z+CoroutineTest.test_func_4.<locals>.<lambda>7      ..;= r   )listtuplesumiterr   )r   r^   r/   checkr9   s   `    r   test_func_4zCoroutineTest.test_func_42  s	   	 u= W 	J	 W 	$K	 W 	I	 W 	J	 W 	 	 W 	1Q	 	

'	 		 		 		 		 	
 	 	sX   CCC)C*C6D!	D*DCCC'*C36C?DDc                     t         j                  d        fd} fd} |       } |       5  |D ]  } 	 d d d        |j                                  D ]  } j                  |d         j                          D cg c]  }| c}dg        j                  t	                      d        j                  t        t                            d       y # 1 sw Y   xY wc c}w )Nc               3      K   d y wNr6   r   r   r   r   ry   z&CoroutineTest.test_func_5.<locals>.barP  s     Grn   c                  0   K             d {    y 7 wr   r   ry   s   r   r^   z&CoroutineTest.test_func_5.<locals>.fooT       %KK   c                  0     j                  t        d      S r   r   r   s   r   r   z+CoroutineTest.test_func_5.<locals>.<lambda>W  r   r   r6   r6   )r(   	coroutiner   rb   r   r7   r   )r   r^   r   r/   elry   s   `    @r   test_func_5zCoroutineTest.test_func_5O  s    		 
		= uW 	 	 	

 % 	$BR#	$su-"-s3sut,d35k*A.	 	 .s   C 	C, C)c                 D   t         j                  d        fd} |       }| j                  |j                  d       d       | j                  |j                  d       d       | j	                  t
              5  |j                  d        d d d        y # 1 sw Y   y xY w)Nc               3      K   d d y wNr6   r5   r   r   r   r   ry   z&CoroutineTest.test_func_6.<locals>.barh  s     GGs   
c                  0   K             d {    y 7 wr   r   r   s   r   r^   z&CoroutineTest.test_func_6.<locals>.foom  r   r   r6   r5   )r(   r   rb   r,   rK   r-   r   s      @r   test_func_6zCoroutineTest.test_func_6g  s    		 
		 Eq)q)}- 	FF4L	 	 	s   ;BBc                     d } |       fd}| j                  t        d      5  t         |              d d d        j                          y # 1 sw Y   xY w)Nc                     K   ywrt   r   r   r   r   ry   z&CoroutineTest.test_func_7.<locals>.barw  rv   rw   c               3   &   K    E d {    y 7 wr   r   r/   s   r   r^   z&CoroutineTest.test_func_7.<locals>.foo{  s     OOs   zCcannot 'yield from' a coroutine object in a non-coroutine generator)r   r   r   r   r   ry   r^   r/   s      @r   test_func_7zCoroutineTest.test_func_7v  sW    	u	 ##,- 	 K		 	

	 	s   AAc                     t         j                  fd       }d } |       | j                  t         |             g df       j	                          y )Nc               3   $   K    E d {   S 7 wr   r   r   s   r   ry   z&CoroutineTest.test_func_8.<locals>.bar  s     #O$Os   c                     K   ywNspamr   r   r   r   r^   z&CoroutineTest.test_func_8.<locals>.foo  	     rw   r   )r(   r   rb   r3   r   r   s      @r   test_func_8zCoroutineTest.test_func_8  sK    		% 
	%	 u35)B<8

r   c                    d }| j                  t        d      5   |        t        j                          d d d        | j                  t        d      5  | j	                  t
              5   |       D ]  } 	 d d d        t        j                          d d d        y # 1 sw Y   hxY w# 1 sw Y   2xY w# 1 sw Y   y xY w)Nc                     K   y wr   r   r   r   r   r^   z&CoroutineTest.test_func_9.<locals>.foo  	     rw   z0coroutine '.*test_func_9.*foo' was never awaited)assertWarnsRegexRuntimeWarningr   r@   rK   r   )r   r^   _s      r   test_func_9zCoroutineTest.test_func_9  s    	 ""CE 	! E 	! ""CE 		! ""9-  A
  		! 		!	! 	! 			! 		!s/   BB5*B)8B5B&)B2	.B55B>c                    dt         j                  fd       fd} |       }|j                         }| j                  |t	        |             t        |       | j                  |j                  d      d       | j                  d       |j                          | j                  d        |       }|j                         }t        |       | j                  t              5  |j                  t                      d d d        | j                  d        |       }|j                         }t        |       | j                  t              5  | j                  t              5  |j                  t        t               d        d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nr   c               3   l   K   	 d } | dz   	 dz  y # t         $ r dz   w xY w# dz  w xY ww)Nr5   d   r6   ZeroDivisionError)aNs    r   rm   z'CoroutineTest.test_func_10.<locals>.gen  sM     Av
 Q	 % S Qs   4 4'* 14c                  0   K             d {    y 7 wr   r   rm   s   r   r^   z'CoroutineTest.test_func_10.<locals>.foo  r   r   ru   r   r6   f   )r(   r   r   assertIsr   r7   rb   r,   r   rK   r   throwassertWarnsDeprecationWarning)r   r^   r/   r8   r   rm   s       @@r   test_func_10zCoroutineTest.test_func_10  su   			 
			 u^^b$r(#Rc*A

Au^^R01 	*HH&()	*C u^^R01 	G!!"45 G*,=,?FG	G 	G	* 	*G G	G 	Gs0   +FF5, F)F5F&)F2	.F55F>c                    d } |       }| j                  dt        |             | j                  dt        |j                                      | j                  dt        |j                                      |j	                          y )Nc                     K   y wr   r   r   r   r   funcz(CoroutineTest.test_func_11.<locals>.func       $rw   r   __iter__coroutine_wrapper)assertIndirr   r   r   )r   r   r/   s      r   test_func_11zCoroutineTest.test_func_11  s^    v 	k3t9-j#dnn&6"78)40@+AB

r   c                     fd} |       | j                  t        d      5  j                  d        d d d        y # 1 sw Y   y xY w)Nc                  P   K   j                  d       } t         d {    y 7 wr   )r,   r^   )r9   mes    r   gz%CoroutineTest.test_func_12.<locals>.g  s     AIIs   &$&zcoroutine already executing)r   
ValueErrorr,   )r   r   r   s     @r   test_func_12zCoroutineTest.test_func_12  sE    	 S##J$AC 	GGDM	 	 	s	   ?Ac                     d } |       }| j                  t        d      5  |j                  d       d d d        |j                          y # 1 sw Y   xY w)Nc                     K   y wr   r   r   r   r   r   z%CoroutineTest.test_func_13.<locals>.g  r   rw   z5can't send non-None value to a just-started coroutiner   )r   r   r,   r   )r   r   r/   s      r   test_func_13zCoroutineTest.test_func_13  sS    	 s##GI 	 IIf	
 	

	 	s   AAc                     t         j                  d        fd} |       }|j                  d        | j                  t        d      5  |j                          d d d        y # 1 sw Y   y xY w)Nc               3      K   d  y wr   r   r   r   r   rm   z'CoroutineTest.test_func_14.<locals>.gen  	     rn   c                  p   K   	           d {    y 7 # t         $ r           d {  7   Y y w xY wwr   GeneratorExitr   s   r   r/   z(CoroutineTest.test_func_14.<locals>.coro  s,     e  es0   6
  6 3-3636zcoroutine ignored GeneratorExit)r(   r   r,   r   r   r   )r   r/   crm   s      @r   test_func_14zCoroutineTest.test_func_14  sd    		 
		
 F	t##L$EG 	GGI	 	 	s   A%%A.c                 &   d }d } |       }| j                  t        d      5   ||      j                  d        d d d        | j                  t        d      5   ||      j                  d        d d d        y # 1 sw Y   @xY w# 1 sw Y   y xY w)Nc                     K   ywr   r   r   r   r   spammerz+CoroutineTest.test_func_15.<locals>.spammer  r   rw   c                 "   K   |  d {   S 7 wr   r   r   s    r   readerz*CoroutineTest.test_func_15.<locals>.reader  s     ::s   r   &cannot reuse already awaited coroutine)r   r-   r,   r   )r   r   r   spammer_coros       r   test_func_15zCoroutineTest.test_func_15   s    		 y##M6: 	,< %%d+	, ##L$LN 	,< %%d+	, 	,	, 	,	, 	,s   A;B;BBc                 f   t         j                  d        fd}fd} |       } ||      }|j                  d        |j                  d        | j                  t        d      5  |j                  t	        d             d d d         ||      }|j                  d        | j                  t        d      5  |j                  d        d d d        | j                  t        d      5  |j                  t	        d             d d d        y # 1 sw Y   xY w# 1 sw Y   OxY w# 1 sw Y   y xY w)Nc               3      K   d  y wr   r   r   r   r   nopz'CoroutineTest.test_func_16.<locals>.nop  r   rn   c                  0   K             d {    y7 wr   r   r   s   r   r,   z(CoroutineTest.test_func_16.<locals>.send  s     %KK r   c                 F   K            d {    |  d {   S 7 7 wr   r   )r/   r   s    r   readz(CoroutineTest.test_func_16.<locals>.read  s!     %KK: s   !	!!!hamr   wat)r(   r   r,   r   	Exceptionr   r   )r   r,   r   r   r   r   s        @r   test_func_16zCoroutineTest.test_func_16  s    
	 
			 &gDD##Iu5 	+LL5)*	+ gD##L$LN 	KK	 ##L$LN 	+LL5)*	+ 	+	+ 	+
	 		+ 	+s$   )D;D+D'DD$'D0c                    d } |       }| j                  t        d      5  |j                  d        d d d        | j                  t        d      5  |j                  d        d d d        | j                  t        d      5  |j	                  t        d             d d d        |j                          |j                          y # 1 sw Y   xY w# 1 sw Y   oxY w# 1 sw Y   BxY w)Nc                     K   ywr   r   r   r   r   r   z-CoroutineTest.test_func_17.<locals>.coroutine3  r   rw   r   r   r   )r   r-   r,   r   r   r  r   )r   r   r/   s      r   test_func_17zCoroutineTest.test_func_170  s    	 {##M6: 	IIdO	 ##L$LN 	IIdO	 ##L$LN 	)JJy'(	) 	



	 		 		) 	)s#   CCCCCC&c                    d } |       }|j                         }t        |      }| j                  t        d      5  |j	                  d        d d d        | j                  t
        d      5  |j	                  d        d d d        | j                  t
        d      5  t        |       d d d        | j                  t
        d      5  |j                  t        d             d d d        | j                  t
        d      5  |j                  t        d             d d d        |j                          |j                          y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   ZxY w)Nc                     K   ywr   r   r   r   r   r   z-CoroutineTest.test_func_18.<locals>.coroutineJ  r   rw   r   r   r   )
r   r   r   r-   r,   r   r7   r   r  r   )r   r   r/   
await_iterits        r   test_func_18zCoroutineTest.test_func_18G  sL   	 {^^%
*##M6: 	GGDM	 ##L$LN 	GGDM	 ##L$LN 	 H	 ##L$LN 	'HHYu%&	' ##L$LN 	'HHYu%&	' 	


9	 		 		 		' 	'	' 	's;   E,EEE'?E3EEE$'E03E<c                 d   dt         j                  fd       fd} |       }|j                  d        |j                  d        | j                  d       |j	                          | j                  d       t        d      D ]$  }|j	                          | j                  d       & y )Nr   c               3   H   K   d  	 d  y # t         $ r  dz   Y y w xY wwr   r   )CHKs   r   r^   z'CoroutineTest.test_func_19.<locals>.foor  s+        qs   " """c                  0   K             d {    y 7 wr   r   )r^   s   r   r   z-CoroutineTest.test_func_19.<locals>.coroutine{  r   r   r6      )r(   r   r,   rb   r   r_   )r   r   r/   r   r  r^   s       @@r   test_func_19zCoroutineTest.test_func_19o  s    		 
		 {		$		$a 

a q 	%A JJLS!$		%r   c                 R    d }t         |             }| j                  |g df       y )Nc                     K   yw)Nru   r   r   r   r   r^   z7CoroutineTest.test_coro_wrapper_send_tuple.<locals>.foo  s	     rw   r  )r:   rb   r   r^   r1   s      r   test_coro_wrapper_send_tuplez*CoroutineTest.test_coro_wrapper_send_tuple  s)    	 $CE*"e-r   c                     d }t         |             }| j                  |d   t               | j                  |d   j                  d       y )Nc                      K   t        d      S wrt   r   r   r   r   r^   z?CoroutineTest.test_coro_wrapper_send_stop_iterator.<locals>.foo  s      $$   r6   ru   )r:   rz   r-   rb   r   r  s      r   $test_coro_wrapper_send_stop_iteratorz2CoroutineTest.test_coro_wrapper_send_stop_iterator  sA    	% $CE*fQi7"-r   c                     t         j                   fd       fd fd} |        j                  t        j                        t        j
                          j                  j                         j                  d         j                  t        j                        t        j                          j                  j                  j                  j                  j                  d        j                  t              5  j                  d        d d d         j                  t        j                        t        j                          j                  j                         y # 1 sw Y   XxY w)Nc               3   N  K   j                  t        j                         t        j                         j	                   j
                         d  j                  t        j                         t        j                         j	                   j
                         y wr   )rb   rd   getcoroutinestateCORO_RUNNINGassertIsNonecr_await)coro_br   s   r   r   z&CoroutineTest.test_cr_await.<locals>.a  sp     W66v>@T@TUfoo.W66v>@T@TUfoo.s   B"B%c                  0   K             d {    y 7 wr   r   )r   s   r   r   z&CoroutineTest.test_cr_await.<locals>.c  s     #IIr   c                     K   j                  j                                   d {    j                  j                         y 7  wr   )r  r  )r   r   r   s   r   bz&CoroutineTest.test_cr_await.<locals>.b  s9     foo.#IIfoo. s   &AA
!Ar   )r(   r   rb   rd   r  CORO_CREATEDr  r  r,   CORO_SUSPENDEDgi_codeco_namerK   r-   CORO_CLOSED)r   r#  r   r   r   s   ` @@@r   test_cr_awaitzCoroutineTest.test_cr_await  s   		/ 
	/		/
 226:G<P<PQ&//*D226:G<R<RS1199AA3G}- 	KK	226:G<O<OP&//*	 	s   E;;Fc                 n   t         j                  }t        j                  s| j	                  d|j
                  j                         | j	                  d|j                  j                         | j	                  d|j                  j                         | j	                  d|j                  d   j                         | j	                  d|j                  d   j                         | j                  |j                  d       d } |       }| j	                  d	t        |             |j                          y )
Nzinto coroutinezinside coroutinezin coroutinezof the coroutiner   r   r   c                     K   y wr   r   r   r   r   r   z(CoroutineTest.test_corotype_1.<locals>.f  s     trw   zcoroutine object)r(   r*   r   MISSING_C_DOCSTRINGSr   r,   __doc__r   r   __dict__rb   r   r   )r   ctr   r   s       r   test_corotype_1zCoroutineTest.test_corotype_1  s      ++MM*BGGOO<MM,bhh.>.>?MM."((*:*:;MM,bkk*.E.M.MNMM,bkk..I.Q.QRk2C($q'2		r   c                     d }| j                  t        d      5  t         |              d d d        y # 1 sw Y   y xY w)Nc                  $   K   d d {    y 7 wr   r   r   r   r   r^   z'CoroutineTest.test_await_1.<locals>.foo  s     GG   zobject int can.t.*awaitr   r   r3   r   s     r   test_await_1zCoroutineTest.test_await_1  s7    	##I/HI 	ce	 	 	r   c                     d }| j                  t        d      5  t         |              d d d        y # 1 sw Y   y xY w)Nc                  $   K   g  d {    y 7 wr   r   r   r   r   r^   z'CoroutineTest.test_await_2.<locals>.foo  s     HHr3  zobject list can.t.*awaitr4  r   s     r   test_await_2zCoroutineTest.test_await_2  s7    	##I/IJ 	ce	 	 	r   c                     d }| j                  t         |             g dd f       | j                  t         |             g dd f       y )Nc                  :   K   t        g d       d {    y 7 wNr6   r5   r  )r	   r   r   r   r^   z'CoroutineTest.test_await_3.<locals>.foo  s      +++s   r<  )rb   r3   r:   r   s     r   test_await_3zCoroutineTest.test_await_3  sB    	, 	35)It+<=+CE2Y4EFr   c                 Z    d fd}| j                  t         |             g df       y )Nc                     K   ywN*   r   r   r   r   ry   z'CoroutineTest.test_await_4.<locals>.bar  rv   rw   c                  .   K             d {   S 7 wr   r   r   s   r   r^   z'CoroutineTest.test_await_4.<locals>.foo  s     ;;   rA  rb   r3   )r   r^   ry   s     @r   test_await_4zCoroutineTest.test_await_4  s*    		 	35)B84r   c                      G d d      fd}| j                  t        d      5  t         |              d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zd Zy)-CoroutineTest.test_await_5.<locals>.Awaitablec                      y r   r   r   s    r   r   z7CoroutineTest.test_await_5.<locals>.Awaitable.__await__  s    r   Nr   r   r   r   r   r   r   	AwaitablerH    s    r   rK  c                  .   K             d {   S 7 wr   r   rK  s   r   r^   z'CoroutineTest.test_await_5.<locals>.foo       #+%&%rC  (__await__.*returned non-iterator of typer4  r   r^   rK  s     @r   test_await_5zCoroutineTest.test_await_5  sJ    	 		' ##AC 	 ce	 	 	   AA
c                 j     G d d      fd}| j                  t         |             dgd f       y )Nc                       e Zd Zd Zy)-CoroutineTest.test_await_6.<locals>.Awaitablec                     t        dg      S )N4   r   r   s    r   r   z7CoroutineTest.test_await_6.<locals>.Awaitable.__await__  s    RDz!r   NrJ  r   r   r   rK  rU    s    "r   rK  c                  .   K             d {   S 7 wr   r   rM  s   r   r^   z'CoroutineTest.test_await_6.<locals>.foo  rN  rC  rW  rD  rP  s     @r   test_await_6zCoroutineTest.test_await_6  s1    	" 	"	' 	35)RD$<8r   c                 j     G d d      fd}| j                  t         |             dgdf       y )Nc                       e Zd Zd Zy)-CoroutineTest.test_await_7.<locals>.Awaitablec              3      K   d yw)NrA  r   r   r   s    r   r   z7CoroutineTest.test_await_7.<locals>.Awaitable.__await__  s     rn   NrJ  r   r   r   rK  r]    s    r   rK  c                  .   K             d {   S 7 wr   r   rM  s   r   r^   z'CoroutineTest.test_await_7.<locals>.foo  rN  rC  rA  r   rD  rP  s     @r   test_await_7zCoroutineTest.test_await_7  s1    	 	
	' 	35)RD#;7r   c                      G d d      fd}| j                  t        d      5  t         |              d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zy)-CoroutineTest.test_await_8.<locals>.AwaitableNr   r   r   r   r   r   rK  rc  	      r   rK  c                  .   K             d {   S 7 wr   r   rM  s   r   r^   z'CoroutineTest.test_await_8.<locals>.foo  s     ik 11 1rC  z4object Awaitable can't be used in 'await' expressionr4  rP  s     @r   test_await_8zCoroutineTest.test_await_8  sH    	 	 	2##MO 	 ce	 	 	rR  c                     fdd fd}fd}| j                  t         |             g df       | j                  t         |             g df       y )Nc                       S r   r   r   s   r   wrapz(CoroutineTest.test_await_9.<locals>.wrap  s    Jr   c                     K   ywr@  r   r   r   r   ry   z'CoroutineTest.test_await_9.<locals>.bar  rv   rw   c                  *  K   dfdi}  G fdd      }         d {                    d {   z      | d                         d {   z            d {   dz  z    |j                                 d {   z   S 7 g7 V7 ;7 -7 w)Nr#  c                       S r   r   rj  s   r   r   z9CoroutineTest.test_await_9.<locals>.foo.<locals>.<lambda>  s     r   c                       e Zd ZW  Zy)3CoroutineTest.test_await_9.<locals>.foo.<locals>.DBN)r   r   r   r#  rn  s   r   DBrp    s    r   rq    r#  )dbrq  ry   rj  s     r   r^   z'CoroutineTest.test_await_9.<locals>.foo  s     %B  %K.0C3FF%K$&'/5rttvx8 9K.3FsU   BB	BBBBB!B" BBBBBBBc                  0   K             d {    S 7 wr   r   r   s   r   foo2z(CoroutineTest.test_await_9.<locals>.foo2#  s     %K<Kr   i  irD  )r   r^   rv  ry   rj  s      @@r   test_await_9zCoroutineTest.test_await_9  sO    			9	  	35)B;746*RI6r   c                 f    d fdfd}| j                  t         |             g df       y )Nc                     K   ywr@  r   r   r   r   bazz(CoroutineTest.test_await_10.<locals>.baz*  rv   rw   c                     K            S wr   r   )rz  s   r   ry   z(CoroutineTest.test_await_10.<locals>.bar-  s     5Ls   c                  B   K             d {    d {   S 7 7 wr   r   r   s   r   r^   z(CoroutineTest.test_await_10.<locals>.foo0  s      #+&&+&s   rA  rD  )r   r^   ry   rz  s     @@r   test_await_10zCoroutineTest.test_await_10)  s/    			' 	35)B84r   c                 n    d d fd}fd}| j                  t         |             g df       y )Nc                     | S r   r   vals    r   identz*CoroutineTest.test_await_11.<locals>.ident6  s    Jr   c                     K   ywr   r   r   r   r   ry   z(CoroutineTest.test_await_11.<locals>.bar9  r   rw   c                  <   K              d {         S 7 	w)Nr  r   )ry   r  s   r   r^   z(CoroutineTest.test_await_11.<locals>.foo<  s     35[))[s   
c                  2   K             d {   dfS 7 w)Nr   r   r   s   r   rv  z)CoroutineTest.test_await_11.<locals>.foo2?  s     ;%%;s   )r   r   rD  )r   r^   rv  ry   r  s      @@r   test_await_11zCoroutineTest.test_await_115  s5    			*	& 	46*R,ABr   c                     d } |        G fdd      fd}| j                  t        d      5  t         |              d d d        j                          y # 1 sw Y   xY w)Nc                     K   ywr   r   r   r   r   r/   z)CoroutineTest.test_await_12.<locals>.coroE  r   rw   c                       e Zd Z fdZy).CoroutineTest.test_await_12.<locals>.Awaitablec                     S r   r   )r   r   s    r   r   z8CoroutineTest.test_await_12.<locals>.Awaitable.__await__J  s    r   NrJ  r   s   r   rK  r  I  s    r   rK  c                  .   K             d {   S 7 wr   r   rM  s   r   r^   z(CoroutineTest.test_await_12.<locals>.fooM       "$$$rC  z"__await__\(\) returned a coroutine)r   r   r3   r   )r   r/   r^   rK  r   s      @@r   test_await_12zCoroutineTest.test_await_12D  s_    	F	 		% ##@B 	ce	 	
			 	s   AA'c                      G d d      fd}| j                  t        d      5  t         |              d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zd Zy).CoroutineTest.test_await_13.<locals>.Awaitablec                     | S r   r   r   s    r   r   z8CoroutineTest.test_await_13.<locals>.Awaitable.__await__X      r   NrJ  r   r   r   rK  r  W      r   rK  c                  .   K             d {   S 7 wr   r   rM  s   r   r^   z(CoroutineTest.test_await_13.<locals>.foo[  r  rC  rO  r4  rP  s     @r   test_await_13zCoroutineTest.test_await_13V  sJ    	 		% ##AC 	 ce	 	 	rR  c                     G d d       G d d       G d dt               fdfd} |       }|j                  d        | j                  t        d	      5  |j                  d	       d d d         |       }|j                  d        | j	                        5  |j                  t               d d d        y # 1 sw Y   QxY w# 1 sw Y   y xY w)
Nc                       e Zd Zd Zd Zy),CoroutineTest.test_await_14.<locals>.Wrapperc                 N    |j                   t        j                  u sJ || _        y r   )r'   r(   r*   r/   )r   r/   s     r   r   z5CoroutineTest.test_await_14.<locals>.Wrapper.__init__f  s!    ~~)<)<<<< 	r   c                 6    | j                   j                         S r   )r/   r   r   s    r   r   z6CoroutineTest.test_await_14.<locals>.Wrapper.__await__i  s    yy**,,r   Nr   r   r   r   Wrapperr  d  s    !-r   r  c                       e Zd Zd Zy)/CoroutineTest.test_await_14.<locals>.FutureLikec              3      K   d S wr   r   r   s    r   r   z9CoroutineTest.test_await_14.<locals>.FutureLike.__await__m  s     s   NrJ  r   r   r   
FutureLiker  l  s    r   r  c                       e Zd Zy)+CoroutineTest.test_await_14.<locals>.MarkerNrd  r   r   r   Markerr  p  re  r   r  c                  N   K   	           d {   S 7 # t         $ r w xY wwr   r   )r  r  s   r   coro1z*CoroutineTest.test_await_14.<locals>.coro1s  s-     '\)))$ s    %
  % "%c                  :   K                    d {   S 7 wr   r   )r  r  s   r   coro2z*CoroutineTest.test_await_14.<locals>.coro2x  s      ))))s   r   )r  r,   r   r-   rK   r   r   )r   r  r   r  r  r  r  s      @@@@r   test_await_14zCoroutineTest.test_await_14c  s    	- 	-	 		Y 		
	* G	t##M6: 	FF6N	 G	tv& 	'GG%&	' 	'	 	
	' 	's   "C%CCCc                     t         j                  d        fd}d } |       }|j                  d        | j                  t        d      5   ||      j                  d        d d d        y # 1 sw Y   y xY w)Nc               3      K   d  y wr   r   r   r   r   r   z(CoroutineTest.test_await_15.<locals>.nop  r   rn   c                  0   K             d {    y 7 wr   r   r   s   r   r   z.CoroutineTest.test_await_15.<locals>.coroutine  r   r   c                 $   K   |  d {    y 7 wr   r   r   s    r   waiterz+CoroutineTest.test_await_15.<locals>.waiter  s     JJr3  z"coroutine is being awaited already)r(   r   r,   r   r   )r   r   r  r/   r   s       @r   test_await_15zCoroutineTest.test_await_15  sr    		 
			 {		$##L$HJ 	$4Ld#	$ 	$ 	$s   A//A8c                 r    d fd}t         |             \  }}| j                  |j                         y )Nc                     K   t               S wr   )r   r   r   r   r   z&CoroutineTest.test_await_16.<locals>.f  s     <s   c                  H   K   	 t         #            d {  7  cY S xY wwr   )KeyError)r   s   r   r   z&CoroutineTest.test_await_16.<locals>.g  s#     !!Syy s   " ")r3   r  __context__)r   r   r   r1   r   s       @r   test_await_16zCoroutineTest.test_await_16  s2    	 	! acN	6&,,-r   c                      G d d      fd} |       }t        |      \  }}| j                  |g d       fd}| j                  t              5  t         |              d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zd Zd Zd Zy)*CoroutineTest.test_with_1.<locals>.Managerc                     || _         y r   )name)r   r  s     r   r   z3CoroutineTest.test_with_1.<locals>.Manager.__init__  s	     	r   c                 p   K   t        d| j                  z   d| j                  z   g       d {    | S 7 w)Nzenter-1-zenter-2-r	   r  r   s    r   
__aenter__z5CoroutineTest.test_with_1.<locals>.Manager.__aenter__  s>     $j499&<&0499&<&> ? ? ??s   +646c                    K   t        d| j                  z   d| j                  z   g       d {    | j                  dk(  ryy 7 w)Nzexit-1-zexit-2-BTr  )r   r.   s     r   	__aexit__z4CoroutineTest.test_with_1.<locals>.Manager.__aexit__  sO     $i$))&;&/$))&;&= > > > 99# $>s   +AAAN)r   r   r   r   r  r  r   r   r   Managerr    s    !
 r   r  c                  Z  K    d      4 d {   }  d      4 d {   }t        d| j                  |j                  fg       d {    ddz   d d d       d {    d d d       d {    y 7 f7 W7 .7 # 1 d {  7  sw Y   +xY w7 "# 1 d {  7  sw Y   y xY ww)NAr  managersr6   r   r  )r   r#  r  s     r   r^   z&CoroutineTest.test_with_1.<locals>.foo       s|  q'#,  !$z166166&B%CDDD!     D          B+A7B+BA9B'A?A;	A?B!A="B&B+1B2B+9B;A?=B?B	BB	BB+B(BB($B+)	z	enter-1-Az	enter-2-Az	enter-1-Bz	enter-2-B)r  r  r  zexit-1-Bzexit-2-Bzexit-1-Azexit-2-Ac                  Z  K    d      4 d {   }  d      4 d {   }t        d| j                  |j                  fg       d {    ddz   d d d       d {    d d d       d {    y 7 f7 W7 .7 # 1 d {  7  sw Y   +xY w7 "# 1 d {  7  sw Y   y xY ww)Nr  Cr  r6   r   r  )r   r   r  s     r   r^   z&CoroutineTest.test_with_1.<locals>.foo  r  r  )r3   rb   rK   r   )r   r^   r   r1   r   r  s        @r   test_with_1zCoroutineTest.test_with_1  st    	  	 "	
 EaL	 E	
	
 01 	ce	 	 	s   A..A7c                      G d d      d fd}| j                  t        d      5  t         |              d d d        | j                  d       y # 1 sw Y   xY w)Nc                       e Zd Zd Zy)%CoroutineTest.test_with_2.<locals>.CMc                      y r   r   r   s    r   r  z0CoroutineTest.test_with_2.<locals>.CM.__aenter__      r   N)r   r   r   r  r   r   r   CMr        r   r  c                     K   d         4 d {    dd d d       d {    y 7 7 # 1 d {  7  sw Y   y xY wwNFTr   r  body_executeds   r   r^   z&CoroutineTest.test_with_2.<locals>.foo  E     !Mt % % $% % % % % % %6   A)A-A+AA?6?Az'asynchronous context manager.*__aexit__Fr   r   r3   r   r   r^   r  r  s     @@r   test_with_2zCoroutineTest.test_with_2  sY    	 	 	% ##I/XY 	ce	mU+	 	   AA c                      G d d      d fd}| j                  t        d      5  t         |              d d d        | j                  d       y # 1 sw Y   xY w)Nc                       e Zd Zd Zy)%CoroutineTest.test_with_3.<locals>.CMc                      y r   r   r   s    r   r  z/CoroutineTest.test_with_3.<locals>.CM.__aexit__  r  r   N)r   r   r   r  r   r   r   r  r    r  r   r  c                     K   d         4 d {    dd d d       d {    y 7 7 # 1 d {  7  sw Y   y xY wwr  r   r  s   r   r^   z&CoroutineTest.test_with_3.<locals>.foo  r  r  asynchronous context managerFr  r  s     @@r   test_with_3zCoroutineTest.test_with_3  sY    	 	 	% ##I/MN 	ce	mU+	 	r  c                      G d d      d fd}| j                  t        d      5  t         |              d d d        | j                  d       y # 1 sw Y   xY w)Nc                       e Zd Zy)%CoroutineTest.test_with_4.<locals>.CMNrd  r   r   r   r  r    re  r   r  c                     K   d         4 d {    dd d d       d {    y 7 7 # 1 d {  7  sw Y   y xY wwr  r   r  s   r   r^   z&CoroutineTest.test_with_4.<locals>.foo  r  r  r  Fr  r  s     @@r   test_with_4zCoroutineTest.test_with_4  sY    	 	 	% ##I/MN 	ce	mU+	 	r  c                       G d d       fd} j                  t              5  t         |              d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zd Zd Zy)%CoroutineTest.test_with_5.<locals>.CMc                    K   | S wr   r   r   s    r   r  z0CoroutineTest.test_with_5.<locals>.CM.__aenter__          c                    K   y wr   r   )r   excs     r   r  z/CoroutineTest.test_with_5.<locals>.CM.__aexit__  	     rw   Nr   r   r   r  r  r   r   r   r  r    s    r   r  c                     K            4 d {    j                  dd       d d d       d {    y 7 '7 # 1 d {  7  sw Y   y xY ww)Nr   r6   )rb   )r  r   s   r   r   z'CoroutineTest.test_with_5.<locals>.func	  sK     t + +  *+ + + + + + +s<   A7A;A9AAAAA	A)rK   AssertionErrorr3   )r   r   r  s   ` @r   test_with_5zCoroutineTest.test_with_5  sA    
	 		+ ~. 	df	 	 	s   AAc                      G d d      fd}| j                  t        d      5  t         |              d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zd Zd Zy)%CoroutineTest.test_with_6.<locals>.CMc                      y)N{   r   r   s    r   r  z0CoroutineTest.test_with_6.<locals>.CM.__aenter__      r   c                      yNi  r   r   es     r   r  z/CoroutineTest.test_with_6.<locals>.CM.__aexit__  r  r   Nr  r   r   r   r  r    s    r   r  c                     K            4 d {    	 d d d       d {    y 7 7 # 1 d {  7  sw Y   y xY wwr   r   r  s   r   r^   z&CoroutineTest.test_with_6.<locals>.foo  s>     t        s0   ?&?*?(??<3<?zV'async with' received an object from __aenter__ that does not implement __await__: intr4  )r   r^   r  s     @r   test_with_6zCoroutineTest.test_with_6  sK    	 		 ##9: 	
 ce	 	 	rR  c                 ^    G d d      fd}	 t         |              | j                  d       y # t        $ ro}| j                  |j                  d   d       | j                  |j                  d u       | j                  t        |j                  t                     Y d }~y d }~ww xY w)Nc                       e Zd Zd Zd Zy)%CoroutineTest.test_with_7.<locals>.CMc                    K   | S wr   r   r   s    r   r  z0CoroutineTest.test_with_7.<locals>.CM.__aenter__%  r  r  c                      y)Ni  r   r  s     r   r  z/CoroutineTest.test_with_7.<locals>.CM.__aexit__(  r  r   Nr  r   r   r   r  r  $      r   r  c                     K            4 d {    ddz   d d d       d {    y 7 7 # 1 d {  7  sw Y   y xY wwNr6   r   r   r  s   r   r^   z&CoroutineTest.test_with_7.<locals>.foo,  sB     t  !      8   A*A.A,AAA 7A Az1invalid asynchronous context manager did not failr   U'async with' received an object from __aexit__ that does not implement __await__: int)	r3   failr   r   r.   rc   r  
isinstancer   )r   r^   r  r  s      @r   test_with_7zCoroutineTest.test_with_7#  s    	 		
	Kce IIIJ  	L9: OOCOO478OOJs8IJKK	Ls   4 	B,A%B''B,c                    d G d d      fd}| j                  t        d      5  t         |              d d d        | j                  d       fd}| j                  t        d      5  t         |              d d d        | j                  d       fd	}| j                  t        d      5  t         |              d d d        | j                  d
       fd}| j                  t        d      5  t         |              d d d        | j                  d       y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   {xY w# 1 sw Y   @xY w)Nr   c                       e Zd Zd Zd Zy)%CoroutineTest.test_with_8.<locals>.CMc                    K   | S wr   r   r   s    r   r  z0CoroutineTest.test_with_8.<locals>.CM.__aenter__A  r  r  c                      yr  r   r  s     r   r  z/CoroutineTest.test_with_8.<locals>.CM.__aexit__D  r  r   Nr  r   r   r   r  r  @  r  r   r  c                     K            4 d {    dz  d d d       d {    y 7 7 # 1 d {  7  sw Y   y xY wwr   r   r  CNTs   r   r^   z&CoroutineTest.test_with_8.<locals>.fooH  D     t  q      r	  r
  r6   c                     K   t        d      D ])  }         4 d {    dz  	 d d d       d {     y  y 7 7 
# 1 d {  7  sw Y   CxY wwNr5   r6   r_   r9   r  r  s    r   r^   z&CoroutineTest.test_with_8.<locals>.fooT  s_     1X 4  1HC      s>   A<AA A>	AA A	A	A	Ar5   c                     K   t        d      D ](  }         4 d {    dz  	 d d d       d {    * y 7 7 	# 1 d {  7  sw Y   BxY wwr  r  r  s    r   r^   z&CoroutineTest.test_with_8.<locals>.foob  s_     1X 4  1HC      s<   A;A?A=AAA	AA	Ar  c                     K            4 d {    dz  	 d d d       d {    y 7 7 # 1 d {  7  sw Y   y xY wwr   r   r  s   r   r^   z&CoroutineTest.test_with_8.<locals>.foop  sG     t  q      s8   A+A/A-AAA8AA   )r   r   r3   rb   r   r^   r  r  s     @@r   test_with_8zCoroutineTest.test_with_8=  sS   	 		 ##9: 	 ce		
 	a 	 ##9: 	 ce		
 	a 	 ##9: 	 ce		
 	a 	
 ##9: 	 ce		
 	a ]	 		 		 		 	s/   D,2D89E E,D58EEEc                     d G d d      fd}| j                  t              5  t         |              d d d        | j                  d       y # 1 sw Y   xY w)Nr   c                       e Zd Zd Zd Zy)%CoroutineTest.test_with_9.<locals>.CMc                    K   | S wr   r   r   s    r   r  z0CoroutineTest.test_with_9.<locals>.CM.__aenter__  r  r  c                    K   ddz   y wr  r   r  s     r   r  z/CoroutineTest.test_with_9.<locals>.CM.__aexit__       !r   Nr  r   r   r   r  r"        r   r  c                     K            4 d {    dz  d d d       d {    y 7 7 # 1 d {  7  sw Y   y xY wwr   r   r  s   r   r^   z&CoroutineTest.test_with_9.<locals>.foo  r  r	  r6   rK   r   r3   rb   r  s     @@r   test_with_9zCoroutineTest.test_with_9}  sY    	 		
 01 	ce	 	a 	 	   AAc                    d G d d      fd}	 t         |              | j                  d       y # t        $ r}| j                  |j                  d u       | j                  t        |j                  t                     | j                  t        |j                  j                  t                     Y d }~y d }~ww xY w)Nr   c                       e Zd Zd Zd Zy)&CoroutineTest.test_with_10.<locals>.CMc                    K   | S wr   r   r   s    r   r  z1CoroutineTest.test_with_10.<locals>.CM.__aenter__  r  r  c                    K   ddz   y wr  r   r  s     r   r  z0CoroutineTest.test_with_10.<locals>.CM.__aexit__  r%  r   Nr  r   r   r   r  r-    r&  r   r  c                     K            4 d {             4 d {    t         7 7 # 1 d {  7  sw Y   nxY wd d d       d {  7   y # 1 d {  7  sw Y   y xY wwr   r   r  s   r   r^   z'CoroutineTest.test_with_10.<locals>.foo  s`     t ' '4 ' '&&'' ' ' '' ' ' ' 'sg   A**A*A,A.A*AA 	7A 	AA*AA*A'AA'#A*z*exception from __aexit__ did not propagate)r3   r  r   rc   r  r  r   r   r^   r  r  r  s      @@r   test_with_10zCoroutineTest.test_with_10  s    	 		'	Dce IIBC ! 	6OOCOO478OOJs8IJKOOJs'B'B'35 6 6	6s   8 	CA9B??Cc                     d G d d      fd}	 t         |              | j                  d       y # t        $ r'}| j                  |j                  d u        Y d }~y d }~ww xY w)Nr   c                       e Zd Zd Zd Zy)&CoroutineTest.test_with_11.<locals>.CMc                    K   t         wr   )NotImplementedErrorr   s    r   r  z1CoroutineTest.test_with_11.<locals>.CM.__aenter__  s     ))r   c                    K   ddz   y wr  r   r  s     r   r  z0CoroutineTest.test_with_11.<locals>.CM.__aexit__  r%  r   Nr  r   r   r   r  r6    s    *r   r  c                  f   K            4 d {    t         7 
# 1 d {  7  sw Y   y xY wwr   r1  r  s   r   r^   z'CoroutineTest.test_with_11.<locals>.foo  s1     t # #""# # # #s$   111.%.1z+exception from __aenter__ did not propagate)r3   r  r8  rc   r  r2  s      @@r   test_with_11zCoroutineTest.test_with_11  s`    	 		#
	Ece IICD # 	5OOCOOt344	5s   8 	A(A##A(c                 P     d G d d       fd}t         |              y )Nr   c                       e Zd Zd Zd Zy)&CoroutineTest.test_with_12.<locals>.CMc                    K   | S wr   r   r   s    r   r  z1CoroutineTest.test_with_12.<locals>.CM.__aenter__  r  r  c                    K   ywNTr   r  s     r   r  z0CoroutineTest.test_with_12.<locals>.CM.__aexit__  	     rw   Nr  r   r   r   r  r>    s    r   r  c                     K           4 d {   } j                  | j                         t        7 &# 1 d {  7  sw Y   y xY wwr   )r   r'   r   )cmr  r  r   s    r   r^   z'CoroutineTest.test_with_12.<locals>.foo  sE     t # #rbllB/""# # # #s,   A6A#8AA
AA
A)r3   r  s   ` @@r   test_with_12zCoroutineTest.test_with_12  s#    	 		# 	#%r   c                     d G d d      fd}| j                  t              5  t         |              d d d        | j                  d       y # 1 sw Y   xY w)Nr   c                       e Zd Zd Zd Zy)&CoroutineTest.test_with_13.<locals>.CMc                    K   ddz   y wr  r   r   s    r   r  z1CoroutineTest.test_with_13.<locals>.CM.__aenter__  r%  r   c                    K   ywrA  r   r  s     r   r  z0CoroutineTest.test_with_13.<locals>.CM.__aexit__  rB  rw   Nr  r   r   r   r  rH    s    r   r  c                     K   dz           4 d {    dz  d d d       d {    dz  y 7 7 # 1 d {  7  sw Y   xY ww)Nr6   rr  '  r   r  s   r   r^   z'CoroutineTest.test_with_13.<locals>.foo  sV     1HCt  t 5LC    s:   A4A8A6AAA
AA
Ar6   r(  r  s     @@r   test_with_13zCoroutineTest.test_with_13  sW    	 		 01 	ce	a 	 	r*  c                 V  	 d G fdd      g 		fd}t         |             \  }}| j                  d       | j                  |t        dd      D cg c]  }|dz  	 c}       | j                  	t        dd      D cg c]  }|d	z  	 c}       g 		fd
}t         |             \  }}| j                  d	       | j                  |ddg       | j                  	t        dd      D cg c]  }| c}dgz          g 		fd}t         |             \  }}| j                  d       | j                  |t        dd      D cg c]  }|dz  	 c}       | j                  	t        dd      D cg c]  }| c}ddgz          y c c}w c c}w c c}w c c}w c c}w )Nr   c                   $    e Zd Zd Z fdZd Zy)+CoroutineTest.test_for_1.<locals>.AsyncIterc                     d| _         y r&   r[   r   s    r   r   z4CoroutineTest.test_for_1.<locals>.AsyncIter.__init__  	    r   c                     dz  | S r   r   )r   aiter_callss    r   	__aiter__z5CoroutineTest.test_for_1.<locals>.AsyncIter.__aiter__  s    q r   c                    K   | xj                   dz  c_         | j                   dz  s t        | j                   dz         d {    | j                   dkD  rt        | j                   | j                   fS 7 1w)Nr6   ru   r   )r9   r   StopAsyncIterationr   s    r   	__anext__z5CoroutineTest.test_for_1.<locals>.AsyncIter.__anext__  s\     !$TVVb[11166C<,,vvtvv~% 2s   A A6A42A6Nr   r   r   r   rU  rX  )rT  s   r   	AsyncIterrP    s    
	&r   rZ  c                  d   K           2 3 d {   \  } }j                  | |z          !7 6 y wr   r+   )i1i2rZ  r0   s     r   test1z'CoroutineTest.test_for_1.<locals>.test1  s4      ) ' 'fb"b2g&'s   0.,.0.0r6      r   e   r5   c                     K           2 3 d {   } j                  | d          | d   dk(  s& j                  d       y 7 46 j                  d       'wNr      what?endr\  r9   rZ  r0   s    r   test2z'CoroutineTest.test_for_1.<locals>.test2  sZ     $; ' 'aad#Q42: MM% ';
 g&s*   AAAAAAAA      rf  c                     K           2 3 d {   } | d   dkD  rj                  | d          '7 "6 j                  d       j                  d       y wrc  r\  rg  s    r   test3z'CoroutineTest.test_for_1.<locals>.test3  sX     $; ' 'aQ4"9ad#';
 g&MM% s   A424A4$Ar  re  )r3   rb   r_   )
r   r_  yieldedr   r9   rh  rl  rZ  rT  r0   s
          @@@r   
test_for_1zCoroutineTest.test_for_1  s   	& 	&* 	' uw'
a(E!RL"Aq1s7"ABuQ}!=!!A#!=> 	! uw'
a(3*-U1b\!:!!:eW!DE 	! uw'
a(E!RL"Aq1s7"ABU1b\!:!!:")5!1"2 	3K #B!=$ ";" #B!:s   F
F
4	F
F!
<	F&
c                     dt        j                        }fd}| j                  t        d      5  t	         |              d d d        | j                  t        j                        |       y # 1 sw Y   /xY w)Nr<  c                  B   K   2 3 d {   } t        d       7 6 y wNznever going to happenprint)r9   tups    r   r^   z%CoroutineTest.test_for_2.<locals>.foo4  s'      / /a-./3   z/async for' requires an object.*__aiter__.*tuplesysgetrefcountr   r   r3   rb   )r   refs_beforer^   rt  s      @r   
test_for_2zCoroutineTest.test_for_20  sn    ooc*	/ ##LN 	 ce	
 	-{;	 	s   A33A<c                     G d d      } |       t        j                        }fd}| j                  t        d      5  t	         |              d d d        | j                  t        j                        |       y # 1 sw Y   /xY w)Nc                       e Zd Zd Zy)#CoroutineTest.test_for_3.<locals>.Ic                     | S r   r   r   s    r   rU  z-CoroutineTest.test_for_3.<locals>.I.__aiter__A  r  r   Nr   r   r   rU  r   r   r   Ir}  @  r  r   r  c                  B   K   2 3 d {   } t        d       7 6 y wrq  rr  r9   aiters    r   r^   z%CoroutineTest.test_for_3.<locals>.fooG  '       / /a-./5ru  z!that does not implement __anext__rv  r   r  ry  r^   r  s       @r   
test_for_3zCoroutineTest.test_for_3?  s{    	 	 ooe,	/ ##46 	 ce		 	/=	 	   BBc                     G d d      } |       t        j                        }fd}| j                  t        d      5  t	         |              d d d        | j                  t        j                        |       y # 1 sw Y   /xY w)Nc                       e Zd Zd Zd Zy)#CoroutineTest.test_for_4.<locals>.Ic                     | S r   r   r   s    r   rU  z-CoroutineTest.test_for_4.<locals>.I.__aiter__U  r  r   c                      y)Nr   r   r   s    r   rX  z-CoroutineTest.test_for_4.<locals>.I.__anext__X  s    r   N)r   r   r   rU  rX  r   r   r   r  r  T  s    r   r  c                  B   K   2 3 d {   } t        d       7 6 y wrq  rr  r  s    r   r^   z%CoroutineTest.test_for_4.<locals>.foo^  r  ru  z7async for' received an invalid object.*__anext__.*tuplerv  r  s       @r   
test_for_4zCoroutineTest.test_for_4S  s|    	 	 ooe,	/ ##IK 	 ce		 	/=	 	r  c                    d G fdd       G d d                      t        j                        }t        j                        }fd}t        j                         5  t        j                  d       t         |              d d d        | j                  d       | j                  t        j                        |       | j                  t        j                        |       fd	}t         |              | j                  d
       fd}t         |              | j                  d       y # 1 sw Y   xY w)Nr   c                   "    e Zd Z fdZ fdZy))CoroutineTest.test_for_6.<locals>.Managerc                    K   dz  y w)NrL  r   )r   r  s    r   r  z4CoroutineTest.test_for_6.<locals>.Manager.__aenter__n  s     U
   
c                    K   dz  y w)Ni r   )r   r.   r  s     r   r  z3CoroutineTest.test_for_6.<locals>.Manager.__aexit__r  s     Vr  Nr  )r  s   r   r  r  m  s    r   r  c                       e Zd Zd Zd Zd Zy)*CoroutineTest.test_for_6.<locals>.Iterablec                     d| _         y r&   r[   r   s    r   r   z3CoroutineTest.test_for_6.<locals>.Iterable.__init__w  rR  r   c                     | S r   r   r   s    r   rU  z4CoroutineTest.test_for_6.<locals>.Iterable.__aiter__z  r  r   c                 v   K   | j                   dkD  rt        | xj                   dz  c_         | j                   S wNru   r6   )r9   rW  r   s    r   rX  z4CoroutineTest.test_for_6.<locals>.Iterable.__anext__}  s-     66B;,,!vvs   79NrY  r   r   r   Iterabler  v  s    r   r  c                     K   4 d {    2 3 d {   } dz  7 7 6 d d d       d {  7   n# 1 d {  7  sw Y   nxY wdz  y wNr6   rr  r   )r9   r  r!   managers    r   mainz&CoroutineTest.test_for_6.<locals>.main  sa        '  !FAx     IAsR   A A7$"$7A$7A3AA	A A	Aerrori c                  f  K           4 d {            2 3 d {   } dz  7 7 6 d d d       d {  7   n# 1 d {  7  sw Y   nxY wdz          4 d {  7           2 3 d {  7  } dz  6 d d d       d {  7   n# 1 d {  7  sw Y   nxY wdz  y wr  r   r9   r  r  r  s    r   r  z&CoroutineTest.test_for_6.<locals>.main  s      y  'z  !FAz     IAy  'z  !FA  *     IAs   B1*B1A.,.AB1.AB1=B1AA
AB1&A)'B1+B3B7A:8B<BB1BB1B(BB($B1i c                    K           4 d {    dz          2 3 d {   } dz  7 7 6 dz  d d d       d {  7   n# 1 d {  7  sw Y   nxY wdz          4 d {  7   dz          2 3 d {  7  } dz  6 dz  d d d       d {  7   n# 1 d {  7  sw Y   nxY wdz  y w)Nr   r6   i rr  r   r  s    r   r  z&CoroutineTest.test_for_6.<locals>.main  s      y " "S'z " "!FA""z MA" " " " " IAy " "S'z " "!FA  * MA" " " " " IAs   C/CA313AC3ACACAAAC0A31C5B*BB	BB*C#B&$C*B<0B31B<8Ci9)rw  rx  r=   r>   r?   r3   rb   )	r   mrefs_beforeirefs_beforer  r  r  r  r!   r  s	       @@@@@r   
test_for_6zCoroutineTest.test_for_6j  s   	 		 	 ):w/x0	 $$& 	!!'* df		
 	F#1<@2LA	 	$&F#	& 	$&H%e	 	s   1&EEc                     d G d d      fd}| j                  t              5  t         |              d d d        | j                  d       y # 1 sw Y   xY w)Nr   c                       e Zd Zd Zy)$CoroutineTest.test_for_7.<locals>.AIc                     ddz   y r  r   r   s    r   rU  z.CoroutineTest.test_for_7.<locals>.AI.__aiter__  	    !r   Nr  r   r   r   AIr        r   r  c                  J   K           2 3 d {   } dz  7 
6 dz  y wNr6   ru   r   r9   r  r  s    r   r^   z%CoroutineTest.test_for_7.<locals>.foo  2     4  aq42IC   ###r(  r   r^   r  r  s     @@r   
test_for_7zCoroutineTest.test_for_7  sW    	 		
 01 	ce	a 	 	r*  c                 @   d G d d      fd}| j                  t              5  t        j                         5  t        j                  d       t         |              d d d        d d d        | j                  d       y # 1 sw Y   $xY w# 1 sw Y   (xY w)Nr   c                       e Zd Zd Zy)$CoroutineTest.test_for_8.<locals>.AIc                     ddz   y r  r   r   s    r   rU  z.CoroutineTest.test_for_8.<locals>.AI.__aiter__  r  r   Nr  r   r   r   r  r    r  r   r  c                  J   K           2 3 d {   } dz  7 
6 dz  y wr  r   r  s    r   r^   z%CoroutineTest.test_for_8.<locals>.foo  r  r  r  )rK   r   r=   r>   r?   r3   rb   r  s     @@r   
test_for_8zCoroutineTest.test_for_8  s    	 		
 01 	!((* !%%g. #% 	!	! 	a ! !	! 	!s"   B&B%BB	BBc                      G d d      fd}| j                  t        d      5 } |       j                  d        d d d        j                  }| j	                  |j
                  t               y # 1 sw Y   6xY w)Nc                       e Zd Zd Zd Zd Zy)$CoroutineTest.test_for_11.<locals>.Fc                     | S r   r   r   s    r   rU  z.CoroutineTest.test_for_11.<locals>.F.__aiter__  r  r   c                     | S r   r   r   s    r   rX  z.CoroutineTest.test_for_11.<locals>.F.__anext__  r  r   c                     ddz   y r  r   r   s    r   r   z.CoroutineTest.test_for_11.<locals>.F.__await__  s	    Ar   N)r   r   r   rU  rX  r   r   r   r   Fr    s    r   r  c                  6   K           2 3 d {   } 
7 6 y wr   r   )r   r  s    r   r  z'CoroutineTest.test_for_11.<locals>.main  s#     3  a3s   z an invalid object from __anext__)r   r   r,   	exceptionrz   	__cause__r   )r   r  r   errr  s       @r   test_for_11zCoroutineTest.test_for_11  sn    	 		 ##I$FH 	KLFKK	 kkcmm->?	 	s   A33A<c                      G d dt                G d dt              g fd}| j                        5   |       j                  d        d d d        | j	                  dg       y # 1 sw Y   xY w)Nc                       e Zd Zy)*CoroutineTest.test_for_tuple.<locals>.DoneNrd  r   r   r   Doner        r   r  c                       e Zd ZdZd Zd Zy)+CoroutineTest.test_for_tuple.<locals>.AIterr   c                     | S r   r   r   s    r   rU  z5CoroutineTest.test_for_tuple.<locals>.AIter.__aiter__  r  r   c                    K   | j                   t        |       k\  rt        | xj                   dz  c_         | | j                   dz
     S wr   )r9   lenrW  r   s    r   rX  z5CoroutineTest.test_for_tuple.<locals>.AIter.__anext__  s<     66SY&,,!DFFQJ''s   AANr   r   r   r9   rU  rX  r   r   r   AIterr    s    A(r   r  c                  ^   K    dg      2 3 d {   } j                  |        7 6 wr@  r\  r9   r  r  r1   s    r   r^   z)CoroutineTest.test_for_tuple.<locals>.foo  s5      "; ! !aa !;Js   
-*(*-*-rA  )r  r   rK   r,   rb   r   r^   r  r  r1   s     @@@r   test_for_tuplezCoroutineTest.test_for_tuple  sh    #9#	(E 	( 	
 t$ 	EJJt	"&	 	   A//A8c                      G d dt                G d dt              g fd}| j                        5   |       j                  d        d d d        | j	                  dg       y # 1 sw Y   xY w)Nc                       e Zd Zy)3CoroutineTest.test_for_stop_iteration.<locals>.DoneNrd  r   r   r   r  r    r  r   r  c                       e Zd ZdZd Zd Zy)4CoroutineTest.test_for_stop_iteration.<locals>.AIterr   c                     | S r   r   r   s    r   rU  z>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__aiter__  r  r   c                 p   K   | j                   rt        | xj                   dz  c_         | j                  S wr   )r9   rW  r   r   s    r   rX  z>CoroutineTest.test_for_stop_iteration.<locals>.AIter.__anext__  s*     66,,!zz!s   46Nr  r   r   r   r  r    s    A"r   r  c                  \   K    d      2 3 d {   } j                  |        7 6 wr@  r\  r  s    r   r^   z2CoroutineTest.test_for_stop_iteration.<locals>.foo  s3      9 ! !aa !9Js   	,)'),),rA  )r  r-   rK   r,   rb   r  s     @@@r   test_for_stop_iterationz%CoroutineTest.test_for_stop_iteration  sh    #9#	"M 	" 	
 t$ 	EJJt	"&	 	r  c                 X   d fd}fd}fd}fd}| j                  t         |             g ddgf       | j                  t         |             g ddhf       | j                  t         |             g ddd	f       | j                  t         |             g ddd
f       y )Nc                    K   | S wr   r   r[   s    r   r   z$CoroutineTest.test_comp_1.<locals>.f)       Hr  c                  f   K    d       d      fD  cg c]  } |  d {    c} S 7 	c c} w wNr6   )   r   r   r   s    r   run_listz+CoroutineTest.test_comp_1.<locals>.run_list,  -     &'dAbE]3!GG33G3   1
,*
,1,1c                  f   K    d       d      fD  ch c]  } |  d {    c} S 7 	c c} w wr  r   r  s    r   run_setz*CoroutineTest.test_comp_1.<locals>.run_set/  r  r  c                  h   K    d       d      fD  ci c]  } |  d {   d c} S 7 
c c} w w)Nr6   r  r   r   r  s    r   	run_dict1z,CoroutineTest.test_comp_1.<locals>.run_dict12  s/     +,Q42-8Q!GSL88G8s   2
-+
-2-2c                     K   t         d       d      g      D  ci c]  \  } }| | d {    c}} S 7 
c c}} w wr  )	enumerate)r9   r   r   s     r   	run_dict2z,CoroutineTest.test_comp_1.<locals>.run_dict25  s8     +4adAbE]+CD41aAQwJDDwDs   A;9;A;Ar6   r  r   )r6   r  )r   r6   rD  )r   r  r  r  r  r   s        @r   test_comp_1zCoroutineTest.test_comp_1(  s    		4	4	9	E 	8:.aW>79-QG}=9;/"#36G1HI9;/"!m1DEr   c                    d fd}| j                  t         |             g g df       fd}| j                  t         |             g h df       fd}| j                  t         |             g ddhf       y )	Nc                    K   | S wr   r   r[   s    r   r   z$CoroutineTest.test_comp_2.<locals>.f>  r  r  c                     K    d       d       d       ddg      fD  cg c]  } |  d {   D ]  }|  c}} S 7 c c}} w w)N abcdefgr   r   sr   s     r   r  z+CoroutineTest.test_comp_2.<locals>.run_listA  sZ      !"qx24,H &!#$W&  &A & &$&s%   $A
AAAAAA)r   r#  r   r  r  c            	         K     ddg       dg      g      fD  ch c]"  } |  d {   D ]  }| d {   D ]  }|  $ c}}} S 7 !7 c c}}} w w)Nru      rd  r   )r   r  dr   s      r   r  z*CoroutineTest.test_comp_2.<locals>.run_setI  s     B8!"B4!* + ,& &#$W& #$W	& 	  &A &A & & %$	&s6   A
AAAAA	AAAA>   ru   rd  r  c                     K     d       d      g      fD  ch c]  } |  d {   D ]  }| d {     c}} S 7 7 c c}} w w)Nru   rd  r   r  s     r   run_set2z+CoroutineTest.test_comp_2.<locals>.run_set2T  s\     2"/0&#$W& GG &G & &$  &s5   A
AAAAAAAAAru   rd  rD  )r   r  r  r   r   s       @r   test_comp_2zCoroutineTest.test_comp_2=  s    		& 	hj!,-	/	& 	gi 	 	&
 	hj!"bN	r   c                 V   d fd}| j                  t         |             g ddgf       fd}| j                  t         |             g ddhf       fd}| j                  t         |             g ddd	f       fd
}| j                  t         |             g ddgf       y )Nc                $   K   | D ]  }| 	 y wr   r   r	  r9   s     r   r   z$CoroutineTest.test_comp_3.<locals>.f^        r$   c                  \   K    ddg      2  cg c3 d {   } | dz   7 
6 c} S c c} w wNru   rd  r6   r   r9   r   s    r   r  z+CoroutineTest.test_comp_3.<locals>.run_listb  .     )*B855AAE5555$   ,'#!
#'#',r`  rj  c                  \   K    ddg      2  ch c3 d {   } | dz   7 
6 c} S c c} w wr  r   r  s    r   r  z*CoroutineTest.test_comp_3.<locals>.run_seth  r	  r
  c                  d   K    ddg      2  ci c3 d {   } | dz   | dz   7 6 c} S c c} w wNru   rd  r6   r5   r   r  s    r   run_dictz+CoroutineTest.test_comp_3.<locals>.run_dictn  s6     012r(<<1AE1q5L<<<<s$   0+'%
'+'+0      )r`  rj  c                  n   K   d  ddg      2        } | 2 cg c3 d {   }|dz   7 
6 c}S c c}w w)Nc                8   K   | 3 d {   }|dz    7 6 y wr   r   .0r9   s     r   	<genexpr>z=CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<genexpr>u  s     4411q544   
ru   rd  r   r   rm   r   r   s     r   run_genz*CoroutineTest.test_comp_3.<locals>.run_gent  s8     42r(4C+.//aAG////$   50,*
,0,05o   y   rD  r   r  r  r  r  r   s        @r   test_comp_3zCoroutineTest.test_comp_3]  s    		6hj!"bN		6gi "bN		=hj!bb!"	$	0 	gi #s	r   c                 N   d fd}| j                  t         |             g dgf       fd}| j                  t         |             g dhf       fd}| j                  t         |             g ddif       fd}| j                  t         |             g dgf       y )	Nc                $   K   | D ]  }| 	 y wr   r   r  s     r   r   z$CoroutineTest.test_comp_4.<locals>.f|  r  r$   c                  h   K    ddg      2  cg c3 d {   } | dkD  s| dz   7 6 c} S c c} w wr  r   r  s    r   r  z+CoroutineTest.test_comp_4.<locals>.run_list  4     )*B8??ABAE????(   2-)'
)--)-2rj  c                  h   K    ddg      2  ch c3 d {   } | dkD  s| dz   7 6 c} S c c} w wr  r   r  s    r   r  z*CoroutineTest.test_comp_4.<locals>.run_set  r!  r"  c                  p   K    ddg      2  ci c3 d {   } | dkD  s| dz   | dz   7 6 c} S c c} w wr  r   r  s    r   r  z+CoroutineTest.test_comp_4.<locals>.run_dict  s<     012r(FF1q2vAE1q5LFFFFs(   61-+
-1
1-16r  c                  n   K   d  ddg      2        } | 2 cg c3 d {   }|dz   7 
6 c}S c c}w w)Nc                D   K   | 3 d {   }|dkD  s|dz    7 6 y wr  r   r  s     r   r  z=CoroutineTest.test_comp_4.<locals>.run_gen.<locals>.<genexpr>  s!     >>1q2v1q5>>s      	  ru   rd  r   r   r  s     r   r  z*CoroutineTest.test_comp_4.<locals>.run_gen  s8     >2r(>C+.//aAG////r  r  rD  r  s        @r   test_comp_4zCoroutineTest.test_comp_4{  s    		@hj!"J		@gi "J		Ghj!"bN		0 	gi #K	r   c                 X   d fd}| j                  t         |             g g df       fd}| j                  t         |             g h df       fd}| j                  t         |             g ddd	df       fd
}| j                  t         |             g g df       y )Nc                $   K   | D ]  }| 	 y wr   r   r  s     r   r   z&CoroutineTest.test_comp_4_2.<locals>.f  r  r$   c                     K    t        d            2  cg c3 d {   } d| cxk  rdk  sn n| dz   7 6 c} S c c} w wN   r   r  ru   r  r  s    r   r  z-CoroutineTest.test_comp_4_2.<locals>.run_list  8     *+E!H+CCQQAFCCCC*   A=97
9=	=9=A)r`  r     c                     K    t        d            2  ch c3 d {   } d| cxk  rdk  sn n| dz   7 6 c} S c c} w wr+  r  r  s    r   r  z,CoroutineTest.test_comp_4_2.<locals>.run_set  r-  r.  >   r`  r  r/  c                     K    t        d            2  ci c3 d {   } d| cxk  rdk  sn n	| dz   | dz   "7 6 c} S c c} w w)Nr,  r   r  ru   r   r  r  s    r   r  z-CoroutineTest.test_comp_4_2.<locals>.run_dict  s@     34U1X;LLa!a)!)AFAGOLLLLs.   AA=;
=AA=AAra  r   g   c                  |   K   d  t        d            2        } | 2 cg c3 d {   }|dz   7 
6 c}S c c}w w)Nc                V   K   | 3 d {   }d|cxk  rdk  sn n|dz    !7 6 y w)Nr   r  ru   r   r  s     r   r  z?CoroutineTest.test_comp_4_2.<locals>.run_gen.<locals>.<genexpr>  s%     BBAA		1r6BBs    )'%'))')r,  r   r  r  s     r   r  z,CoroutineTest.test_comp_4_2.<locals>.run_gen  s8     B58BC+.//aAG////s$   <731
3737<)r  p   q   rD  r  s        @r   test_comp_4_2zCoroutineTest.test_comp_4_2  s    		Dhj!	 	Dgi 	 	Mhj!cs,-	/	0 	gi !	#r   c                 \    d fd}| j                  t         |             g dgf       y )Nc                $   K   | D ]  }| 	 y wr   r   r  s     r   r   z$CoroutineTest.test_comp_5.<locals>.f  r  r$   c                     K   ddgddgfD  cg c]&  } | d   dkD  s |       2 3 d {   }|dkD  r|dz    c}} S 7 6 1c c}} w w)Nru   rd  r  (   r   r6   r   )pairr9   r   s     r   r  z+CoroutineTest.test_comp_5.<locals>.run_list  sh     (*Bx"b&: 6dd1gl#$T76 6a"f E 6 6 6 6E 6s8   AAAA 
>A 
AAA 
 AAr  rD  r   r  r   s     @r   test_comp_5zCoroutineTest.test_comp_5  s0    		6 	hj!"J	r   c                 ^    d fd}| j                  t         |             g g df       y )Nc                $   K   | D ]  }| 	 y wr   r   r  s     r   r   z$CoroutineTest.test_comp_6.<locals>.f  r  r$   c                  p   K    ddg      2  cg c3 d {   } | D ]  }|dz   	 7 6 c}} S c c}} w w)Nru   rd  )r  r6   r   )seqr9   r   s     r   r  z+CoroutineTest.test_comp_6.<locals>.run_list  sQ     +,h->+? " "C " E "E " " " "s$   60+)+0+0
6)r`  rj     rD  r=  s     @r   test_comp_6zCoroutineTest.test_comp_6  s/    		" 	hj!	 r   c                     d fd}| j                  t        d      5  t         |              d d d        y # 1 sw Y   y xY w)Nc                 4   K   d d t        d      w)Nr6   r5   aaa)r  r   r   r   r   z$CoroutineTest.test_comp_7.<locals>.f  s     GGE""s   c                  P   K           2  cg c3 d {   } | 7 6 c} S c c} w wr   r   r  s    r   r  z+CoroutineTest.test_comp_7.<locals>.run_list  s$     %&S))A))))s$   
&!
!!&rH  )r   r  r3   r=  s     @r   test_comp_7zCoroutineTest.test_comp_7  s>    	#
	* ##Iu5 	"hj!	" 	" 	"s	   :Ac                 R    d }| j                  t         |             g g df       y )Nc                  4   K   dD  cg c]  } |  c} S c c} w wr;  r   r[   s    r   r   z$CoroutineTest.test_comp_8.<locals>.f  s     ()!A)))s   	r<  rD  r   r   s     r   test_comp_8zCoroutineTest.test_comp_8  s'    	* 	acNO	r   c                 ^    d fd}| j                  t         |             g ddgf       y )Nc                     K   d d y wr   r   r   r   r   rm   z&CoroutineTest.test_comp_9.<locals>.gen  s     GGr  c                  z   K           2  cg c3 d {   } | 7 6 nc c} w }} |D  cg c]  } |  c} S c c} w wr   r   )r9   lrm   s     r   r   z$CoroutineTest.test_comp_9.<locals>.f  s7     "%%((Q(((A( >!A>!>s,   
;
;	6;r6   r5   rD  r   r   rm   s     @r   test_comp_9zCoroutineTest.test_comp_9  s1    		" 	acN!QL	r   c                 V    d }| j                  t         |             g ddddf       y )Nc                  ^   K   dD  ch c]  } |  }} |D ci c]  }|| c}S c c} w c c}w wr;  r   )r9   xxr"   s      r   r   z%CoroutineTest.test_comp_10.<locals>.f  s6     &'!'B'"$%QAqD%% (%s   -	#-
(-r6   r5   r  r<  rD  rM  s     r   test_comp_10zCoroutineTest.test_comp_10  s/    	& 	acNQ1#$	&r   c                    d }| j                  t         |             g ddgddggf       d }| j                  t         |             g ddhddhgf       d }| j                  t         |             g dd	hf       d
 }| j                  t         |             g dddddddf       d }| j                  t         |             g ddgddggf       d }| j                  t         |             g g df       d }| j                  t         |             g g df       d }| j                  t         |             g ddgddggddgddgggf       y )Nc            
         K   dD  cg c]!  } t        ddg      2 cg c3 d {   }|| z    c}} S 7 6 nc c}w c}5c c}} w wNrB  r6   r5   r#   jr9   s     r   run_list_inside_listz<CoroutineTest.test_nested_comp.<locals>.run_list_inside_list  <     FNO)QF*;<<QQUOO<<<O7   A?64246?A46
?Ar`  r  rj  r  c            
         K   dD  cg c]!  } t        ddg      2 ch c3 d {   }|| z    c}} S 7 6 nc c}w c}5c c}} w wr[  r\  r]  s     r   run_set_inside_listz;CoroutineTest.test_nested_comp.<locals>.run_set_inside_list   r`  ra  c                     K   dD  ch c]*  } t        t        t        |             2 cg c3 d {   }| c}} S 7 6 nc c}w c}      Bc c}} w w)Nr  r,  )r   r#   r_   r]  s     r   run_list_inside_setz;CoroutineTest.test_nested_comp.<locals>.run_list_inside_set  s=     IOPAC)E!H*=>>QPP>>>?Ps;   A A?=;=?AA=?AAr  ru   c                     K   dD  ci c]#  } | t        ddg      2 ci c3 d {   }||| z    c}} S 7 6 nc c}w c}7c c}} w wr[  r\  r]  s     r   run_dict_inside_dictz<CoroutineTest.test_nested_comp.<locals>.run_dict_inside_dict  sE     LTUqA	1a&0ABB11q5UUBBBBUs;   AA86468AA68
AA)r6   r5   rB  c                  V   K   d dD        } | 2 cg c3 d {   }|7 6 c}S c c}w w)Nc                v   K   | ]!  }t        d dg      2 cg c3 d{   }||z    y7 6 nc c}w c} 5w)r6   r5   Nr\  )r  r^  r9   s      r   r  zNCoroutineTest.test_nested_comp.<locals>.run_list_inside_gen.<locals>.<genexpr>  s5     NAq6):;;AAEN;;;;s(   9-+)+-9+-9rB  r   )rm   r"   s     r   run_list_inside_genz;CoroutineTest.test_nested_comp.<locals>.run_list_inside_gen  s+     NXNC%())A))))s$   )$ 
 $ $)c            	         K   dD  cg c]  } d t        t        |             2         }} |D cg c]  }|2 3 d {   }| c}}S c c} w 7 6 c c}}w w)Nre  c                2   K   | 3 d {   }| 7 
6 y wr   r   r  s     r   r  zNCoroutineTest.test_nested_comp.<locals>.run_gen_inside_list.<locals>.<genexpr>       ::Q::   r#   r_   )r^  gensr   r"   s       r   run_gen_inside_listz;CoroutineTest.test_nested_comp.<locals>.run_gen_inside_list  sU     DJKq:ia&9:KDK#5!155aA55 L55A5s@   A"AAAA
AA
A	AA
AA)r   r6   r5   r   r6   r5   r  r  c                  j   K   d dD        } | D cg c]  }|2 3 d {   }| c}}S 7 6 c c}}w w)Nc              3   R   K   | ]  }d  t        t        |            2         ! yw)c                2   K   | 3 d {   }| 7 
6 y wr   r   r  s     r   r  zWCoroutineTest.test_nested_comp.<locals>.run_gen_inside_gen.<locals>.<genexpr>.<genexpr>!  rn  ro  Nrp  )r  r^  s     r   r  zMCoroutineTest.test_nested_comp.<locals>.run_gen_inside_gen.<locals>.<genexpr>!  s"     Kq:ia&9::Ks   %'re  r   )rq  r   r"   s      r   run_gen_inside_genz:CoroutineTest.test_nested_comp.<locals>.run_gen_inside_gen   s7     KFKD#5!155aA5555A5s(   3-+
)+
-3+
-3c                     K   dD  cg c]4  } dD cg c]$  }t        ddg      2 cg c3 d {   }||z   | z    c}}6 c}}} S 7 6 nc c}w c}?c c}}w c c}}} w w)N)r   ri  rB  r6   r5   r\  )kr^  r9   s      r    run_list_inside_list_inside_listzHCoroutineTest.test_nested_comp.<locals>.run_list_inside_list_inside_list'  sk      () ) '( 09!Q/@AA!a!eai ( ) )AAA ( )sV   A!
AAAA	AA	
AAAA!A		A

AAA!r  r5  r  z               rD  )	r   r_  rc  rf  rh  rk  rr  rv  ry  s	            r   test_nested_compzCoroutineTest.test_nested_comp  s   	P*,-2r(RH%&	(	P)+,2r(RH%&	(	Q)+,!RM		V*,-"nbR.9:	<	* 	)+,2r(RH%&	(	6 	)+,)*	,	6 	(*+)*	,	) 	689C:Sz*c3Z#s,DEF	Hr   c                    d } |       }| j                  t              5  t        j                  |       d d d        |j                         }	 | j                  t              5  t        j                  |       d d d        |j	                          y # 1 sw Y   ^xY w# 1 sw Y   &xY w# |j	                          w xY w)Nc                     K   y wr   r   r   r   r   r   z%CoroutineTest.test_copy.<locals>.func0  r   rw   )rK   r   copyr   r   )r   r   r/   r8   s       r   	test_copyzCoroutineTest.test_copy/  s    vy) 	IIdO	 ^^	""9- 		" HHJ	 	
  HHJs/   BB+ $B:B+ BB($B+ +B=c                 J   d } |       }t        t        j                  dz         D ]F  }| j                  t        t        j
                  f      5  t        j                  ||       d d d        H |j                         }	 t        t        j                  dz         D ]F  }| j                  t        t        j
                  f      5  t        j                  ||       d d d        H 	 |j                          y # 1 sw Y   xY w# 1 sw Y   pxY w# |j                          w xY w)Nc                     K   y wr   r   r   r   r   r   z'CoroutineTest.test_pickle.<locals>.func=  r   rw   r6   )	r_   pickleHIGHEST_PROTOCOLrK   r   PicklingErrordumpsr   r   )r   r   r/   protor8   s        r   test_picklezCoroutineTest.test_pickle<  s    v622Q67 	*E""Iv/C/C#DE *T5)* *	* ^^	v66:; ,&&	63G3G'HI ,LLU+, ,, HHJ* *, , HHJs1   C8AD D
D 8D	D		D D"c                    d }t        j                         5  t        j                         5 }t        j                  d        |       }t        |      }d }t        j                          | j                  dt        |j                  j                               | j                  t        |j                  j                        |       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nc                     K   y wr   r   r   r   r   r   z3CoroutineTest.test_fatal_coro_warning.<locals>.funcM  r   rw   r  zwas never awaited)r=   r>   r   catch_unraisable_exceptionfilterwarningsr   r@   r   str
unraisable	exc_valuerb   object)r   r   rD  r/   	coro_reprs        r   test_fatal_coro_warningz%CoroutineTest.test_fatal_coro_warningK  s    $$& 
	D//1
	D57##G,6DT
ID MM-s2==3J3J/KLT"--"6"67C
	D 
	D 
	D 
	D 
	D 
	Ds#   C&BC	C&C#	C&&C/c                 (     G d d      } |       d  fd} j                  t         |             g df        fd} j                  t         |             g df        fd} j                  t         |             g df       y )Nc                       e Zd Zd Zy)MCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.BadTargetc                     t        d      r@  rW  )r   keyr   s      r   __setitem__zYCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.BadTarget.__setitem__\      (,,r   N)r   r   r   r  r   r   r   	BadTargetr  [      -r   r  c                    K   d y wrt   r   r   r   r   sourcezJCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.source_  s     Hr   c                     K   j                  t              5 }         2 3 d {   d<   7 6 	 d d d        n# 1 sw Y   nxY wj                   j                  j                  d       ywNr   rA  rf  rK   rW  rb   r  r.   rD  r   r  tgts    r   run_forzKCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_forb  sl     ""#56 "$*H  #a&H   R\\..61   A.;0.0;0;	A.A .A.rf  c                     K   j                  t              5 }         2 g c3 d {   d<   d7 
6 cd d d        S # 1 sw Y   nxY wj                   j                  j                  d       ywr  r  r  s    r   r  zLCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_listj  sd     ""#56 8".4h77CF778 8 8R\\..6s1   A2
?42
4?4?
A2A.A2c                  p  K   fd        2        } | j                  d       }j                  t              5 }| d {    d d d        j                  j                  j
                  t               j                  |j                  j
                  j                  d       y7 g# 1 sw Y   fxY ww)Nc                :   K   | 3 d {   d<   d 7 6 y wr&   r   )r  r  s    r   r  z^CoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_gen.<locals>.<genexpr>r  s     22s1v122s   
r  rf  	asendrK   r   rz   r  r  rW  rb   r.   )rm   r   rD  r   r  r  s      r   r  zKCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_genq  s     22C		$A""<0 B!!",,"8"8:LMR\\3388%@  s/   7B6B* B(B*A#B6(B**B3/B6rD  )r   r  r  r  r  r  r  s   `    @@r   ,test_for_assign_raising_stop_async_iterationz:CoroutineTest.test_for_assign_raising_stop_async_iterationZ  s    	- 	- k		 	79-E{;	
 	8:.U<	 	79-E{;r   c                      G d d      fd fd} j                  t         |             g df        fd} j                  t         |             g df        fd} j                  t         |             g df       y )Nc                       e Zd Zd Zy)QCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.BadIterablec                     t        d      r@  r  r   s    r   r   zZCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.BadIterable.__iter__}  r  r   N)r   r   r   r   r   r   r   BadIterabler  |  r  r   r  c                 "   K             y wr   r   )r  s   r   badpairszNCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.badpairs  s     -s   c                     K   j                  t              5 }         2 3 d {   \  }}7 6 	 d d d        n# 1 sw Y   nxY wj                   j                  j                  d       yw)Nr  rf  r  rD  r9   r^  r  r   s      r   r  zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_for  sl     ""#56 ""**  $!Q*   R\\..6r  rf  c                    K   j                  t              5 }         2 cg c3 d {   \  }}d7 
6 nc c}}w c}}cd d d        S # 1 sw Y   nxY wj                   j                  j                  d       ywr  r  r  s      r   r  zNCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_list  sh     ""#56 8",4J77DAq7778 8 8R\\..6s=   A?A97
57
97
9
A
A?A.A?c                  l  K   d         2        } | j                  d       }j                  t              5 }| d {    d d d        j                  j                  j
                  t               j                  |j                  j
                  j                  d       y7 g# 1 sw Y   fxY ww)Nc                8   K   | 3 d {   \  }}d 7 6 y wr&   r   )r  r9   r^  s      r   r  z`CoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_gen.<locals>.<genexpr>  s     22tq!122r  r  rf  r  )rm   r   rD  r  r   s      r   r  zMCoroutineTest.test_for_assign_raising_stop_async_iteration_2.<locals>.run_gen  s     2xz2C		$A""<0 B!!",,"8"8:LMR\\3388%@  s-   5B4B(B&B(A#B4&B((B1-B4rD  )r   r  r  r  r  r  s   `   @@r   .test_for_assign_raising_stop_async_iteration_2z<CoroutineTest.test_for_assign_raising_stop_async_iteration_2{  sx    	- 	-	 	 	79-E{;	
 	8:.U<	 	79-E{;r   c                     d }| j                  t              5   |       j                  }ddd       j                          y# 1 sw Y   xY w)*This would crash the interpreter in 3.11a2c                     K   y wr   r   r   r   r   r   z)CoroutineTest.test_bpo_45813_1.<locals>.f  r   rw   N)r   r   cr_frameclear)r   r   frames      r   test_bpo_45813_1zCoroutineTest.test_bpo_45813_1  s>    	n- 	!CLLE	!	! 	!s   AAc                     d } |       }| j                  t              5  |j                  j                          ddd       |j	                          y# 1 sw Y   xY w)r  c                     K   y wr   r   r   r   r   r   z)CoroutineTest.test_bpo_45813_2.<locals>.f  r   rw   N)r   r   r  r  r   rS  s      r   test_bpo_45813_2zCoroutineTest.test_bpo_45813_2  sJ    	cn- 	!LL 	!			! 	!s   AAc                     d } |       }| j                  |j                         |j                          | j                  |j                         y )Nc                     K   y wr   r   r   r   r   r   z2CoroutineTest.test_cr_frame_after_close.<locals>.f  r   rw   )assertIsNotNoner  r   r  rS  s      r   test_cr_frame_after_closez'CoroutineTest.test_cr_frame_after_close  s;    	cS\\*		#,,'r   c                     fd}fdt         j                  d         |       }|j                  d       }|j                  t              }| j                  ||       y )Nc                  .   K             d {   S 7 wr   r   rs  s   r   r   z6CoroutineTest.test_stack_in_coroutine_throw.<locals>.a       99rC  c                  .   K             d {   S 7 wr   r   r  s   r   r#  z6CoroutineTest.test_stack_in_coroutine_throw.<locals>.b  r  rC  c               3      K   	 t        t        j                                y # t        $ r" t        t        j                                Y y w xY wwr   )r  	tracebackextract_stackr   r   r   r   r   z6CoroutineTest.test_stack_in_coroutine_throw.<locals>.c  sA     5)11344$ 5)113445s%   A$ A(AAAA)r(   r   r,   r   r   rb   )r   r   r/   len_send	len_throwr#  r   s        @@r   test_stack_in_coroutine_throwz+CoroutineTest.test_stack_in_coroutine_throw  sZ    		 
	5 
	5 s99T?JJ01	9-r   N)Wr   r   r   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  r  r)  r0  r5  r8  r=  rE  rQ  rZ  r`  rg  rw  r}  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r)  r3  r;  rE  rM  rn  rz  r  r  r  r  r  r  r  r  r  r  r  r'  r7  r>  rE  rJ  rN  rT  rX  r  r  r  r  r  r  r  r  r  r  r   r   r   rj   rj   
  s   4M":/0 
!,(GT
,"+>.&P%<..+<G59	8	7,
5C$ 'D$$.&P, , ,&&K4=!@!(D4E,$!*F3P<>(>.Z&x!!$@('.'.F*@<<#<
 
"
&4HlD<B<@(.r   rj   z0asyncio does not work under Emscripten/WASI yet.c                       e Zd Zd Zy)CoroAsyncIOCompatTestc                    t        j                  d       G d dt              g  G fdd      fd}j                         }j	                  |       	 |j                   |              |j                          j                  d        | j                  g d       y # $ r Y =w xY w# |j                          j                  d        w xY w)Nasyncioc                       e Zd Zy)9CoroAsyncIOCompatTest.test_asyncio_1.<locals>.MyExceptionNrd  r   r   r   MyExceptionr    re  r   r  c                   &    e Zd Z fdZ fdZy)0CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CMc                    K   j                  d       j                  d       d {    j                  d       | S 7 w)Nr6   {Gz?r5   )r+   sleep)r   r  r0   s    r   r  z;CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aenter__  s;     a mmD)))a  *s   &AAAc                 z   K   j                  d       d {    j                  |j                         y 7  w)Nr  )r  r+   r   )r   exc_typeexc_valexc_tbr  r0   s       r   r  z:CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aexit__  s0     mmD)))h//0 *s   ;9!;Nr  )r  r0   s   r   r  r    s    1r   r  c                     K           4 d {   } j                  d       d {    7 7 # 1 d {  7  sw Y   nxY wj                  d       y w)Nr  unreachable)r  r+   )r   r  r  r  r0   s    r   r   z/CoroAsyncIOCompatTest.test_asyncio_1.<locals>.f  sX     t " "qmmD)))!!")" " " MM-(s7   A/A313A3A<AA)r6   r5   r  )	r   import_moduler  new_event_loopset_event_looprun_until_completer   set_event_loop_policyrb   )r   r   loopr  r  r  r0   s      @@@@r   test_asyncio_1z$CoroAsyncIOCompatTest.test_asyncio_1  s      --i8	) 	 		1 		1	) %%'t$	0##AC( JJL))$/!67  		 JJL))$/s$   "B. .B63B9 5B66B9 9#CN)r   r   r   r  r   r   r   r  r    s    %8r   r  c                   $    e Zd Zd Zd Zd Zd Zy)OriginTrackingTestc                     t        j                  t        j                         j                        }|j                  |j
                  fS r   )rd   getframeinfocurrentframef_backfilenamelineno)r   infos     r   herezOriginTrackingTest.here  s4    ##G$8$8$:$A$ABt{{++r   c                     t        j                         }	 d t        j                  d        j                  t        j                         d       t	        j
                                5 } j                  |j                         d d d        t        j                  d        j                  t        j                         d        j                         \  }}t	        j
                                5 } j                  |j                  ||dz   dff       d d d        t        j                  d        j                  t        j                         d        fd} j                         \  }} |       \  \  }}}t	        j
                  |      5   j                  |j                  ||df||dz   dff       d d d        t        j                  d       t	        j
                                5 } j                  dt        |j                        cxk  xr dk  nc        d d d         j                  t              5  t        j                  d	       d d d         j                  t        j                         d       t        j                  |       y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   uxY w# t        j                  |       w xY w)
Nc                     K   y wr   r   r   r   r   corofnz7OriginTrackingTest.test_origin_tracking.<locals>.corofn	  r  rw   r   r6   test_origin_trackingr5   c                  2    j                                  fS r   )r  )r  r   s   r   nestedz7OriginTrackingTest.test_origin_tracking.<locals>.nested	  s    		VX..r   r  rr  )rw  #get_coroutine_origin_tracking_depth#set_coroutine_origin_tracking_depthrb   
contextlibclosingr  	cr_originr  rc   r  rK   r   )	r   
orig_depthr/   fnamer  r  nested_fnamenested_linenor  s	   `       @r   r  z'OriginTrackingTest.test_origin_tracking  s{   <<>
*	@ 33A6SDDFJ##FH- 2!!$..12 33A6SDDFJ IIKME6##FH- Q  #(&1*6L"M!OQQ 33A6SDDFJ/ IIKME64:H1*lMD##D) P  #/"I#(&1*6L"M"OPP 33D9##FH- @C$7 >$ >?@ "":. <77;< SDDFM 33J?G2 2Q QP P@ @< < 33J?s   AK .J
A.K 8$J,A<K (J9 7K 73K*K K,K J)$K ,J61K 9K>K K
K KK K4c                    	
 d 
 j                         \  }}
fd|dz  } j                         \  }}fd	|dz  }	 fd}t        j                         }	  |dd
j                   d      } |d	d
j	                  d
j                   ddd| d| ddg              |dd
j	                  d
j                   ddd| d| ddd| d| ddg             t        j
                  |       y # t        j
                  |       w xY w)Nc                     K   y wr   r   r   r   r   r  z?OriginTrackingTest.test_origin_tracking_warning.<locals>.corofn.	  r   rw   c                               S r   r   )r  s   r   a1z;OriginTrackingTest.test_origin_tracking_warning.<locals>.a12	  s
    8Or   r5   c                               S r   r   )r  s   r   a2z;OriginTrackingTest.test_origin_tracking_warning.<locals>.a27	  s
    4Kr   c                    t        j                  |        j                  t              5 }         t	        j
                          d d d        j                  |t        j                               y # 1 sw Y   /xY wr   )	rw  r   r   r   r   r@   rb   r  warning)depthmsgrD  r  r   s      r   r   z>OriginTrackingTest.test_origin_tracking_warning.<locals>.check;	  sa    33E:!!.1 %R""$% S#bjj/2% %s   A66A?r   zcoroutine 'z' was never awaitedr6   r  z' 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  rw  r  r   ra   r   )r   a1_filename	a1_linenoa2_filename	a2_linenor   r  r  r  r  r  s   `       @@@r   test_origin_tracking_warningz/OriginTrackingTest.test_origin_tracking_warning-	  s@   	 "&Y	Q	!%Y	Q		3 <<>
	@[)<)<(==PQRC!RWWf1122GH@;-x	{)D6	   !RWWf1122GH@;-x	{)D4;-x	{)D6   33J?C33J?s   BC5 5Dc                    d }t         j                  }	 d t         _        t        j                         5 }t	        j
                  dt        f      5   |       }t        |      }~t        j                          | j                  t        |j                  j                        |       | j                  |j                  j                  t               d d d        d d d        t         `t	        j
                  dt        f      5   |        t        j                          d d d        |t         _        y # 1 sw Y   bxY w# 1 sw Y   fxY w# 1 sw Y   -xY w# |t         _        w xY w)Nc                     K   y wr   r   r   r   r   r  zLOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.corofn[	  r   rw   c                     ddz  S r  r   r   s    r   r   zNOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.<lambda>`	  s
    ac r   zcoroutine .* was never awaited)r=   _warn_unawaited_coroutiner   r  r   check_warningsr   r   r@   rb   r  r  r  r   )r   r  orig_wucrD  r/   r  s         r   )test_unawaited_warning_when_module_brokenz<OriginTrackingTest.test_unawaited_warning_when_module_brokenW	  s1   	 55	:1AH.335 L //;(*+L
 x J	 ""$  bmm&:&:!;YG  !7!79JKL L 2 //6GI %""$% 2:H.-L L L L % % 2:H.sS    E D?BD3D?)E EE 3D<	8D??EE EE E$N)r   r   r   r  r  r  r  r   r   r   r  r    s    ,,@\(@T :r   r  c                       e Zd Zd Zy)"UnawaitedWarningDuringShutdownTestc                 X    d}t        d|       d}t        d|       d}t        d|       y )NzWimport asyncio
async def f(): pass
async def t(): asyncio.gather(f())
asyncio.run(t())
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   rF   s     r   &test_unawaited_warning_during_shutdownzIUnawaitedWarningDuringShutdownTest.test_unawaited_warning_during_shutdown|	  s;    % 	t$# 	t$8 	t$r   N)r   r   r   r!  r   r   r   r  r  z	  s    %r   r  c                       e Zd Zd Zd Zd Zy)CAPITestc                 h    ddl m fd}| j                   |       j                  d       d       y )Nr   	awaitTypec                  H   K    t        dg            } |  d {   S 7 wr   rX  futureats    r   r^   z%CAPITest.test_tp_await_1.<locals>.foo	  s      aS	]F L!Ls   " "r6   )	_testcapir&  rb   r,   r   r^   r*  s     @r   test_tp_await_1zCAPITest.test_tp_await_1	  s(    -	" 	D)1-r   c                     ddl m}  |t        dg            }| j                  t	        |j                               d       y )Nr   r%  r6   )r+  r&  r   rb   r7   r   )r   r*  r)  s      r   test_tp_await_2zCAPITest.test_tp_await_2	  s2    -D!If..0115r   c                     ddl m fd}| j                  t        d      5  | j	                   |       j                  d       d       d d d        y # 1 sw Y   y xY w)Nr   r%  c                  4   K    d      } |  d {   S 7 wr   r   r(  s    r   r^   z%CAPITest.test_tp_await_3.<locals>.foo	  s     UF L!Ls   z.__await__.*returned non-iterator of type 'int'r6   )r+  r&  r   r   rb   r,   r,  s     @r   test_tp_await_3zCAPITest.test_tp_await_3	  sR    -	" ##KM 	2SUZZ-q1	2 	2 	2s   'AAN)r   r   r   r-  r/  r2  r   r   r   r#  r#  	  s    .6	2r   r#  __main__)%r  r  rd   r  rw  r(   r  unittestr=   testr   test.supportr   r   test.support.script_helperr   r	   r   r#   r3   r:   contextmanagerrA   TestCaserC   rY   rj   skipIfis_emscriptenis_wasir  r  r  cpython_onlyr#  r   r  r   r   r   <module>r>     sQ       
      & ( 7  &  b0** b0J@)) @,.H%% .D6 ,W__6'8H-- '8	'8T}:** }:@%):): %* 	2x   2 2: ZHMMO r   