o
    IXh`x                     @   s\   	 d dl Z d dlZd dlmZmZmZ d dlmZ G dd de jZ	e
dkr,e   dS dS )    N)captured_stderr
disable_gc
gc_collect)supportc                   @   s  e Zd Z	 dd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCS )DTestPEP380Operationc                    P   	 g  fdd}fdd | D ]
} d|f  q| g d d S )Nc                   3   &     d   E d H   d d S NStarting g1Finishing g1append g2tracer   >/opt/python-3.10.19/usr/lib/python3.10/test/test_yield_from.pyg1      
zOTestPEP380Operation.test_delegation_of_initial_next_to_subgenerator.<locals>.g1c                   3   s       d dV    d d S )NStarting g2*   Finishing g2r   r   r   r   r   r      s   
zOTestPEP380Operation.test_delegation_of_initial_next_to_subgenerator.<locals>.g2
Yielded %s)r
   r   z
Yielded 42r   r   r   assertEqualselfr   xr   r   r   /test_delegation_of_initial_next_to_subgenerator   s   
zCTestPEP380Operation.test_delegation_of_initial_next_to_subgeneratorc              
         	 g  fdd}fdd z| D ]
} d|f  qW n ty; } z| |jd d W Y d }~n
d }~ww | d | g d	 d S )
Nc                	   3   s6    z d   E d H  W  d d S  d w r	   r   r   r   r   r   r   1   s
   
zKTestPEP380Operation.test_raising_exception_in_initial_next_call.<locals>.g1c                	      s    z	  d td  d w )Nr   spanish inquisition occurredr   r   
ValueErrorr   r   r   r   r   7   s   
zKTestPEP380Operation.test_raising_exception_in_initial_next_call.<locals>.g2r   r   r!   'subgenerator failed to raise ValueError)r
   r   r   r   r   r#   r   argsfailr   r   r   er   r   r   +test_raising_exception_in_initial_next_call,   s   

z?TestPEP380Operation.test_raising_exception_in_initial_next_callc                    r   )Nc                   3   s2     d dV    E d H  dV   d d S Nr
   g1 hamg1 eggsr   r   r   r   r   r   r   P   s   
zLTestPEP380Operation.test_delegation_of_next_call_to_subgenerator.<locals>.g1c                   3   s&      d dV  dV    d d S Nr   g2 spamg2 more spamr   r   r   r   r   r   r   V   s
   
zLTestPEP380Operation.test_delegation_of_next_call_to_subgenerator.<locals>.g2r   )r
   Yielded g1 hamr   Yielded g2 spamYielded g2 more spamr   Yielded g1 eggsr   r   r   r   r   r   ,test_delegation_of_next_call_to_subgeneratorK   s   
z@TestPEP380Operation.test_delegation_of_next_call_to_subgeneratorc              
      r    )
Nc                	   3   B    z d dV    E d H  dV  W  d d S  d w r+   r   r   r   r   r   r   m      
zMTestPEP380Operation.test_raising_exception_in_delegated_next_call.<locals>.g1c                	   3   s(    z  d dV  td  d w )Nr   r/   hovercraft is full of eelsr0   r   r"   r   r   r   r   r   u   s   
zMTestPEP380Operation.test_raising_exception_in_delegated_next_call.<locals>.g2r   r   r8   r$   r
   r1   r   r2   r   r   r%   r(   r   r   r   -test_raising_exception_in_delegated_next_callh   s   

zATestPEP380Operation.test_raising_exception_in_delegated_next_callc                    s   	 g  fdd}fdd | }t |}d}z	 ||}d|f  |d7 }q ty5   Y nw | g d d S )Nc                  3   R     d dV }  d| f    E d H  dV }  d| f   d d S Nr
   r,   zg1 received %sr-   r   r   r   r   r   r   r         
z7TestPEP380Operation.test_delegation_of_send.<locals>.g1c                  3   sF      d dV }   d| f  dV }   d| f    d d S )Nr   r/   g2 received %sr0   r   r   r=   r   r   r   r      s   
z7TestPEP380Operation.test_delegation_of_send.<locals>.g2   r   )r
   g1 received 1r   r2   g2 received 2r3   zg2 received 3r   r4   zg1 received 4r   )nextsendr   StopIterationr   )r   r   gyr   r   r   r   test_delegation_of_send   s"   
z+TestPEP380Operation.test_delegation_of_sendc                    sN   	 g fdd fdd fdd}|  t| | g d d S )Nc                  3   r;   r<   r   r=   r   r   r   r      r>   zMTestPEP380Operation.test_handling_exception_while_delegating_send.<locals>.g1c                  3   s*      d dV }   d| f  td)Nr   r/   r?   r8   r"   r=   r   r   r   r      s
   
zMTestPEP380Operation.test_handling_exception_while_delegating_send.<locals>.g2c                     sX     } t | }d}z	 | |}d|f  |d7 }q ty+   d Y d S w )Nr@   r   rE   )rC   rD   r   rE   )rF   rG   r   )r   r   r   r   run   s   
zNTestPEP380Operation.test_handling_exception_while_delegating_send.<locals>.run)r
   rA   r   r2   rB   )assertRaisesr#   r   r   rI   r   r   r   r   r   -test_handling_exception_while_delegating_send   s   zATestPEP380Operation.test_handling_exception_while_delegating_sendc                    sh   	 g  fdd}fdd | }t dD ]}t|}d|f  q|  | g d d S )Nc                	   3   r6   r+   r   r   r   r   r   r      r7   z5TestPEP380Operation.test_delegating_close.<locals>.g1c                	   3   6    z  d dV  dV  W   d d S   d w r.   r   r   r   r   r   r         
z5TestPEP380Operation.test_delegating_close.<locals>.g2   r   r9   )rangerC   r   closer   )r   r   rF   ir   r   r   r   test_delegating_close   s   z)TestPEP380Operation.test_delegating_closec              
      s   	 g  fdd}fdd z| }t dD ]}t|}d|f  q|  W n" tyN } z| |jd d | |jt	 W Y d }~n
d }~ww | 
d	 | g d
 d S )Nc                	   3   r6   r+   r   r   r   r   r   r   	  r7   zMTestPEP380Operation.test_handing_exception_while_delegating_close.<locals>.g1c                	   3   s@    z  d dV  dV  W   d td  d td)Nr   r/   r0   r   "nybbles have exploded with delightr"   r   r   r   r   r     s   


zMTestPEP380Operation.test_handing_exception_while_delegating_close.<locals>.g2rP   r   r   rU   r$   r9   )rQ   rC   r   rR   r#   r   r&   assertIsInstance__context__GeneratorExitr'   r   r   rF   rS   r   r)   r   r   r   -test_handing_exception_while_delegating_close  s"   
zATestPEP380Operation.test_handing_exception_while_delegating_closec              
      s   	 g  fdd}fdd z!| }t dD ]}t|}d|f  qtd}|| W n tyL } z| |jd d W Y d }~n
d }~ww | d	 | g d
 d S )Nc                	   3   r6   r+   r   r   r   r   r   r   2  r7   z5TestPEP380Operation.test_delegating_throw.<locals>.g1c                	   3   rN   r.   r   r   r   r   r   r   :  rO   z5TestPEP380Operation.test_delegating_throw.<locals>.g2rP   r   tomato ejectedr   r$   r9   rQ   rC   r   r#   throwr   r&   r'   rY   r   r   r   test_delegating_throw-  s"   
z)TestPEP380Operation.test_delegating_throwc                    sR   	 g   fdd}t  }|| t d}|| d|_|| |  g d d S )Nc                    s,     d| jj| f    d| jf  d S )Nz%s: %sz
value = %s)r   	__class____name__value)r)   r   r   r   pexZ  s   zPTestPEP380Operation.test_value_attribute_of_StopIteration_exception.<locals>.pexspameggs)zStopIteration: zvalue = NoneStopIteration: spamzvalue = spamre   zvalue = eggs)rE   ra   r   )r   rb   r)   r   r   r   /test_value_attribute_of_StopIteration_exceptionU  s   zCTestPEP380Operation.test_value_attribute_of_StopIteration_exceptionc                    s,    fdd}dd  |  t| dg d S )Nc                   3         E d H  d S Nr   r   r   r   r   r   p     z:TestPEP380Operation.test_exception_value_crash.<locals>.g1c                   s   s    dV  dgS )Nr   r   r   r   r   r   r   r   r  s   z:TestPEP380Operation.test_exception_value_crash.<locals>.g2r   )r   list)r   r   r   ri   r   test_exception_value_crashm  s   z.TestPEP380Operation.test_exception_value_crashc                    sR   	 g  fdd}dfdd	 | D ]
} d|f  q| g d d S )Nc                  3   st     d dV    E d H }  d| f  ddtdfD ]} |E d H }  d| f  qdV   d d S )	Nr
   r,   zg2 returned %rr@   rP      r-   r   )r   rE   )retvr   r   r   r   }  s   
z;TestPEP380Operation.test_generator_return_value.<locals>.g1c                 3   s.      d dV  dV    d | r| S d S r.   r   rp   r   r   r   r     s   

z;TestPEP380Operation.test_generator_return_value.<locals>.g2r   )r
   r1   r   r2   r3   r   zg2 returned Noner   r2   r3   r   zg2 returned 1r   r2   r3   r   zg2 returned (2,)r   r2   r3   r   zg2 returned StopIteration(3)r4   r   rh   r   r   r   r   r   test_generator_return_valuex  s   

z/TestPEP380Operation.test_generator_return_valuec                 C   s>   	 g }dd }| D ]
}| d|f  q
| |g d d S )Nc                   s       t dE d H  d S Nrn   rQ   r   r   r   r   rF        zGTestPEP380Operation.test_delegation_of_next_to_non_generator.<locals>.gr   )	Yielded 0	Yielded 1	Yielded 2r   )r   r   rF   r   r   r   r   (test_delegation_of_next_to_non_generator  s   
z<TestPEP380Operation.test_delegation_of_next_to_non_generatorc                 C   sP   	 g }dd }| }t dD ]}|d }|d|f  q| |g d d S )Nc                   s   rs   rt   ru   r   r   r   r   rF     rv   zBTestPEP380Operation.test_conversion_of_sendNone_to_next.<locals>.grn   Yielded: %s)z
Yielded: 0z
Yielded: 1z
Yielded: 2)rQ   rD   r   r   )r   r   rF   gir   rG   r   r   r   #test_conversion_of_sendNone_to_next  s   
z7TestPEP380Operation.test_conversion_of_sendNone_to_nextc                    sr   	 g   fdd}| }t | t }|  W d    n1 s"w   Y  | | d |  ddg d S )Nc                	   3   B    z  d tdE d H    d W   d d S   d w N
starting grn   zg should not be herefinishing gr   rQ   r   r   r   r   rF        
zHTestPEP380Operation.test_delegation_of_close_to_non_generator.<locals>.g r   r   )rC   r   rR   r   getvalue)r   rF   r|   outputr   r   r   )test_delegation_of_close_to_non_generator  s   

z=TestPEP380Operation.test_delegation_of_close_to_non_generatorc              
      s   	 g   fdd}z!| }t dD ]}t|} d|f  qtd}|| W n tyE } z| |jd d W Y d }~n
d }~ww | d |  g d d S )	Nc                	   3   s8    z  d tdE d H  W   d d S   d w )N
Starting g
   Finishing gr   r   r   r   r   rF     s
   
zETestPEP380Operation.test_delegating_throw_to_non_generator.<locals>.g   r   r[   r   r$   )r   rw   rx   ry   z	Yielded 3z	Yielded 4r   r\   )r   rF   r|   rS   r   r)   r   r   r   &test_delegating_throw_to_non_generator  s    
z:TestPEP380Operation.test_delegating_throw_to_non_generatorc              
      s   	 g   fdd}z| }t | tdD ]}|d} d|f  qW n tyA } z| d|jd  W Y d }~n
d }~ww | d |  d	d
g d S )Nc                	   3   r~   r   r   r   r   r   r   rF     r   zGTestPEP380Operation.test_attempting_to_send_to_non_generator.<locals>.grn   r   zShould not have yielded: %srD   r   z#was able to send into non-generatorr   r   )	rC   rQ   rD   r   AttributeErrorZassertInr&   r'   r   )r   rF   r|   r   rG   r)   r   r   r   (test_attempting_to_send_to_non_generator  s&   


z<TestPEP380Operation.test_attempting_to_send_to_non_generatorc                    s  	 G dd d  fdd}|  t | }| t|d |d W d    n1 s.w   Y  |  t | }| t|d |t W d    n1 sSw   Y  t  }| }| t|d |	  | t|j
j W d    d S 1 sw   Y  d S )Nc                   @   s$   e Zd Zdd Zdd Zdd ZdS )z@TestPEP380Operation.test_broken_getattr_handling.<locals>.Brokenc                 S      | S rh   r   r   r   r   r   __iter__"     zITestPEP380Operation.test_broken_getattr_handling.<locals>.Broken.__iter__c                 S      dS )Nr@   r   r   r   r   r   __next__$  r   zITestPEP380Operation.test_broken_getattr_handling.<locals>.Broken.__next__c                 S   s   dd  d S Nr@   r   r   )r   attrr   r   r   __getattr__&  s   zLTestPEP380Operation.test_broken_getattr_handling.<locals>.Broken.__getattr__N)r`   
__module____qualname__r   r   r   r   r   r   r   Broken!  s    r   c                   3   rg   rh   r   r   r   r   r   rF   )  rj   z;TestPEP380Operation.test_broken_getattr_handling.<locals>.gr@   )rJ   ZeroDivisionErrorr   rC   rD   r]   r   r   Zcatch_unraisable_exceptionrR   Z
unraisableexc_type)r   rF   r|   cmr   r   r   test_broken_getattr_handling  s&   
"z0TestPEP380Operation.test_broken_getattr_handlingc                    sF   	 g fdd dd  fdd}|  t| | dg d S )Nc                   3   r   )Ng1 about to yield from g2g1 should not be herer   r   r   r   r   r   B  r   zCTestPEP380Operation.test_exception_in_initial_next_call.<locals>.g1c                   s   s    dd V  d S r   r   r   r   r   r   r   F     zCTestPEP380Operation.test_exception_in_initial_next_call.<locals>.g2c                     s     } t |  d S rh   )rC   )r|   r   r   r   rI   H  s   zDTestPEP380Operation.test_exception_in_initial_next_call.<locals>.runr   )rJ   r   r   rK   r   rL   r   #test_exception_in_initial_next_call=  s   
z7TestPEP380Operation.test_exception_in_initial_next_callc              
      s   	 g  fdd}fdd z| D ]
} d|f  qW n ty> } z| |jd d W Y d }~n
d }~ww | d | g d	 d S )
Nc                   3   s6     d dV   d   E d H   d d S )Ng1: startingZy1g1: about to yield from g2r   r   r   r   r   r   r   U  s   

