
    z%i                       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     H/home/uftp/.pyenv/versions/3.12.0/lib/python3.12/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                     g }d }	 	 |j                  | j                  d              "# t        $ r*}|j                  r|j                  d   nd }Y d }~||fS d }~ww xY wNr   )appendsendStopIterationargs)corobufferresultexs       r   	run_asyncr/   &   sc     FF
	MM$))D/*   	#%77RWWQZF6>	s    ( 	AAAc                 *   | 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'   nextr(   r)   r*   )r+   awr,   r-   ir.   s         r   run_async__await__r6   4   s    		BFF	A
	1ud2h'bggdm,FA   	#%77RWWQZF6>	s   AA 	B(BB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_gcr=   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   samplesrB   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)rA   rC   rD   rE   rJ   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 0rM   c                 r    | j                  t              5  t        ddd       d d d        y # 1 sw Y   y xY w)Nz	async = 1rC   rD   )rG   rH   rI   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
            rA   rC   rD   rE   rJ   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 0rM   N)r   r   r   rL   rO   rQ   rS   r   r   r   r?   r?   O   s    C0J
%0N300r   r?   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}r5   
i499i  z
async def foo():
    returnfoo)	ranger'   formatjoinrD   assertEqual
assertTrueinspectiscoroutinefunction)r   bufr5   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   rd   r   r   r   rU   rU     s    @r   rU   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 ZUyT)U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   ri   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   rZ   z&CoroutineTest.test_func_1.<locals>.foo  	        rq   c                       y r   r   r   r   r   barz&CoroutineTest.test_func_1.<locals>.bar  s    r   )assertIsInstancetypesCoroutineTyper_   bool__code__co_flagsr`   CO_COROUTINErk   CO_GENERATORcr_coder^   r/   r6   r   rZ   fru   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   rZ   z&CoroutineTest.test_func_2.<locals>.foo"          	zcoroutine raised StopIteration)assertRaisesRegexRuntimeErrorr/   r   rZ   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   rZ   z&CoroutineTest.test_func_3.<locals>.foo+  r   r   z^<coroutine object.* at 0x.*>$)assertRegexreprclose)r   rZ   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   rZ   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   rZ   r+   checkr5   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Nr2   r   r   r   r   ru   z&CoroutineTest.test_func_5.<locals>.barP  s     Grj   c                  0   K             d {    y 7 wr   r   ru   s   r   rZ   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   r2   r2   )rw   	coroutiner   r^   r   r3   r   )r   rZ   r   r+   elru   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Nr2   r1   r   r   r   r   ru   z&CoroutineTest.test_func_6.<locals>.barh  s     GGs   
c                  0   K             d {    y 7 wr   r   r   s   r   rZ   z&CoroutineTest.test_func_6.<locals>.foom  r   r   r2   r1   )rw   r   r^   r(   rG   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rp   r   r   r   r   ru   z&CoroutineTest.test_func_7.<locals>.barw  rr   rs   c               3   &   K    E d {    y 7 wr   r   r+   s   r   rZ   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   ru   rZ   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   ru   z&CoroutineTest.test_func_8.<locals>.bar  s     #O$Os   c                     K   ywNspamr   r   r   r   rZ   z&CoroutineTest.test_func_8.<locals>.foo  	     rs   r   )rw   r   r^   r/   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   rZ   z&CoroutineTest.test_func_9.<locals>.foo  	     rs   z0coroutine '.*test_func_9.*foo' was never awaited)assertWarnsRegexRuntimeWarningr   r<   rG   r   )r   rZ   _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)Nr1   d   r2   ZeroDivisionError)aNs    r   ri   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   ri   s   r   rZ   z'CoroutineTest.test_func_10.<locals>.foo  r   r   rq   r   r2   f   )rw   r   r   assertIsr   r3   r^   r(   r   rG   r   throwassertWarnsDeprecationWarning)r   rZ   r+   r4   r   ri   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       rs   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(   rZ   )r5   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   rs   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   ri   z'CoroutineTest.test_func_14.<locals>.gen  	     rj   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)rw   r   r(   r   r   r   )r   r+   cri   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   rs   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   rj   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)rw   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   rs   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   rs   r   r   r   )
r   r   r   r)   r(   r   r3   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   rZ   z'CoroutineTest.test_func_19.<locals>.foor  s+        qs   " """c                  0   K             d {    y 7 wr   r   )rZ   s   r   r   z-CoroutineTest.test_func_19.<locals>.coroutine{  r   r   r2      )rw   r   r(   r^   r   r[   )r   r   r+   r   r  rZ   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rq   r   r   r   r   rZ   z7CoroutineTest.test_coro_wrapper_send_tuple.<locals>.foo  s	     rs   r  )r6   r^   r   rZ   r-   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rp   r   r   r   r   rZ   z?CoroutineTest.test_coro_wrapper_send_stop_iterator.<locals>.foo  s      $$   r2   rq   )r6   rv   r)   r^   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   )r^   r`   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   )rw   r   r^   r`   r  CORO_CREATEDr  r  r(   CORO_SUSPENDEDgi_codeco_namerG   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                  }| 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  r   rs   zcoroutine object)rw   rx   r   r(   __doc__r   r   __dict__r^   r   r   )r   ctr   r   s       r   test_corotype_1zCoroutineTest.test_corotype_1  s      &8("((*:*:;nbhh&6&67("++j*A*I*IJ("++n*E*M*MN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   rZ   z'CoroutineTest.test_await_1.<locals>.foo  s     GG   zobject int can.t.*awaitr   r   r/   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   rZ   z'CoroutineTest.test_await_2.<locals>.foo  s     HHr0  zobject list can.t.*awaitr1  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r2   r1   r  )r	   r   r   r   rZ   z'CoroutineTest.test_await_3.<locals>.foo  s      +++s   r9  )r^   r/   r6   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   ru   z'CoroutineTest.test_await_4.<locals>.bar  rr   rs   c                  .   K             d {   S 7 wr   r   r   s   r   rZ   z'CoroutineTest.test_await_4.<locals>.foo  s     ;;   r>  r^   r/   )r   rZ   ru   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   	AwaitablerE    s    r   rH  c                  .   K             d {   S 7 wr   r   rH  s   r   rZ   z'CoroutineTest.test_await_5.<locals>.foo       #+%&%r@  (__await__.*returned non-iterator of typer1  r   rZ   rH  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   NrG  r   r   r   rH  rR    s    "r   rH  c                  .   K             d {   S 7 wr   r   rJ  s   r   rZ   z'CoroutineTest.test_await_6.<locals>.foo  rK  r@  rT  rA  rM  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)Nr>  r   r   r   s    r   r   z7CoroutineTest.test_await_7.<locals>.Awaitable.__await__  s     rj   NrG  r   r   r   rH  rZ    s    r   rH  c                  .   K             d {   S 7 wr   r   rJ  s   r   rZ   z'CoroutineTest.test_await_7.<locals>.foo  rK  r@  r>  r   rA  rM  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   rH  r`        r   rH  c                  .   K             d {   S 7 wr   r   rJ  s   r   rZ   z'CoroutineTest.test_await_8.<locals>.foo  s     ik 11 1r@  z4object Awaitable can't be used in 'await' expressionr1  rM  s     @r   test_await_8zCoroutineTest.test_await_8  sH    	 	 	2##MO 	 ce	 	 	rO  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   ru   z'CoroutineTest.test_await_9.<locals>.bar  rr   rs   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   rg  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!  rk  s   r   DBrm    s    r   rn    r!  )dbrn  ru   rg  s     r   rZ   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  irA  )r   rZ   rs  ru   rg  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)  rr   rs   c                     K            S wr   r   )rw  s   r   ru   z(CoroutineTest.test_await_10.<locals>.bar,  s     5Ls   c                  B   K             d {    d {   S 7 7 wr   r   r   s   r   rZ   z(CoroutineTest.test_await_10.<locals>.foo/  s      #+&&+&s   r>  rA  )r   rZ   ru   rw  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>.ident5  s    Jr   c                     K   ywr   r   r   r   r   ru   z(CoroutineTest.test_await_11.<locals>.bar8  r   rs   c                  <   K              d {         S 7 	w)Nr}  r   )ru   r  s   r   rZ   z(CoroutineTest.test_await_11.<locals>.foo;  s     35[))[s   
c                  2   K             d {   dfS 7 w)Nr   r   r   s   r   rs  z)CoroutineTest.test_await_11.<locals>.foo2>  s     ;%%;s   )r   r   rA  )r   rZ   rs  ru   r  s      @@r   test_await_11zCoroutineTest.test_await_114  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>.coroD  r   rs   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__I  s    r   NrG  r   s   r   rH  r  H  s    r   rH  c                  .   K             d {   S 7 wr   r   rJ  s   r   rZ   z(CoroutineTest.test_await_12.<locals>.fooL       "$$$r@  z"__await__\(\) returned a coroutine)r   r   r/   r   )r   r+   rZ   rH  r   s      @@r   test_await_12zCoroutineTest.test_await_12C  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__W      r   NrG  r   r   r   rH  r  V      r   rH  c                  .   K             d {   S 7 wr   r   rJ  s   r   rZ   z(CoroutineTest.test_await_13.<locals>.fooZ  r  r@  rL  r1  rM  s     @r   test_await_13zCoroutineTest.test_await_13U  sJ    	 		% ##AC 	 ce	 	 	rO  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                     || _         y r   r   )r   r+   s     r   r   z5CoroutineTest.test_await_14.<locals>.Wrapper.__init__e  s	     	r   c                 6    | j                   j                         S r   )r+   r   r   s    r   r   z6CoroutineTest.test_await_14.<locals>.Wrapper.__await__h  s    yy**,,r   Nr   r   r   r   Wrapperr  c  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__l  s     s   NrG  r   r   r   
FutureLiker  k  s    r   r  c                       e Zd Zy)+CoroutineTest.test_await_14.<locals>.MarkerNra  r   r   r   Markerr  o  rb  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>.coro1r  s-     '\)))$ s    %
  % "%c                  :   K                    d {   S 7 wr   r   )r  r  s   r   coro2z*CoroutineTest.test_await_14.<locals>.coro2w  s      ))))s   r   )r   r(   r   r)   rG   r   r   )r   r  r   r  r  r  r  s      @@@@r   test_await_14zCoroutineTest.test_await_14b  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   rj   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     JJr0  z"coroutine is being awaited already)rw   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   " ")r/   r  __context__)r   r   r   r-   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  managersr2   r   r  )r   r!  r  s     r   rZ   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  r2   r   r  )r   r   r  s     r   rZ   z&CoroutineTest.test_with_1.<locals>.foo  r  r  )r/   r^   rG   r   )r   rZ   r   r-   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   rZ   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   r/   r   r   rZ   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   rZ   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>.CMNra  r   r   r   r  r    rb  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   rZ   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__  	     rs   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   r2   )r^   )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)rG   AssertionErrorr/   )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   rZ   z&CoroutineTest.test_with_6.<locals>.foo  s>     t        s0   ?&?*?(??<3<?zV'async with' received an object from __aenter__ that does not implement __await__: intr1  )r   rZ   r  s     @r   test_with_6zCoroutineTest.test_with_6  sK    	 		 ##9: 	
 ce	 	 	rO  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Nr2   r   r   r  s   r   rZ   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)	r/   failr   r   r*   r_   r  
isinstancer   )r   rZ   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__@  r  r  c                      yr  r   r  s     r   r  z/CoroutineTest.test_with_8.<locals>.CM.__aexit__C  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   rZ   z&CoroutineTest.test_with_8.<locals>.fooG  D     t  q      r  r  r2   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Nr1   r2   r[   r5   r  r  s    r   rZ   z&CoroutineTest.test_with_8.<locals>.fooS  s_     1X 4  1HC      s>   A<AA A>	AA A	A	A	Ar1   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   rZ   z&CoroutineTest.test_with_8.<locals>.fooa  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   rZ   z&CoroutineTest.test_with_8.<locals>.fooo  sG     t  q      s8   A+A/A-AAA8AA   )r   r   r/   r^   r   rZ   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   rZ   z&CoroutineTest.test_with_9.<locals>.foo  r  r  r2   rG   r   r/   r^   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   rZ   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)r/   r  r   r_   r  r	  r   r   rZ   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  r3    s    *r   r  c                  f   K            4 d {    t         7 
# 1 d {  7  sw Y   y xY wwr   r.  r  s   r   rZ   z'CoroutineTest.test_with_11.<locals>.foo  s1     t # #""# # # #s$   111.%.1z+exception from __aenter__ did not propagate)r/   r  r5  r_   r  r/  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__  	     rs   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   	__class__r   )cmr  r  r   s    r   rZ   z'CoroutineTest.test_with_12.<locals>.foo  sE     t # #rbllB/""# # # #s,   A6A#8AA
AA
A)r/   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r>  r   r  s     r   r  z0CoroutineTest.test_with_13.<locals>.CM.__aexit__  r?  rs   Nr  r   r   r   r  rF    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)Nr2   ro  '  r   r  s   r   rZ   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r2   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&   rW   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)Nr2   rq   r   )r5   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   rS  rV  )rR  s   r   	AsyncIterrN    s    
	&r   rX  c                  d   K           2 3 d {   \  } }j                  | |z          !7 6 y wr   r'   )i1i2rX  r,   s     r   test1z'CoroutineTest.test_for_1.<locals>.test1   s4      ) ' 'fb"b2g&'s   0.,.0.0r2      r   e   r1   c                     K           2 3 d {   } j                  | d          | d   dk(  s& j                  d       y 7 46 j                  d       'wNr      what?endrZ  r5   rX  r,   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      rd  c                     K           2 3 d {   } | d   dkD  rj                  | d          '7 "6 j                  d       j                  d       y wra  rZ  re  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  rc  )r/   r^   r[   )
r   r]  yieldedr   r5   rf  rj  rX  rR  r,   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)Nr9  c                  B   K   2 3 d {   } t        d       7 6 y wNznever going to happenprint)r5   tups    r   rZ   z%CoroutineTest.test_for_2.<locals>.foo3  s'      / /a-./3   z/async for' requires an object.*__aiter__.*tuplesysgetrefcountr   r   r/   r^   )r   refs_beforerZ   rr  s      @r   
test_for_2zCoroutineTest.test_for_2/  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   rS  z-CoroutineTest.test_for_3.<locals>.I.__aiter__@  r  r   Nr   r   r   rS  r   r   r   Ir{  ?  r  r   r~  c                  B   K   2 3 d {   } t        d       7 6 y wro  rp  r5   aiters    r   rZ   z%CoroutineTest.test_for_3.<locals>.fooF  '       / /a-./5rs  z!that does not implement __anext__rt  r   r~  rw  rZ   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   rS  z-CoroutineTest.test_for_4.<locals>.I.__aiter__T  r  r   c                      y)Nr   r   r   s    r   rV  z-CoroutineTest.test_for_4.<locals>.I.__anext__W  s    r   N)r   r   r   rS  rV  r   r   r   r~  r  S  s    r   r~  c                  B   K   2 3 d {   } t        d       7 6 y wro  rp  r  s    r   rZ   z%CoroutineTest.test_for_4.<locals>.foo]  r  rs  z7async for' received an invalid object.*__anext__.*tuplert  r  s       @r   
test_for_4zCoroutineTest.test_for_4R  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)NrJ  r   )r   r~  s    r   r  z4CoroutineTest.test_for_6.<locals>.Manager.__aenter__m  s     U
   
c                    K   dz  y w)Ni r   )r   r*   r~  s     r   r  z3CoroutineTest.test_for_6.<locals>.Manager.__aexit__q  s     Vr  Nr  )r~  s   r   r  r  l  s    r   r  c                       e Zd Zd Zd Zd Zy)*CoroutineTest.test_for_6.<locals>.Iterablec                     d| _         y r&   rW   r   s    r   r   z3CoroutineTest.test_for_6.<locals>.Iterable.__init__v  rP  r   c                     | S r   r   r   s    r   rS  z4CoroutineTest.test_for_6.<locals>.Iterable.__aiter__y  r  r   c                 v   K   | j                   dkD  rt        | xj                   dz  c_         | j                   S wNrq   r2   )r5   rU  r   s    r   rV  z4CoroutineTest.test_for_6.<locals>.Iterable.__anext__|  s-     66B;,,!vvs   79NrW  r   r   r   Iterabler  u  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Nr2   ro  r   )r5   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   r5   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   r2   i ro  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)ru  rv  r9   r:   r;   r/   r^   )	r   mrefs_beforeirefs_beforer  r~  r  r  r!   r  s	       @@@@@r   
test_for_6zCoroutineTest.test_for_6i  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   rS  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Nr2   rq   r   r5   r  r  s    r   rZ   z%CoroutineTest.test_for_7.<locals>.foo  2     4  aq42IC   ###r%  r   rZ   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   rS  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   rZ   z%CoroutineTest.test_for_8.<locals>.foo  r  r  r  )rG   r   r9   r:   r;   r/   r^   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   rS  z.CoroutineTest.test_for_11.<locals>.F.__aiter__  r  r   c                     | S r   r   r   s    r   rV  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   rS  rV  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(   	exceptionrv   	__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>.DoneNra  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   rS  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   )r5   lenrU  r   s    r   rV  z5CoroutineTest.test_for_tuple.<locals>.AIter.__anext__   s<     66SY&,,!DFFQJ''s   AANr   r   r   r5   rS  rV  r   r   r   AIterr    s    A(r   r  c                  ^   K    dg      2 3 d {   } j                  |        7 6 wr=  rZ  r5   r  r  r-   s    r   rZ   z)CoroutineTest.test_for_tuple.<locals>.foo  s5      "; ! !aa !;Js   
-*(*-*-r>  )r   r   rG   r(   r^   r   rZ   r  r  r-   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>.DoneNra  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   rS  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   )r5   rU  r   r   s    r   rV  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=  rZ  r  s    r   rZ   z2CoroutineTest.test_for_stop_iteration.<locals>.foo  s3      9 ! !aa !9Js   	,)'),),r>  )r   r)   rG   r(   r^   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   rW   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Nr2   )   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)Nr2   r  r   r   r  s    r   	run_dict1z,CoroutineTest.test_comp_1.<locals>.run_dict11  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)r5   r   r   s     r   	run_dict2z,CoroutineTest.test_comp_1.<locals>.run_dict24  s8     +4adAbE]+CD41aAQwJDDwDs   A;9;A;Ar2   r  r   )r2   r  )r   r2   rA  )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   rW   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_list@  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)Nrq      rb  r   )r   r  dr   s      r   r  z*CoroutineTest.test_comp_2.<locals>.run_setH  s     B8!"B4!* + ,& &#$W& #$W	& 	  &A &A & & %$	&s6   A
AAAAA	AAAA>   rq   rb  r  c                     K     d       d      g      fD  ch c]  } |  d {   D ]  }| d {     c}} S 7 7 c c}} w w)Nrq   rb  r   r  s     r   run_set2z+CoroutineTest.test_comp_2.<locals>.run_set2S  s\     2"/0&#$W& GG &G & &$  &s5   A
AAAAAAAAArq   rb  rA  )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  r5   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Nrq   rb  r2   r   r5   r   s    r   r  z+CoroutineTest.test_comp_3.<locals>.run_lista  .     )*B855AAE5555$   ,'#!
#'#',r^  rh  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_setg  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Nrq   rb  r2   r1   r   r  s    r   run_dictz+CoroutineTest.test_comp_3.<locals>.run_dictm  s6     012r(<<1AE1q5L<<<<s$   0+'%
'+'+0      )r^  rh  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   .0r5   s     r   	<genexpr>z=CoroutineTest.test_comp_3.<locals>.run_gen.<locals>.<genexpr>t  s     4411q544   
rq   rb  r   r   ri   r   r   s     r   run_genz*CoroutineTest.test_comp_3.<locals>.run_gens  s8     42r(4C+.//aAG////$   50,*
,0,05o   y   rA  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rh  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      	  rq   rb  r   r   r  s     r   r  z*CoroutineTest.test_comp_4.<locals>.run_gen  s8     >2r(>C+.//aAG////r  r  rA  r  s        @r   test_comp_4zCoroutineTest.test_comp_4z  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  rq   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  rq   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r_  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  rq   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   rA  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)Nrq   rb  r  (   r   r2   r   )pairr5   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  rA  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rq   rb  )r  r2   r   )seqr5   r   s     r   r  z+CoroutineTest.test_comp_6.<locals>.run_list  sQ     +,h->+? " "C " E "E " " " "s$   60+)+0+0
6)r^  rh     rA  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)Nr2   r1   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$   
&!
!!&rF  )r   r   r/   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r8  r   rW   s    r   r   z$CoroutineTest.test_comp_8.<locals>.f  s     ()!A)))s   	r9  rA  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   ri   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   )r5   lri   s     r   r   z$CoroutineTest.test_comp_9.<locals>.f  s7     "%%((Q(((A( >!A>!>s,   
;
;	6;r2   r1   rA  r   r   ri   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r8  r   )r5   xxr"   s      r   r   z%CoroutineTest.test_comp_10.<locals>.f  s6     &'!'B'"$%QAqD%% (%s   -	#-
(-r2   r1   r  r9  rA  rK  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Nr@  r2   r1   r#   jr5   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  rh  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rY  rZ  r[  s     r   run_set_inside_listz;CoroutineTest.test_nested_comp.<locals>.run_set_inside_list  r^  r_  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  rq   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rY  rZ  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)r2   r1   r@  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)r2   r1   NrZ  )r  r\  r5   s      r   r  zNCoroutineTest.test_nested_comp.<locals>.run_list_inside_gen.<locals>.<genexpr>  s5     NAq6):;;AAEN;;;;s(   9-+)+-9+-9r@  r   )ri   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)Nrc  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   r2   r1   r   r2   r1   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>   rl  rm  Nrn  )r  r\  s     r   r  zMCoroutineTest.test_nested_comp.<locals>.run_gen_inside_gen.<locals>.<genexpr>   s"     Kq:ia&9::Ks   %'rc  r   )ro  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   rg  r@  r2   r1   rZ  )kr\  r5   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  r3  r  z               rA  )	r   r]  ra  rd  rf  ri  rp  rt  rw  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>.func/  r   rs   )rG   r   copyr   r   )r   r   r+   r4   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   rs   r2   )	r[   pickleHIGHEST_PROTOCOLrG   r   PicklingErrordumpsr   r   )r   r   r+   protor4   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>.funcL  r   rs   r  zwas never awaited)r9   r:   r   catch_unraisable_exceptionfilterwarningsr   r<   r   str
unraisable	exc_valuer^   object)r   r   rB  r+   	coro_reprs        r   test_fatal_coro_warningz%CoroutineTest.test_fatal_coro_warningJ  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=  rU  )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  Z      -r   r  c                    K   d y wrp   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   r>  rd  rG   rU  r^   r  r*   rB  r   r  tgts    r   run_forzKCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_fora  sl     ""#56 "$*H  #a&H   R\\..61   A.;0.0;0;	A.A .A.rd  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_listi  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>q  s     22s1v122s   
r  rd  	asendrG   r   rv   r  r  rU  r^   r*   )ri   r   rB  r   r  r  s      r   r  zKCoroutineTest.test_for_assign_raising_stop_async_iteration.<locals>.run_genp  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rA  )r   r  r  r  r  r  r  s   `    @@r   ,test_for_assign_raising_stop_async_iterationz:CoroutineTest.test_for_assign_raising_stop_async_iterationY  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  rd  r  rB  r5   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  rd  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  r5   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  rd  r  )ri   r   rB  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rA  )r   r  r  r  r  r  s   `   @@r   .test_for_assign_raising_stop_async_iteration_2z<CoroutineTest.test_for_assign_raising_stop_async_iteration_2z  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   rs   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   rs   N)r   r   r  r  r   rQ  s      r   test_bpo_45813_2zCoroutineTest.test_bpo_45813_2  sJ    	cn- 	!LL 	!			! 	!s   AAc                     fd}fdt         j                  d         |       }|j                  d       }|j                  t              }| j                  ||       y )Nc                  .   K             d {   S 7 wr   r   rp  s   r   r   z6CoroutineTest.test_stack_in_coroutine_throw.<locals>.a       99r@  c                  .   K             d {   S 7 wr   r   r  s   r   r!  z6CoroutineTest.test_stack_in_coroutine_throw.<locals>.b  r  r@  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)rw   r   r(   r   r   r^   )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)Vr   r   r   rm   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r'  r-  r2  r5  r:  rB  rN  rW  r]  rd  rt  rz  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r&  r0  r8  rC  rK  rl  rx  r  r  r  r  r  r  r  r  r  r  r  r%  r5  r<  rC  rH  rL  rR  rV  r}  r  r  r  r  r  r  r  r  r   r   r   rf   rf   
  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   rf   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>.MyExceptionNra  r   r   r   MyExceptionr    rb  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)Nr2   {Gz?r1   )r'   sleep)r   r  r,   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  r,   s       r   r  z:CoroAsyncIOCompatTest.test_asyncio_1.<locals>.CM.__aexit__  s0     mmD)))h//0 *s   ;9!;Nr  )r  r,   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  r,   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)r2   r1   r  )	r   import_moduler   new_event_loopset_event_looprun_until_completer   set_event_loop_policyr^   )r   r   loopr  r  r  r,   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   )r`   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  rs   r   r2   test_origin_trackingr1   c                  2    j                                  fS r   )r  )r  r   s   r   nestedz7OriginTrackingTest.test_origin_tracking.<locals>.nested	  s    		VX..r   r  ro  )ru  #get_coroutine_origin_tracking_depth#set_coroutine_origin_tracking_depthr^   
contextlibclosingr  	cr_originr  r_   r  rG   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   rs   c                               S r   r   )r  s   r   a1z;OriginTrackingTest.test_origin_tracking_warning.<locals>.a1)	  s
    8Or   r1   c                               S r   r   )r  s   r   a2z;OriginTrackingTest.test_origin_tracking_warning.<locals>.a2.	  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   )	ru  r  r   r   r   r<   r^   r  warning)depthmsgrB  r  r   s      r   r   z>OriginTrackingTest.test_origin_tracking_warning.<locals>.check2	  sa    33E:!!.1 %R""$% S#bjj/2% %s   A66A?r   zcoroutine 'z' was never awaitedr2   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  ru  r  r   r]   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>.corofnR	  r   rs   c                     ddz  S r  r   r   s    r   r   zNOriginTrackingTest.test_unawaited_warning_when_module_broken.<locals>.<lambda>W	  s
    ac r   zcoroutine .* was never awaited)r9   _warn_unawaited_coroutiner   r  r   check_warningsr   r   r<   r^   r  r  r  r   )r   r  orig_wucrB  r+   r  s         r   )test_unawaited_warning_when_module_brokenz<OriginTrackingTest.test_unawaited_warning_when_module_brokenN	  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   rB   s     r   &test_unawaited_warning_during_shutdownzIUnawaitedWarningDuringShutdownTest.test_unawaited_warning_during_shutdowns	  s;    % 	t$# 	t$8 	t$r   N)r   r   r   r  r   r   r   r  r  q	  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   rU  futureats    r   rZ   z%CAPITest.test_tp_await_1.<locals>.foo	  s      aS	]F L!Ls   " "r2   )	_testcapir   r^   r(   r   rZ   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  r2   )r%  r   r   r^   r3   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   rZ   z%CAPITest.test_tp_await_3.<locals>.foo	  s     UF L!Ls   z.__await__.*returned non-iterator of type 'int'r2   )r%  r   r   r   r^   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)  r,  r   r   r   r  r  	  s    .6	2r   r  __main__)%r  r  r`   r  ru  rw   r  unittestr9   testr   test.supportr   r   test.support.script_helperr   r	   r   r#   r/   r6   contextmanagerr=   TestCaser?   rU   rf   skipIfis_emscriptenis_wasir  r  r  cpython_onlyr  r   r  r   r   r   <module>r8     sQ       
      & ( 7  &  b0** b0J@)) @,v.H%% v.r5 ,W__6'8H-- '8	'8T}:** }:@%):): %* 	2x   2 2: ZHMMO r   