z>TestPEP380Operation.test_attempted_yield_from_loop.<locals>.g1c                   3   s4     d dV   d  E d H   d d S )Ng2: startingZy2g2: about to yield from g1zg2 should not be herer   r   )r|   r   r   r   r   \  s   


z>TestPEP380Operation.test_attempted_yield_from_loop.<locals>.g2r{   r   zgenerator already executingz$subgenerator didn't raise ValueError)r   zYielded: y1r   r   zYielded: y2r   r%   )r   r   rG   r)   r   )r   r|   r   r   test_attempted_yield_from_loopP  s   
z2TestPEP380Operation.test_attempted_yield_from_loopc                    s   	 g fdd} fddG dd dt  | }tdD ]}t|}d|f  q  d	}|| |D ]
}d|f  q:| g d
 d S )Nc                	   3   r6   r+   r   r   r   r   r   r   x  r7   zITestPEP380Operation.test_returning_value_from_delegated_throw.<locals>.g1c                   3   sJ    z d dV  dV  W d S   y$    d dV  dV  Y d S w )Nr   r/   r0   Caught LunchError in g2zg2 lunch savedzg2 yet more spamr   r   )
LunchErrorr   r   r   r     s   

zITestPEP380Operation.test_returning_value_from_delegated_throw.<locals>.g2c                   @      e Zd ZdS )zQTestPEP380Operation.test_returning_value_from_delegated_throw.<locals>.LunchErrorNr`   r   r   r   r   r   r   r         r   rP   r   r[   )r
   r1   r   r2   r   zYielded g2 yet more spamr4   r   )	ExceptionrQ   rC   r   r]   r   rY   r   )r   r   r   r   )test_returning_value_from_delegated_throws  s   	
z=TestPEP380Operation.test_returning_value_from_delegated_throwc                    X   	 g  fdd}fdd |d  |d |d |t d | g d d S )	Nc              
      sj    | }t | zd t | d W d S  ty4 } zd|f  W Y d }~d S d }~ww )Nf resuming gf SHOULD NOT BE HEREf caught %r)rC   r   rE   rr|   r)   rF   r   r   r   f  s   
z>TestPEP380Operation.test_next_and_return_with_value.<locals>.fc                 3   s&      d d V    d| f  | S )N
g startingg returning %rr   )r   r   r   r   rF     s
   
z>TestPEP380Operation.test_next_and_return_with_value.<locals>.gr@   rm   rn   )r   r   g returning Nonef caught StopIteration()r   r   g returning 1f caught StopIteration(1)r   r   g returning (2,)f caught StopIteration((2,))r   r   g returning StopIteration(3)(f caught StopIteration(StopIteration(3))rE   r   r   r   r   r   r   test_next_and_return_with_value  s   	z3TestPEP380Operation.test_next_and_return_with_valuec                    r   )	Nc              
      sl    | }t | zd |d d W d S  ty5 } zd|f  W Y d }~d S d }~ww )Nf sending spam to grc   r   r   )rC   r   rD   rE   r   r   r   r   r     s   

z>TestPEP380Operation.test_send_and_return_with_value.<locals>.fc                 3   s6      d d V }  d|f    d| f  | S )Nr   zg received %rr   r   )r   r   r   r   r   rF     s   
z>TestPEP380Operation.test_send_and_return_with_value.<locals>.gr@   rm   rn   )r   r   g received 'spam'r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   test_send_and_return_with_value  s   	z3TestPEP380Operation.test_send_and_return_with_valuec              	      s   	 fdd  fdd}ddt dfD ]'g | }t| t|t | ddd	f tg qd S )
Nc                   3   s.    zdV  W S  t y    d Y S w )Nr@   inner caught ValueError)r#   r   r   )r   ra   r   r   inner  s   zTTestPEP380Operation.test_catching_exception_from_subgen_and_returning.<locals>.innerc                  3   s(      E d H }  d| f  | V  d S )Ninner returned %r to outerr   rq   )r   r   r   r   outer  s   
zTTestPEP380Operation.test_catching_exception_from_subgen_and_returning.<locals>.outerrP   rm   r@   r   r   )rE   r   rC   reprr]   r#   r   r   r   rF   r   )r   r   ra   r   1test_catching_exception_from_subgen_and_returning  s   zETestPEP380Operation.test_catching_exception_from_subgen_and_returningc                    sn   	 g fdd  fdd}z| }t | |t W n	 ty'   Y nw | d | ddg d S )Nc                   3   s8    z  d d V    d W d S  ty   Y d S w NEnter fExit fr   rX   r   r   r   r   r     s   
zSTestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_returns.<locals>.fc                   3   r   NEnter gzExit gr   r   r   r   r   r   rF   !  r   zSTestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_returns.<locals>.g*subgenerator failed to raise GeneratorExitr   r   )rC   r]   rX   r'   r   )r   rF   r|   r   r   r   4test_throwing_GeneratorExit_into_subgen_that_returns  s    

zHTestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_returnsc              
      s   	 g fdd  fdd}z| }t | |t W n ty9 } z| |jd d W Y d }~n
d }~ww | d | dd	g d S )
Nc                   3   s>    z  d d V    d W d S  ty   d V  Y d S w r   r   r   r   r   r   r   8  s   
zXTestPEP380Operation.test_throwing_GeneratorExit_into_subgenerator_that_yields.<locals>.fc                   3   r   r   r   r   r   r   r   rF   ?  r   zXTestPEP380Operation.test_throwing_GeneratorExit_into_subgenerator_that_yields.<locals>.gr   zgenerator ignored GeneratorExitr   r   r   )rC   r]   rX   RuntimeErrorr   r&   r'   r   rF   r|   r)   r   r   r   9test_throwing_GeneratorExit_into_subgenerator_that_yields2  s"   

zMTestPEP380Operation.test_throwing_GeneratorExit_into_subgenerator_that_yieldsc              
      s   	 g fdd  fdd}z| }t | |t W n" ty@ } z| |jd d | |jt W Y d }~n
d }~ww | d | dd	g d S )
Nc                   3   s:    z  d d V    d W d S  ty   tdw )Nr   r   Vorpal bunny encountered)r   rX   r#   r   r   r   r   r   V  s   
zRTestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_raises.<locals>.fc                   3   r   r   r   r   r   r   r   rF   ]  r   zRTestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_raises.<locals>.gr   r   r$   r   r   )	rC   r]   rX   r#   r   r&   rV   rW   r'   r   r   r   r   3test_throwing_GeneratorExit_into_subgen_that_raisesP  s$   

zGTestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_raisesc                 C   s   dd }|  tt|  d S )Nc                   s   s    dE d H  d S )Nr   r   r   r   r   r   rF   p  r   z4TestPEP380Operation.test_yield_from_empty.<locals>.g)rJ   rE   rC   )r   rF   r   r   r   test_yield_from_emptyo  s   z)TestPEP380Operation.test_yield_from_emptyc                    s0  fdd}fdd|  tg d | tg}z
	 |d q# ty4   Y nw  |g d G dd	 d	t  fd
d} fdd| tg}z
	 |  q] tyn   Y n    |g d  G fdddtfdd}| t 	  d S )Nc                   3   s    dV    E d H  dV  d S Nr   rn   r   r   )twor   r   onev  s   
zOTestPEP380Operation.test_delegating_generators_claim_to_be_running.<locals>.onec                   3   s4    dV  z E d H  W n	 t y   Y nw dV  d S Nr@   rP   r#   r   r   r   r   r   z  s   
zOTestPEP380Operation.test_delegating_generators_claim_to_be_running.<locals>.two)r   r@   rP   rn   Tr   c                   @   r   )zQTestPEP380Operation.test_delegating_generators_claim_to_be_running.<locals>.MyErrNr   r   r   r   r   MyErr  r   r   c                   3   sN    zdV  W n	  y   Y nw  E d H  zdV  W d S   y&   Y d S w r   r   r   )r   r   r   r   r     s   
c                   3   sd    zdV  W n	  y   Y nw zE d H  W n	 t y    Y nw zdV  W d S   y1   Y d S w r   r   r   )r   r   r   r   r     s    
c                       s*   e Zd Zdd Zdd Z fddZdS )zPTestPEP380Operation.test_delegating_generators_claim_to_be_running.<locals>.MyItc                 S   r   rh   r   r   r   r   r   r     r   zYTestPEP380Operation.test_delegating_generators_claim_to_be_running.<locals>.MyIt.__iter__c                 S   r   Nr   r   r   r   r   r   r     r   zYTestPEP380Operation.test_delegating_generators_claim_to_be_running.<locals>.MyIt.__next__c                    s     j tt  d S rh   )
assertTrue
gi_runningrJ   r#   rC   )Zself_r   r   r   r   rR     s   zVTestPEP380Operation.test_delegating_generators_claim_to_be_running.<locals>.MyIt.closeN)r`   r   r   r   r   rR   r   r   r   r   MyIt  s    r   c                   3   rg   rh   r   r   )r   r   r   r     rj   )
r   rk   rC   r   rD   rE   r   r]   objectrR   )r   r   resr   )r   r   r   r   r   r   .test_delegating_generators_claim_to_be_runningt  sB   


zBTestPEP380Operation.test_delegating_generators_claim_to_be_runningc                    sp   dd   fdd}dd }dd }|| D ]	}|  d	|v  q||| D ]}|  d	|v o3d
|v  q(d S )Nc                   S   s   dd t  D S )Nc                 S   s   g | ]}|d  qS )rn   r   ).0r   r   r   r   
<listcomp>  s    zaTestPEP380Operation.test_delegator_is_visible_to_debugger.<locals>.call_stack.<locals>.<listcomp>)inspectstackr   r   r   r   
call_stack  s   zMTestPEP380Operation.test_delegator_is_visible_to_debugger.<locals>.call_stackc                   3   s      V    V    V  d S rh   r   r   r   r   r   gen  s   zFTestPEP380Operation.test_delegator_is_visible_to_debugger.<locals>.genc                 s       | E d H  d S rh   r   rF   r   r   r   rc     r   zGTestPEP380Operation.test_delegator_is_visible_to_debugger.<locals>.spamc                 s   r   rh   r   r   r   r   r   rd     r   zGTestPEP380Operation.test_delegator_is_visible_to_debugger.<locals>.eggsrc   rd   )r   )r   r   rc   rd   r   r   r   r   %test_delegator_is_visible_to_debugger  s   z9TestPEP380Operation.test_delegator_is_visible_to_debuggerc                    s:   G dd d  fdd}d t |  | d d S )Nc                   @   s   e Zd Zdd Zdd ZdS )z?TestPEP380Operation.test_custom_iterator_return.<locals>.MyIterc                 S   r   rh   r   r   r   r   r   r     r   zHTestPEP380Operation.test_custom_iterator_return.<locals>.MyIter.__iter__c                 S   s   t dr   )rE   r   r   r   r   r     s   zHTestPEP380Operation.test_custom_iterator_return.<locals>.MyIter.__next__N)r`   r   r   r   r   r   r   r   r   MyIter  s    r   c                   3   s      E d H d S rh   r   r   r   ro   r   r   r     s   z<TestPEP380Operation.test_custom_iterator_return.<locals>.genr   )rk   r   )r   r   r   r   r   test_custom_iterator_return  s
   
z/TestPEP380Operation.test_custom_iterator_returnc                    s|   dd   fdd}dd }t  # | }| }|d  || || ~~t  W d    d S 1 s7w   Y  d S )Nc                   s   s    d V  d S rh   r   r   r   r   r   	innermost  s   
zDTestPEP380Operation.test_close_with_cleared_frame.<locals>.innermostc                  3   s    d V }   E d H  d S rh   r   )	outer_genr   r   r   r     s   z@TestPEP380Operation.test_close_with_cleared_frame.<locals>.innerc                  s   s    d V } | E d H  d S rh   r   )	inner_genr   r   r   r     s   z@TestPEP380Operation.test_close_with_cleared_frame.<locals>.outer)r   rD   r   )r   r   r   r   r   r   r   r   test_close_with_cleared_frame  s   


"z1TestPEP380Operation.test_close_with_cleared_framec                    sJ   G fddd  fdd}| }t | d |d | d d S )Nc                       s(   e Zd Zdd Zdd Z fddZdS )zHTestPEP380Operation.test_send_tuple_with_custom_generator.<locals>.MyGenc                 S   r   rh   r   r   r   r   r   r     r   zQTestPEP380Operation.test_send_tuple_with_custom_generator.<locals>.MyGen.__iter__c                 S   r   r   r   r   r   r   r   r     r   zQTestPEP380Operation.test_send_tuple_with_custom_generator.<locals>.MyGen.__next__c                    s   | d S rh   r   )r   Zwhatrq   r   r   rD     s   zMTestPEP380Operation.test_send_tuple_with_custom_generator.<locals>.MyGen.sendN)r`   r   r   r   r   rD   r   rq   r   r   MyGen  s    r   c                  3   s      E d H } d S rh   r   rq   )r   r   r   r     rj   zHTestPEP380Operation.test_send_tuple_with_custom_generator.<locals>.outer)r@   rP   rn      )rC   rD   r   r   r   )r   rp   r   %test_send_tuple_with_custom_generator	  s   	
z9TestPEP380Operation.test_send_tuple_with_custom_generatorN)$r`   r   r   r   r*   r5   r:   rH   rM   rT   rZ   r^   rf   rl   rr   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r      sF    %,)")(3  #+*/K'r   __main__)Zunittestr   Ztest.supportr   r   r   testr   ZTestCaser   r`   mainr   r   r   r   <module>   s"           