
    0hhu                         S r SSKrSSKrSSKJrJrJr  SSKJr   " S S\R                  5      r
 " S S\R                  5      r\S	:X  a  \R                  " 5         gg)
z
Test suite for PEP 380 implementation

adapted from original tests written by Greg Ewing
see <http://www.cosc.canterbury.ac.nz/greg.ewing/python/yield-from/YieldFrom-Python3.1.2-rev5.zip>
    N)captured_stderr
disable_gc
gc_collect)supportc                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$ r&S% r'S&r(g')(TestPEP380Operation   z
Test semantics.
c                    ^^ / mUU4S jnU4S jmU" 5        H  nTR                  SU< 35        M     U R                  T/ SQ5        g)z8
Test delegation of initial next() call to subgenerator
c               3   t   >#    TR                  S5        T " 5        S h  vN   TR                  S5        g  N7fNStarting g1Finishing g1appendg2traces   =/opt/python-3.13.8/usr/lib/python3.13/test/test_yield_from.pyg1OTestPEP380Operation.test_delegation_of_initial_next_to_subgenerator.<locals>.g1   s,     LL'tOOLL(    868c               3   Z   >#    T R                  S5        Sv   T R                  S5        g 7f)NStarting g2*   Finishing g2r   r   s   r   r   OTestPEP380Operation.test_delegation_of_initial_next_to_subgenerator.<locals>.g2   s#     LL'HLL(s   (+Yielded )r   r   z
Yielded 42r   r   Nr   assertEqualselfr   xr   r   s      @@r   /test_delegation_of_initial_next_to_subgeneratorCTestPEP380Operation.test_delegation_of_initial_next_to_subgenerator   sF     	)	) ALL,-   
 	    c                 $  ^^ / mUU4S jnU4S jm U" 5        H  nTR                  SU< 35        M     U R                  S5        U R                  T/ SQ5        g! [         a)  nU R                  UR                  S   S5         SnANCSnAff = f)	z/
Test raising exception in initial next() call
c               3      >#     TR                  S5        T " 5        S h  vN   TR                  S5        g  N! TR                  S5        f = f7fr   r   r   s   r   r   KTestPEP380Operation.test_raising_exception_in_initial_next_call.<locals>.g11   s>     -]+4^,  ^,s%   A9 79 A9 AAc                  j   >  T R                  S5        [        S5      e! T R                  S5        f = f)Nr   spanish inquisition occurredr   r   
ValueErrorr   s   r   r   KTestPEP380Operation.test_raising_exception_in_initial_next_call.<locals>.g27   s.    -]+ !?@@^,s    2r   'subgenerator failed to raise ValueErrorr   r+   N)r   r   r   r   r   failr-   r    argsr"   r   r#   er   r   s       @@r   +test_raising_exception_in_initial_next_call?TestPEP380Operation.test_raising_exception_in_initial_next_call,   s     	-	-	ATQ01 
 II?@  
 		  	HQVVAY(FGG	H   #A 
B&B

Bc                    ^^ / mUU4S jnU4S jmU" 5        H  nTR                  SU< 35        M     U R                  T/ SQ5        g)z0
Test delegation of next() call to subgenerator
c               3      >#    TR                  S5        Sv   T " 5        S h  vN   Sv   TR                  S5        g  N7fNr   g1 hamg1 eggsr   r   r   s   r   r   LTestPEP380Operation.test_delegation_of_next_call_to_subgenerator.<locals>.g1P   s6     LL'NtOOOLL( s    A >A c               3   b   >#    T R                  S5        Sv   Sv   T R                  S5        g 7fNr   g2 spamg2 more spamr   r   r   s   r   r   LTestPEP380Operation.test_delegation_of_next_call_to_subgenerator.<locals>.g2V   s)     LL'O  LL(s   ,/r   )r   Yielded g1 hamr   Yielded g2 spamYielded g2 more spamr   Yielded g1 eggsr   Nr   r!   s      @@r   ,test_delegation_of_next_call_to_subgenerator@TestPEP380Operation.test_delegation_of_next_call_to_subgeneratorK   sF     	)	)
 ALL,-  	 
 		r&   c                 $  ^^ / mUU4S jnU4S jm U" 5        H  nTR                  SU< 35        M     U R                  S5        U R                  T/ SQ5        g! [         a)  nU R                  UR                  S   S5         SnANCSnAff = f)	z1
Test raising exception in delegated next() call
c               3      >#     TR                  S5        Sv   T " 5        S h  vN   Sv   TR                  S5        g  N! TR                  S5        f = f7fr:   r   r   s   r   r   MTestPEP380Operation.test_raising_exception_in_delegated_next_call.<locals>.g1m   J     -]+4^,   ^,)   AA ?A AA AAc               3   z   >#     T R                  S5        Sv   [        S5      e! T R                  S5        f = f7f)Nr   r@   hovercraft is full of eelsr   r,   r   s   r   r   MTestPEP380Operation.test_raising_exception_in_delegated_next_call.<locals>.g2u   s7     -]+ !=>> ^,s   ; % 8;r   r/   r   rO   Nr   rC   r   rD   r   r   r0   r3   s       @@r   -test_raising_exception_in_delegated_next_callATestPEP380Operation.test_raising_exception_in_delegated_next_callh   s     	-	-	ATQ01 
 II?@  
 		  	FQVVAY(DEE	Fr7   c                    ^^ / mUU4S jnU4S jmU" 5       n[        U5      nSn  UR                  U5      nTR                  SU< 35        US-  nM-  ! [         a     Of = fU R	                  T/ SQ5        g)z
Test delegation of send()
c               3      >#    TR                  S5        Sv n TR                  SU < 35        T" 5        S h  vN   Sv n TR                  SU < 35        TR                  S5        g  N/7fNr   r;   zg1 received r<   r   r   r#   r   r   s    r   r   7TestPEP380Operation.test_delegation_of_send.<locals>.g1   X     LL'ALLQ01tOOALLQ01LL(    5A*A(0A*c               3      >#    TR                  S5        Sv n TR                  SU < 35        Sv n TR                  SU < 35        TR                  S5        g 7f)Nr   r@   g2 received rA   r   r   r#   r   s    r   r   7TestPEP380Operation.test_delegation_of_send.<locals>.g2   sK     LL'ALLQ01$$ALLQ01LL(s   AA   r   )r   g1 received 1r   rD   g2 received 2rE   zg2 received 3r   rF   zg1 received 4r   N)nextsendr   StopIterationr    )r"   r   gyr#   r   r   s        @@r   test_delegation_of_send+TestPEP380Operation.test_delegation_of_send   s     	)	) DG	FF1IQ01Q   		  
 	s   .A 
A"!A"c                    ^^^ / mUU4S jmU4S jmUU4S jnU R                  [        U5        U R                  T/ SQ5        g)z1
Test handling exception while delegating 'send'
c               3      >#    TR                  S5        Sv n TR                  SU < 35        T" 5        S h  vN   Sv n TR                  SU < 35        TR                  S5        g  N/7frV   r   rW   s    r   r   MTestPEP380Operation.test_handling_exception_while_delegating_send.<locals>.g1   rY   rZ   c               3   v   >#    TR                  S5        Sv n TR                  SU < 35        [        S5      e7f)Nr   r@   r\   rO   r,   r]   s    r   r   MTestPEP380Operation.test_handling_exception_while_delegating_send.<locals>.g2   s4     LL'ALLQ019::s   69c                     > T" 5       n [        U 5      nSn  U R                  U5      nTR                  SU< 35        US-  nM-  ! [         a    TR                  S5         g f = f)Nr_   r   rd   )rb   rc   r   rd   )re   rf   r#   r   r   s      r   runNTestPEP380Operation.test_handling_exception_while_delegating_send.<locals>.run   sg    AQAA.q	ALL!45FA  ! ._-.s   .A A#"A#)r   r`   r   rD   ra   N)assertRaisesr-   r    r"   ro   r   r   r   s     @@@r   -test_handling_exception_while_delegating_sendATestPEP380Operation.test_handling_exception_while_delegating_send   s@     	)	)
	. 	*S)  
 	r&   c                    ^^ / mUU4S jnU4S jmU" 5       n[        S5       H#  n[        U5      nTR                  SU< 35        M%     UR                  5         U R	                  T/ SQ5        g)z
Test delegating 'close'
c               3      >#     TR                  S5        Sv   T " 5        S h  vN   Sv   TR                  S5        g  N! TR                  S5        f = f7fr:   r   r   s   r   r   5TestPEP380Operation.test_delegating_close.<locals>.g1   rL   rM   c               3      >#     T R                  S5        Sv   Sv   T R                  S5        g ! T R                  S5        f = f7fr?   r   r   s   r   r   5TestPEP380Operation.test_delegating_close.<locals>.g2   :     -]+$$^,^,   A0 AAA   r   rQ   N)rangerb   r   closer    )r"   r   re   ir#   r   r   s        @@r   test_delegating_close)TestPEP380Operation.test_delegating_close   sc     	-	- DqAQALL,-  	
	  
 	r&   c                   ^^ / mUU4S jnU4S jm U" 5       n[        S5       H#  n[        U5      nTR                  SU< 35        M%     UR                  5         U R	                  S5        U R                  T/ S	Q5        g! [
         aI  nU R                  UR                  S   S5        U R                  UR                  [        5         SnANcSnAff = f)
z2
Test handling exception while delegating 'close'
c               3      >#     TR                  S5        Sv   T " 5        S h  vN   Sv   TR                  S5        g  N! TR                  S5        f = f7fr:   r   r   s   r   r   MTestPEP380Operation.test_handing_exception_while_delegating_close.<locals>.g1	  rL   rM   c               3      >#     T R                  S5        Sv   Sv   T R                  S5        [        S5      e! T R                  S5        [        S5      e= f7f)Nr   r@   rA   r   "nybbles have exploded with delightr,   r   s   r   r   MTestPEP380Operation.test_handing_exception_while_delegating_close.<locals>.g2  sV     G]+$$^, !EFF ^, !EFFs   A: AAAr|   r   r/   r   r   NrQ   )r}   rb   r   r~   r1   r-   r    r2   assertIsInstance__context__GeneratorExitr"   r   re   r   r#   r4   r   r   s         @@r   -test_handing_exception_while_delegating_closeATestPEP380Operation.test_handing_exception_while_delegating_close  s     	-	G
	AA1XGQ01  GGI
 II?@  
 	  	@QVVAY(LM!!!--??	@s   A	B 
C?CCc                   ^^ / mUU4S jnU4S jm U" 5       n[        S5       H#  n[        U5      nTR                  SU< 35        M%     [        S5      nUR	                  U5        U R                  S5        U R                  T/ S	Q5        g! [         a)  nU R                  UR                  S   S5         SnANCSnAff = f)
z
Test delegating 'throw'
c               3      >#     TR                  S5        Sv   T " 5        S h  vN   Sv   TR                  S5        g  N! TR                  S5        f = f7fr:   r   r   s   r   r   5TestPEP380Operation.test_delegating_throw.<locals>.g12  rL   rM   c               3      >#     T R                  S5        Sv   Sv   T R                  S5        g ! T R                  S5        f = f7fr?   r   r   s   r   r   5TestPEP380Operation.test_delegating_throw.<locals>.g2:  rz   r{   r|   r   tomato ejectedr/   r   NrQ   r}   rb   r   r-   throwr1   r    r2   r   s         @@r   test_delegating_throw)TestPEP380Operation.test_delegating_throw-  s     	-	-
	AA1XGQ01  +,AGGAJ II?@  
 		  	:QVVAY(899	:s   AB 
CB<<Cc                    ^ / mU4S jn[        5       nU" U5        [        S5      nU" U5        SUl        U" U5        U R                  T/ SQ5        g)z3
Test 'value' attribute of StopIteration exception
c                    > TR                  U R                  R                  < SU < 35        TR                  SU R                  < 35        g )Nz: zvalue = )r   	__class____name__value)r4   r   s    r   pexPTestPEP380Operation.test_value_attribute_of_StopIteration_exception.<locals>.pexZ  s1    LLQ[[%9%91=>LL23r&   spameggs)zStopIteration: zvalue = NoneStopIteration: spamzvalue = spamr   zvalue = eggsN)rd   r   r    )r"   r   r4   r   s      @r   /test_value_attribute_of_StopIteration_exceptionCTestPEP380Operation.test_value_attribute_of_StopIteration_exceptionU  sS     	4 OA&!AA  
 	r&   c                 Z   ^ U4S jnS mU R                  [        U" 5       5      S/5        g )Nc               3   0   >#    T " 5        S h  vN   g  N7fN )r   s   r   r   :TestPEP380Operation.test_exception_value_crash.<locals>.g1p  s     tOO   c               3      #    Sv   S/$ 7f)Nr   r   r   r   r&   r   r   :TestPEP380Operation.test_exception_value_crash.<locals>.g2r  s     J4Ks   
r   )r    list)r"   r   r   s     @r   test_exception_value_crash.TestPEP380Operation.test_exception_value_crashm  s'    		 	bddV,r&   c                    ^^ / mUU4S jnSU4S jjmU" 5        H  nTR                  SU< 35        M     U R                  T/ SQ5        g)z
Test generator return value
c               3   &  >#    TR                  S5        Sv   T" 5        S h  vN n TR                  SU < 35        SS[        S5      4 H(  nT" U5       S h  vN n TR                  SU < 35        M*     Sv   TR                  S5        g  Ni N57f)	Nr   r;   zg2 returned r_   r|      r<   r   )r   rd   )retvr   r   s     r   r   ;TestPEP380Operation.test_generator_return_value.<locals>.g1}  s}     LL'NT/CLLS23mA..!#A&67 / OLL( " 's!    BB5BB4BBNc              3   t   >#    TR                  S5        Sv   Sv   TR                  S5        U (       a  U $ g 7fr?   r   )r   r   s    r   r   ;TestPEP380Operation.test_generator_return_value.<locals>.g2  s6     LL'O  LL( s   58r   )r   rC   r   rD   rE   r   zg2 returned Noner   rD   rE   r   zg2 returned 1r   rD   rE   r   zg2 returned (2,)r   rD   rE   r   zg2 returned StopIteration(3)rF   r   r   r   r!   s      @@r   test_generator_return_value/TestPEP380Operation.test_generator_return_valuex  sF     		)	 ALL,-   
 	r&   c                 |    / nS nU" 5        H  nUR                  SU< 35        M     U R                  U/ SQ5        g)z,
Test delegation of next() to non-generator
c               3   6   #    [        S5       S h  vN   g  N7fNr   r}   r   r&   r   re   GTestPEP380Operation.test_delegation_of_next_to_non_generator.<locals>.g       Qx   r   )	Yielded 0	Yielded 1	Yielded 2Nr   )r"   r   re   r#   s       r   (test_delegation_of_next_to_non_generator<TestPEP380Operation.test_delegation_of_next_to_non_generator  s>     	 ALL,-   
 	r&   c                     / nS nU" 5       n[        S5       H)  nUR                  S5      nUR                  SU< 35        M+     U R                  U/ SQ5        g)z)
Test conversion of send(None) to next()
c               3   6   #    [        S5       S h  vN   g  N7fr   r   r   r&   r   re   BTestPEP380Operation.test_conversion_of_sendNone_to_next.<locals>.g  r   r   r   N	Yielded: )z
Yielded: 0z
Yielded: 1z
Yielded: 2)r}   rc   r   r    )r"   r   re   gir#   rf   s         r   #test_conversion_of_sendNone_to_next7TestPEP380Operation.test_conversion_of_sendNone_to_next  sV     	 SqAALL!-.  	  
 	r&   c                 
  ^ / mU4S jnU" 5       n[        U5        [        5        nUR                  5         SSS5        U R                  WR	                  5       S5        U R                  TSS/5        g! , (       d  f       NC= f)z-
Test delegation of close() to non-generator
c               3      >#     T R                  S5        [        S5       S h  vN   T R                  S5        T R                  S5        g  N'! T R                  S5        f = f7fN
starting gr   zg should not be herefinishing gr   r}   r   s   r   re   HTestPEP380Operation.test_delegation_of_close_to_non_generator.<locals>.g  Q     ,\* 8##34]+ $ ]++   A$A AA A$A A!!A$N r   r   )rb   r   r~   r    getvalue)r"   re   r   outputr   s       @r   )test_delegation_of_close_to_non_generator=TestPEP380Operation.test_delegation_of_close_to_non_generator  sp     	, SR&HHJ *B/ 
 	 s   A44
Bc                 x  ^ / mU4S jn U" 5       n[        S5       H#  n[        U5      nTR                  SU< 35        M%     [        S5      nUR	                  U5        U R                  S5        U R                  T/ SQ5        g! [         a)  nU R                  UR                  S   S5         SnANCSnAff = f)	z*
Test delegating 'throw' to non-generator
c               3      >#     T R                  S5        [        S5       S h  vN   T R                  S5        g  N! T R                  S5        f = f7f)N
Starting g
   Finishing gr   r   s   r   re   ETestPEP380Operation.test_delegating_throw_to_non_generator.<locals>.g  sB     ,\* 9$$]+ %]+s%   A= ;= A= AA   r   r   r/   r   N)r   r   r   r   z	Yielded 3z	Yielded 4r   r   )r"   re   r   r   r#   r4   r   s         @r   &test_delegating_throw_to_non_generator:TestPEP380Operation.test_delegating_throw_to_non_generator  s     	,
	AB1XHQ01  +,AHHQK II?@  
 		  	9QVVAY'788	9s   AB 
B9B44B9c                 b  ^ / mU4S jn U" 5       n[        U5        [        S5       H)  nUR                  S5      nTR                  SU< 35        M+     U R	                  S5        U R                  TS	S
/5        g! [
         a)  nU R                  SUR                  S   5         SnANCSnAff = f)z*
Test attempting to send to non-generator
c               3      >#     T R                  S5        [        S5       S h  vN   T R                  S5        T R                  S5        g  N'! T R                  S5        f = f7fr   r   r   s   r   re   GTestPEP380Operation.test_attempting_to_send_to_non_generator.<locals>.g  r   r   r   r   zShould not have yielded: z#was able to send into non-generatorrc   r   Nr   r   )	rb   r}   rc   r   r1   AttributeErrorassertInr2   r    )r"   re   r   r#   rf   r4   r   s         @r   (test_attempting_to_send_to_non_generator<TestPEP380Operation.test_attempting_to_send_to_non_generator  s     	,		=BH1XGGBKaAB  II;< 
 		  	-MM&!&&),,	-s   A
A; ;
B.B))B.c                   ^  " S S5      mU4S jnU R                  [        5         U" 5       nU R                  [        U5      S5        UR	                  S5        SSS5        U R                  [        5         U" 5       nU R                  [        U5      S5        UR                  [        5        SSS5        [        R                  " 5        nU" 5       nU R                  [        U5      S5        UR                  5         U R                  [        UR                  R                  5        SSS5        g! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g= f)z7
Test subiterator with a broken getattr implementation
c                   &    \ rS rSrS rS rS rSrg)@TestPEP380Operation.test_broken_getattr_handling.<locals>.Brokeni!  c                     U $ r   r   r"   s    r   __iter__ITestPEP380Operation.test_broken_getattr_handling.<locals>.Broken.__iter__"      r&   c                     g)Nr_   r   r   s    r   __next__ITestPEP380Operation.test_broken_getattr_handling.<locals>.Broken.__next__$  s    r&   c                     SS-    g Nr_   r   r   )r"   attrs     r   __getattr__LTestPEP380Operation.test_broken_getattr_handling.<locals>.Broken.__getattr__&  s	    !r&   r   N)r   
__module____qualname____firstlineno__r   r   r   __static_attributes__r   r&   r   Brokenr   !  s    r&   r   c               3   0   >#    T " 5        S h  vN   g  N7fr   r   )r   s   r   re   ;TestPEP380Operation.test_broken_getattr_handling.<locals>.g)  s     xr   r_   N)rq   ZeroDivisionErrorr    rb   rc   r   r   r   catch_unraisable_exceptionr~   
unraisableexc_type)r"   re   r   cmr   s       @r   test_broken_getattr_handling0TestPEP380Operation.test_broken_getattr_handling  s    	 		  01BT"Xq)GGAJ 2
 01BT"Xq)HH^$ 2
 //1RBT"Xq)HHJ.0F0FG 21 21
 21
 21s$   4D388EAE3
E
E
E#c                    ^^^ / mUU4S jmS mU4S jnU R                  [        U5        U R                  TS/5        g)z'
Test exception in initial next() call
c               3   t   >#    TR                  S5        T " 5        S h  vN   TR                  S5        g  N7f)Ng1 about to yield from g2g1 should not be herer   r   s   r   r   CTestPEP380Operation.test_exception_in_initial_next_call.<locals>.g1B  s.     LL45tOOLL01 r   c               3      #    SS-  v   g 7fr   r   r   r&   r   r   CTestPEP380Operation.test_exception_in_initial_next_call.<locals>.g2F  s     A#Is   	c                  *   > T" 5       n [        U 5        g r   )rb   )r   r   s    r   ro   DTestPEP380Operation.test_exception_in_initial_next_call.<locals>.runH  s    BHr&   r  N)rq   r  r    rr   s     @@@r   #test_exception_in_initial_next_call7TestPEP380Operation.test_exception_in_initial_next_call=  sD     	2		 	+C0' 
 	r&   c                 ,  ^^^ / mUU4S jnUU4S jm U" 5       mT H  nTR                  SU< 35        M     U R                  S5        U R                  T/ SQ5        g! [         a)  nU R                  UR                  S   S5         SnANCSnAff = f)	z 
Test attempted yield-from loop
c               3      >#    TR                  S5        Sv   TR                  S5        T " 5        S h  vN   TR                  S5        g  N7f)Ng1: startingy1g1: about to yield from g2r  r   r   s   r   r   >TestPEP380Operation.test_attempted_yield_from_loop.<locals>.g1U  s?     LL(JLL56tOOLL01 s   1AAAc               3      >#    TR                  S5        Sv   TR                  S5        T  S h  vN   TR                  S5        g  N7f)Ng2: startingy2g2: about to yield from g1zg2 should not be herer   )r   r   s   r   r   >TestPEP380Operation.test_attempted_yield_from_loop.<locals>.g2\  s=     LL(JLL56MMLL01 s   ,AAAr   z$subgenerator didn't raise ValueErrorr   zgenerator already executingN)r  zYielded: y1r  r  zYielded: y2r  r0   )r"   r   rf   r4   r   r   r   s       @@@r   test_attempted_yield_from_loop2TestPEP380Operation.test_attempted_yield_from_loopP  s     	2	2	>Ba12 
 II<=  
 		  	FQVVAY'DEE	Fs   %A   
B*BBc                 P  ^^^ / mUU4S jnUU4S jm " S S[         5      mU" 5       n[        S5       H#  n[        U5      nTR                  SU< 35        M%     T" S5      nUR	                  U5        U H  nTR                  SU< 35        M     U R                  T/ SQ5        g	)
z-
Test returning value from delegated 'throw'
c               3      >#     TR                  S5        Sv   T " 5        S h  vN   Sv   TR                  S5        g  N! TR                  S5        f = f7fr:   r   r   s   r   r   ITestPEP380Operation.test_returning_value_from_delegated_throw.<locals>.g1x  rL   rM   c               3      >#     TR                  S5        Sv   Sv   g ! T  a    TR                  S5        Sv   Sv    g f = f7f)Nr   r@   rA   Caught LunchError in g2zg2 lunch savedzg2 yet more spamr   )
LunchErrorr   s   r   r   ITestPEP380Operation.test_returning_value_from_delegated_throw.<locals>.g2  sI     )]+$$ )67&&(()s$   A AAA AAc                       \ rS rSrSrg)QTestPEP380Operation.test_returning_value_from_delegated_throw.<locals>.LunchErrori  r   Nr   r   r   r   r   r   r&   r   r&  r)        r&   r&  r|   r   r   )r   rC   r   rD   r%  zYielded g2 yet more spamrF   r   N)	Exceptionr}   rb   r   r   r    )	r"   r   re   r   r#   r4   r&  r   r   s	         @@@r   )test_returning_value_from_delegated_throw=TestPEP380Operation.test_returning_value_from_delegated_throws  s     	-	)	 	DqAQALL,-  '(	
ALL,-  	 
 		r&   c                    ^^ / mUU4S jnU4S jmU" S5        U" S5        U" S5        U" [        S5      5        U R                  T/ SQ5        g)z!
Test next and return with value
c                    > T" U 5      n[        U5         TR                  S5        [        U5        TR                  S5        g ! [         a  nTR                  SU< 35         S nAg S nAff = f)Nf resuming gf SHOULD NOT BE HERE	f caught )rb   r   rd   rr   r4   re   r   s      r   f>TestPEP380Operation.test_next_and_return_with_value.<locals>.f  sZ    1BH3^,R34  3a1223s   -A 
A-A((A-c              3   d   >#    TR                  S5        S v   TR                  SU < 35        U $ 7f)N
g startingg returning r   )r5  r   s    r   re   >TestPEP380Operation.test_next_and_return_with_value.<locals>.g  s)     LL&LLQ01Hs   -0Nr_   r   r   )r9  r1  g returning Nonef caught StopIteration()r9  r1  g returning 1f caught StopIteration(1)r9  r1  g returning (2,)f caught StopIteration((2,))r9  r1  g returning StopIteration(3)(f caught StopIteration(StopIteration(3))rd   r    r"   r6  re   r   s     @@r   test_next_and_return_with_value3TestPEP380Operation.test_next_and_return_with_value  sM     	3	
 	
$	!	$	-
  
 	r&   c                    ^^ / mUU4S jnU4S jmU" S5        U" S5        U" S5        U" [        S5      5        U R                  T/ SQ5        g)z!
Test send and return with value
c                    > T" U 5      n[        U5         TR                  S5        UR                  S5        TR                  S5        g ! [         a  nTR                  SU< 35         S nAg S nAff = f)Nf sending spam to gr   r2  r3  )rb   r   rc   rd   r4  s      r   r6  >TestPEP380Operation.test_send_and_return_with_value.<locals>.f  s_    1BH32334  3a1223s   3A
 

A3A..A3c              3      >#    TR                  S5        S v nTR                  SU< 35        TR                  SU < 35        U $ 7f)Nr9  zg received r:  r   )r5  r#   r   s     r   re   >TestPEP380Operation.test_send_and_return_with_value.<locals>.g  s:     LL&ALLA/0LLQ01Hs   AANr_   r   r   )r9  rJ  g received 'spam'r<  r=  r9  rJ  rN  r>  r?  r9  rJ  rN  r@  rA  r9  rJ  rN  rB  rC  rD  rE  s     @@r   test_send_and_return_with_value3TestPEP380Operation.test_send_and_return_with_value  sM     	3	 	
$	!	$	-
 !
 	r&   c           
      8  ^^^ UU4S jmUU4S jnSS[        S5      4 Hw  m/ mU" 5       nTR                  [        U5      5        TR                  [        UR	                  [
        5      5      5        U R                  TSSST< S3[        T5      /5        My     g	)
zM
Test catching an exception thrown into a
subgenerator and returning a value
c               3   ^   >#     Sv   T$ ! [          a    T R                  S5         T$ f = f7f)Nr_   inner caught ValueError)r-   r   )r   r   s   r   innerTTestPEP380Operation.test_catching_exception_from_subgen_and_returning.<locals>.inner  s9     8 L  867L8s   - -*-*-c               3   d   >#    T" 5        S h  vN n TR                  SU < S35        U v   g  N7f)Ninner returned 	 to outerr   )r   rT  r   s    r   outerTTestPEP380Operation.test_catching_exception_from_subgen_and_returning.<locals>.outer  s)      7"ALL<=G #s   0. 0r|   r   r_   rS  rW  rX  N)rd   r   rb   reprr   r-   r    )r"   rY  re   rT  r   r   s      @@@r   1test_catching_exception_from_subgen_and_returningETestPEP380Operation.test_catching_exception_from_subgen_and_returning  s    
		
 mA..EEALLa!LLaggj123U)057U	%  /r&   c                    ^^ / mU4S jmUU4S jn U" 5       n[        U5        UR                  [        5        U R                  S5        U R	                  TSS/5        g! [         a     N!f = f)zW
Test throwing GeneratorExit into a subgenerator that
catches it and returns normally.
c               3   |   >#     T R                  S5        S v   T R                  S5        g ! [         a     g f = f7fNEnter fExit fr   r   r   s   r   r6  STestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_returns.<locals>.f  s7     Y'X&  s   <&, <
9<9<c               3   t   >#    TR                  S5        T " 5        S h  vN   TR                  S5        g  N7fNEnter gzExit gr   r6  r   s   r   re   STestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_returns.<locals>.g!  ,     LL#sNNLL" r   *subgenerator failed to raise GeneratorExitrg  ra  N)rb   r   r   r1   r    )r"   re   r   r6  r   s      @@r   4test_throwing_GeneratorExit_into_subgen_that_returnsHTestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_returns  sr    
 		#	DBHHH]# IIBC 
 		  		s   'A   
A-,A-c                 ,  ^^ / mU4S jmUU4S jn U" 5       n[        U5        UR                  [        5        U R                  S5        U R                  TSS/5        g! [         a)  nU R                  UR                  S   S5         SnANCSnAff = f)	zM
Test throwing GeneratorExit into a subgenerator that
catches it and yields.
c               3      >#     T R                  S5        S v   T R                  S5        g ! [         a    S v    g f = f7fr`  rc  r   s   r   r6  XTestPEP380Operation.test_throwing_GeneratorExit_into_subgenerator_that_yields.<locals>.f8  s7     Y'X&  s    A &, A =A =A c               3   t   >#    TR                  S5        T " 5        S h  vN   TR                  S5        g  N7frf  r   rh  s   r   re   XTestPEP380Operation.test_throwing_GeneratorExit_into_subgenerator_that_yields.<locals>.g?  rj  r   rk  r   zgenerator ignored GeneratorExitNrg  ra  )rb   r   r   r1   RuntimeErrorr    r2   r"   re   r   r4   r6  r   s       @@r   9test_throwing_GeneratorExit_into_subgenerator_that_yieldsMTestPEP380Operation.test_throwing_GeneratorExit_into_subgenerator_that_yields2  s    
 		#	DBHHH]# IIBC 
 		  	KQVVAY(IJJ	Ks   'A   
B*BBc                 l  ^^ / mU4S jmUU4S jn U" 5       n[        U5        UR                  [        5        U R                  S5        U R                  TSS/5        g! [         aI  nU R                  UR                  S   S5        U R                  UR                  [        5         SnANcSnAff = f)	zc
Test throwing GeneratorExit into a subgenerator that
catches it and raises a different exception.
c               3      >#     T R                  S5        S v   T R                  S5        g ! [         a    [        S5      ef = f7f)Nra  rb  Vorpal bunny encountered)r   r   r-   r   s   r   r6  RTestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_raises.<locals>.fV  s@     =Y'X&  = !;<<=s   A&, AAAc               3   t   >#    TR                  S5        T " 5        S h  vN   TR                  S5        g  N7frf  r   rh  s   r   re   RTestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_raises.<locals>.g]  rj  r   r/   r   ry  Nrg  ra  )	rb   r   r   r1   r-   r    r2   r   r   rt  s       @@r   3test_throwing_GeneratorExit_into_subgen_that_raisesGTestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_raisesP  s    
 	=	#	ABHHH]#
 II?@ 
 	  	@QVVAY(BC!!!--??	@s   'A   
B3*?B..B3c                 J    S nU R                  [        [        U" 5       5        g )Nc               3   $   #    S S h  vN   g  N7f)Nr   r   r   r&   r   re   4TestPEP380Operation.test_yield_from_empty.<locals>.gp  s     MM   )rq   rd   rb   )r"   re   s     r   test_yield_from_empty)TestPEP380Operation.test_yield_from_emptyo  s    	-qs3r&   c                   ^^ U4S jnU4S jmU" 5       mU R                  [        T5      / SQ5        U" 5       m[        T5      /n  UR                  TR	                  S5      5        M"  ! [
         a     Of = fU R                  U/ SQ5        g )Nc               3   @   >#    Sv   T " 5        S h  vN   Sv   g  N	7fNr   r   r   )twos   r   oneOTestPEP380Operation.test_delegating_generators_claim_to_be_running.<locals>.onev  s      GuG s   
c               3   X   >#    Sv    T  S h  vN   Sv   g  N	! [          a     Nf = f7fNr_   r|   r-   )r   s   r   r  OTestPEP380Operation.test_delegating_generators_claim_to_be_running.<locals>.twoz  s4     G G  s(   *  * 
'*'*r   r_   r|   r   r   )r    r   rb   r   rc   rd   )r"   r  resr   r  s      @@r   .test_delegating_generators_claim_to_be_runningBTestPEP380Operation.test_delegating_generators_claim_to_be_runningt  s    		 Ub<0 UBxj	

2772;'  		l+s   #A* *
A76A7c                    ^^^  " S S[         5      mUU4S jnUU4S jmU" 5       m[        T5      /n  UR                  TR                  T5      5        M"  ! [         a     g   U R                  U/ SQ5        e = f)Nc                       \ rS rSrSrg)\TestPEP380Operation.test_delegating_generators_claim_to_be_running_with_throw.<locals>.MyErri  r   Nr*  r   r&   r   MyErrr    r+  r&   r  c               3   t   >#     Sv   T" 5        S h  vN    Sv   g ! T  a     Nf = f N! T  a     g f = f7fr  r   )r  r  s   r   r  ZTestPEP380Operation.test_delegating_generators_claim_to_be_running_with_throw.<locals>.one  sQ      u	    s<   8 
8*8, 8'8'85858c               3      >#     Sv    T S h  vN    Sv   g ! T  a     Nf = f N! [          a     N f = f! T  a     g f = f7fr  r  )r  r   s   r   r  ZTestPEP380Operation.test_delegating_generators_claim_to_be_running_with_throw.<locals>.two  sc           s\   A ( &( 8 A#A#A( 
5A5AAA AAr  )r,  rb   r   r   rd   r    )r"   r  r  r  r   r  s      @@@r   9test_delegating_generators_claim_to_be_running_with_throwMTestPEP380Operation.test_delegating_generators_claim_to_be_running_with_throw  ss    	I 				 UBxj	

288E?+  		S,/s   #A 
A:$A:c                 v   ^ ^^  " UU 4S jS5      mU4S jnU" 5       m[        T5        TR                  5         g )Nc                   0   > \ rS rSrS rS rU U4S jrSrg)[TestPEP380Operation.test_delegating_generators_claim_to_be_running_with_close.<locals>.MyIti  c                     U $ r   r   r   s    r   r   dTestPEP380Operation.test_delegating_generators_claim_to_be_running_with_close.<locals>.MyIt.__iter__  r   r&   c                     gNr   r   r   s    r   r   dTestPEP380Operation.test_delegating_generators_claim_to_be_running_with_close.<locals>.MyIt.__next__      r&   c                 r   > TR                  TR                  5        TR                  [        [        T5        g r   )
assertTrue
gi_runningrq   r-   rb   )self_r   r"   s    r   r~   aTestPEP380Operation.test_delegating_generators_claim_to_be_running_with_close.<locals>.MyIt.close  s%    .!!*dB7r&   r   N)r   r   r   r   r   r   r~   r   )r   r"   s   r   MyItr    s    8 8r&   r  c               3   0   >#    T " 5        S h  vN   g  N7fr   r   )r  s   r   r  ZTestPEP380Operation.test_delegating_generators_claim_to_be_running_with_close.<locals>.one  s     vr   )rb   r~   )r"   r  r  r   s   ` @@r   9test_delegating_generators_claim_to_be_running_with_closeMTestPEP380Operation.test_delegating_generators_claim_to_be_running_with_close  s)    	8 	8	UR

r&   c                    ^ S mU4S jnS nS nU" U" 5       5       H  nU R                  SU;   5        M     U" U" U" 5       5      5       H#  nU R                  SU;   =(       a    SU;   5        M%     g )Nc                  \    [         R                  " 5        V s/ s H  o S   PM	     sn $ s  sn f r   )inspectstack)r6  s    r   
call_stackMTestPEP380Operation.test_delegator_is_visible_to_debugger.<locals>.call_stack  s"    ")--/2/QaD/222s   )c               3   D   >#    T " 5       v   T " 5       v   T " 5       v   g 7fr   r   )r  s   r   genFTestPEP380Operation.test_delegator_is_visible_to_debugger.<locals>.gen  s     ,,,s    c              3   $   #    U  S h  vN   g  N7fr   r   re   s    r   r   GTestPEP380Operation.test_delegator_is_visible_to_debugger.<locals>.spam       LLr  c              3   $   #    U  S h  vN   g  N7fr   r   r  s    r   r   GTestPEP380Operation.test_delegator_is_visible_to_debugger.<locals>.eggs  r  r  r   r   )r  )r"   r  r   r   r  r  s        @r   %test_delegator_is_visible_to_debugger9TestPEP380Operation.test_delegator_is_visible_to_debugger  si    	3	
		 #%[EOOFeO, ! $su+&EOOFeO?%@ 'r&   c                 r   ^^  " S S5      mUU4S jnS m[        U" 5       5        U R                  TS5        g )Nc                        \ rS rSrS rS rSrg)?TestPEP380Operation.test_custom_iterator_return.<locals>.MyIteri  c                     U $ r   r   r   s    r   r   HTestPEP380Operation.test_custom_iterator_return.<locals>.MyIter.__iter__  r   r&   c                     [        S5      er  )rd   r   s    r   r   HTestPEP380Operation.test_custom_iterator_return.<locals>.MyIter.__next__  s    #B''r&   r   N)r   r   r   r   r   r   r   r   r&   r   MyIterr    s    (r&   r  c               3   0   >#    T " 5        S h  vN mg  N7fr   r   )r  r   s   r   r  <TestPEP380Operation.test_custom_iterator_return.<locals>.gen  s     #X%C%r   r   )r   r    )r"   r  r  r   s     @@r   test_custom_iterator_return/TestPEP380Operation.test_custom_iterator_return  s2    	( 	(
	& SUb!r&   c                    ^ S mU4S jnS n[        5          U" 5       nU" 5       nUR                  S 5        UR                  U5        UR                  U5        AA[        5         S S S 5        g ! , (       d  f       g = f)Nc               3      #    S v   g 7fr   r   r   r&   r   	innermostDTestPEP380Operation.test_close_with_cleared_frame.<locals>.innermost  s     s   c               3   8   >#    S v n T" 5        S h  vN   g  N7fr   r   )	outer_genr  s    r   rT  @TestPEP380Operation.test_close_with_cleared_frame.<locals>.inner  s     I {""s   c               3   ,   #    S v n U  S h  vN   g  N7fr   r   )	inner_gens    r   rY  @TestPEP380Operation.test_close_with_cleared_frame.<locals>.outer  s     I   s   
)r   rc   r   )r"   rT  rY  r  r  r  s        @r   test_close_with_cleared_frame1TestPEP380Operation.test_close_with_cleared_frame  s`    &		#	! \IINN4 NN9%NN9%L \\s   AA//
A=c                    ^^  " U4S jS5      mU4S jnU" 5       n[        U5        S mUR                  S5        U R                  TS5        g )Nc                   .   > \ rS rSrS rS rU 4S jrSrg)HTestPEP380Operation.test_send_tuple_with_custom_generator.<locals>.MyGeni  c                     U $ r   r   r   s    r   r   QTestPEP380Operation.test_send_tuple_with_custom_generator.<locals>.MyGen.__iter__  r   r&   c                     gr  r   r   s    r   r   QTestPEP380Operation.test_send_tuple_with_custom_generator.<locals>.MyGen.__next__  r  r&   c                 
   > Umg r   r   )r"   whatr   s     r   rc   MTestPEP380Operation.test_send_tuple_with_custom_generator.<locals>.MyGen.send  s    r&   r   N)r   r   r   r   r   r   rc   r   )r   s   r   MyGenr    s     r&   r  c               3   0   >#    T" 5        S h  vN n g  N7fr   r   )r   r  s    r   rY  HTestPEP380Operation.test_send_tuple_with_custom_generator.<locals>.outer  s      7"A"r   )r_   r|   r      )rb   rc   r    )r"   rY  re   r  r   s      @@r   %test_send_tuple_with_custom_generator9TestPEP380Operation.test_send_tuple_with_custom_generator  sA    	 		#GQ	|L)r&   r   N))r   r   r   r   __doc__r$   r5   rG   rR   rg   rs   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r-  rF  rO  r\  rl  ru  r}  r  r  r  r  r  r  r  r  r   r   r&   r   r   r      s    .>:#J*X'R D'R&P0-1f ",@6H@&!F)V(T-^:<<>4
,4$L A*"%N*r&   r   c                   P    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rSrg)TestInterestingEdgeCasesi!  c                    U R                  [        5       n[        U5        S S S 5        U R                  WR                  R
                  5        U R                  UR                  R                  5        g ! , (       d  f       NY= fr   )rq   rd   rb   assertIsNone	exceptionr   r   )r"   iteratorcaughts      r   assert_stop_iteration.TestInterestingEdgeCases.assert_stop_iteration#  s[    }-N .&**001&**667 .-s   A55
Bc                 .    U R                  [        S5      $ )Nz ^generator raised StopIteration$assertRaisesRegexrs  r   s    r   &assert_generator_raised_stop_iteration?TestInterestingEdgeCases.assert_generator_raised_stop_iteration)  s    %%l4WXXr&   c                 .    U R                  [        S5      $ )Nz!^generator ignored GeneratorExit$r  r   s    r   'assert_generator_ignored_generator_exit@TestInterestingEdgeCases.assert_generator_ignored_generator_exit,  s    %%l4XYYr&   c                   ^^^^ [        5       m[        5       m[        5       mUUU4S jmU4S jnU R                  S5         U" 5       nU R                  [        U5      T5        UR	                  5         U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  U5        U R                  UR                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [        5       nU R                  5        nUR                  U5        S S S 5        U R                  WR                  R                  U5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  U5        U R                  UR                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  U5        U R                  UR                  R                  5        U R                  U5        S S S 5        g ! , (       d  f       GN;= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNB= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNC= f! , (       d  f       N= f! , (       d  f       g = f)Nc               3       >#    Tv   Tv   T $ 7fr   r   returnedyielded_firstyielded_seconds   r   rT  ATestInterestingEdgeCases.test_close_and_throw_work.<locals>.inner5  s       Os   c               3   .   >#    T " 5        S h  vN $  N7fr   r   rT  s   r   rY  ATestInterestingEdgeCases.test_close_and_throw_work.<locals>.outer:       $w&'&   r~   throw GeneratorExitthrow StopIterationthrow BaseExceptionthrow Exception)objectsubTestassertIsrb   r~   r  r   rq   r   r  r  r   rd   r  BaseExceptionr,  	r"   rY  re   thrownr  rT  r  r  r   s	        @@@@r   test_close_and_throw_work2TestInterestingEdgeCases.test_close_and_throw_work/  s   8	
	( \\'"AMM$q'=1GGI&&q)	 # \\/0AMM$q'=1"_F""=1V 2MM&**F3f..::;&&q) 1 \\/0AMM$q'=1"_F<<>& ?MM&**66?f..::FFG&&q) 1 \\/0AMM$q'=1"_F""=1V 2MM&**F3f..::;&&q) 1 \\+,AMM$q'=1[F""9- .MM&**F3f..::;&&q) -,K #" 21	 10 ?> 10 21	 10 .-	 -,s   AN:AO!O3AO&=P#O05A.P<AP&>PAP&AQ	P8AQ	:
O	
O	O
O-0
O?	:P
P
P#	P&&
P58
Q	Q		
Qc                  
  ^^^^^	 [        5       m[        5       m	[        5       mUUUU	4S jmU4S jnU R                  S5         U" 5       nU R                  [        U5      T5        [	        5       mUR                  5         U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[	        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  U5        U R                  UR                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  T5        U R                  UR                  R                  U5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  T5        U R                  UR                  R                  U5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  T5        U R                  UR                  R                  U5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN7= f! , (       d  f       GN= f! , (       d  f       GNZ= f! , (       d  f       GN= f! , (       d  f       GN}= f! , (       d  f       GN= f! , (       d  f       g = f)Nc               3   0   >#     Tv   Tv   TT e! T e= f7fr   r   raisedr  r  r   s   r   rT  QTestInterestingEdgeCases.test_close_and_throw_raise_generator_exit.<locals>.innerr  $     ##$$f   	 c               3   .   >#    T " 5        S h  vN $  N7fr   r   r  s   r   rY  QTestInterestingEdgeCases.test_close_and_throw_raise_generator_exit.<locals>.outerz  r  r  r~   r  r  r	  r
  )r  r  r  rb   r   r~   r  rq   r   r  r  r   rd   r  r,  )
r"   rY  re   r  r  rT  r  r  r  r   s
        @@@@@r   )test_close_and_throw_raise_generator_exitBTestInterestingEdgeCases.test_close_and_throw_raise_generator_exitl  s   8	 		( \\'"AMM$q'=1"_F GGI&&q) # \\/0AMM$q'=1"_F"_F""=1V 2
 MM&**F3f..::;&&q) 1 \\/0AMM$q'=1"_F"_F""=1V 2MM&**F3MM&**66?f..::FFG&&q) 1 \\/0AMM$q'=1"_F"_F""=1V 2MM&**F3MM&**66?f..::FFG&&q) 1 \\+,AMM$q'=1"_F[F""=1V 2MM&**F3MM&**66?f..::FFG&&q) -,_ #" 21 10& 21 10" 21 10" 21 -,s   AQ/+AR7R	AR<AR7R%B
R7=AS	S	B
S>AS?
S-B
S?/
Q>
R	R
R"%
R4	/R77
S	
S	S
S*-
S<	7S??
Tc                   ^^^^^	 [        5       m[        5       m	[        5       mUUUU	4S jmU4S jnU R                  S5         U" 5       nU R                  [        U5      T5        [	        5       mU R                  5        nUR                  5         S S S 5        U R                  WR                  R                  T5        U R                  UR                  R                  R                  [        5        U R                  UR                  R                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  5        nUR                  U5        S S S 5        U R                  WR                  R                  T5        U R                  UR                  R                  R                  [        5        U R                  UR                  R                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[	        5       nU R                  5        nUR                  U5        S S S 5        U R                  WR                  R                  T5        U R                  UR                  R                  R                  U5        U R                  UR                  R                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  5        nUR                  U5        S S S 5        U R                  WR                  R                  T5        U R                  UR                  R                  R                  U5        U R                  UR                  R                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  5        nUR                  U5        S S S 5        U R                  WR                  R                  T5        U R                  UR                  R                  R                  U5        U R                  UR                  R                  R                  R                  5        U R                  U5        S S S 5        g ! , (       d  f       GN(= f! , (       d  f       GN= f! , (       d  f       GN.= f! , (       d  f       GN= f! , (       d  f       GN4= f! , (       d  f       GN= f! , (       d  f       GN>= f! , (       d  f       GN= f! , (       d  f       GNH= f! , (       d  f       g = f)Nc               3   0   >#     Tv   Tv   TT e! T e= f7fr   r   r  s   r   rT  QTestInterestingEdgeCases.test_close_and_throw_raise_stop_iteration.<locals>.inner  r  r  c               3   .   >#    T " 5        S h  vN $  N7fr   r   r  s   r   rY  QTestInterestingEdgeCases.test_close_and_throw_raise_stop_iteration.<locals>.outer  r  r  r~   r  r  r	  r
  )r  r  r  rb   rd   r  r~   r  r   r   r   r  r  r   r  r,  
r"   rY  re   r  r  rT  r  r  r  r   s
        @@@@@r   )test_close_and_throw_raise_stop_iterationBTestInterestingEdgeCases.test_close_and_throw_raise_stop_iteration  sd   8	 		( \\'"AMM$q'=1"_F<<>&	 ?MM&**66?!!&"2"2">">"J"JMZf..::FFRRS&&q) # \\/0AMM$q'=1"_F"_F<<>& ?MM&**66? !!&"2"2">">"J"JMZf..::FFRRS&&q) 1 \\/0AMM$q'=1"_F"_F<<>& ?MM&**66?MM&**66BBFKf..::FFRRS&&q) 1 \\/0AMM$q'=1"_F"_F<<>& ?MM&**66?MM&**66BBFKf..::FFRRS&&q) 1 \\+,AMM$q'=1"_F[F<<>& ?MM&**66?MM&**66BBFKf..::FFRRS&&q) -,a ?> #"$ ?> 10* ?> 10& ?> 10& ?> -,s   =WV3B,WAW)W0B,W)5AX<W;B(XAX1X(B(X1)AY0YB(Y3
W	=W
W
W&	!W))
W8;
X
	X
X
X.	)X11
Y 
Y	Y
Y#c                   ^^^^^	 [        5       m[        5       m	[        5       mUUUU	4S jmU4S jnU R                  S5         U" 5       nU R                  [        U5      T5        [	        5       mU R                  [        5       nUR                  5         S S S 5        U R                  WR                  T5        U R                  UR                  R                  [        5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  T5        U R                  UR                  R                  [        5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  T5        U R                  UR                  R                  U5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[	        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  T5        U R                  UR                  R                  U5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  T5        U R                  UR                  R                  U5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN*= f! , (       d  f       GN= f! , (       d  f       GNI= f! , (       d  f       GN= f! , (       d  f       GNl= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN*= f! , (       d  f       g = f)Nc               3   0   >#     Tv   Tv   TT e! T e= f7fr   r   r  s   r   rT  QTestInterestingEdgeCases.test_close_and_throw_raise_base_exception.<locals>.inner  r  r  c               3   .   >#    T " 5        S h  vN $  N7fr   r   r  s   r   rY  QTestInterestingEdgeCases.test_close_and_throw_raise_base_exception.<locals>.outer  r  r  r~   r  r  r	  r
  )r  r  r  rb   r  rq   r~   r  r   r   r   r  r  r   rd   r,  r#  s
        @@@@@r   )test_close_and_throw_raise_base_exceptionBTestInterestingEdgeCases.test_close_and_throw_raise_base_exception  s   8	 		( \\'"AMM$q'=1"_F""=1V	 2MM&**F3!!&"2"2">">Nf..::FFG&&q) # \\/0AMM$q'=1"_F"_F""=1V 2MM&**F3 !!&"2"2">">Nf..::FFG&&q) 1 \\/0AMM$q'=1"_F"_F""=1V 2MM&**F3MM&**66?f..::FFG&&q) 1 \\/0AMM$q'=1"_F"_F""=1V 2MM&**F3MM&**66?f..::FFG&&q) 1 \\+,AMM$q'=1"_F[F""=1V 2MM&**F3MM&**66?f..::FFG&&q) -,[ 21	 #"  21 10& 21 10" 21 10" 21 -,   AUT6BU>AU,
UBU,AVU>!B
VAV4V""B
V4AWW#B
W6
U	 U
U
U)	$U,,
U;>
V	V
V"
V1	,V44
W
W	W
W&c                   ^^^^^	 [        5       m[        5       m	[        5       mUUUU	4S jmU4S jnU R                  S5         U" 5       nU R                  [        U5      T5        [	        5       mU R                  [        5       nUR                  5         S S S 5        U R                  WR                  T5        U R                  UR                  R                  [        5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  T5        U R                  UR                  R                  [        5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  T5        U R                  UR                  R                  U5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  T5        U R                  UR                  R                  U5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [	        5       m[	        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  T5        U R                  UR                  R                  U5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN*= f! , (       d  f       GN= f! , (       d  f       GNI= f! , (       d  f       GN= f! , (       d  f       GNl= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN*= f! , (       d  f       g = f)Nc               3   0   >#     Tv   Tv   TT e! T e= f7fr   r   r  s   r   rT  LTestInterestingEdgeCases.test_close_and_throw_raise_exception.<locals>.inner_  r  r  c               3   .   >#    T " 5        S h  vN $  N7fr   r   r  s   r   rY  LTestInterestingEdgeCases.test_close_and_throw_raise_exception.<locals>.outerg  r  r  r~   r  r  r	  r
  )r  r  r  rb   r,  rq   r~   r  r   r   r   r  r  r   rd   r  r#  s
        @@@@@r   $test_close_and_throw_raise_exception=TestInterestingEdgeCases.test_close_and_throw_raise_exceptionY  s   8	 		( \\'"AMM$q'=1[F""9-	 .MM&**F3!!&"2"2">">Nf..::FFG&&q) # \\/0AMM$q'=1[F"_F""9- .MM&**F3 !!&"2"2">">Nf..::FFG&&q) 1 \\/0AMM$q'=1[F"_F""9- .MM&**F3MM&**66?f..::FFG&&q) 1 \\/0AMM$q'=1[F"_F""9- .MM&**F3MM&**66?f..::FFG&&q) 1 \\+,AMM$q'=1[F[F""9- .MM&**F3MM&**66?f..::FFG&&q) -,[ .-	 #"  .- 10& .- 10" .- 10" .- -,r-  c                 	  ^^^^ [        5       m[        5       m[        5       mUUU4S jmU4S jnU R                  S5         U" 5       nU R                  [        U5      T5        U R	                  5        nUR                  5         S S S 5        U R                  WR                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [        5       nU R	                  5        nUR                  U5        S S S 5        U R                  WR                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [        5       nU R                  UR                  U5      T5        U R                  5        n[        U5        S S S 5        U R                  WR                  R                  U5        U R                  UR                  R                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [        5       nU R                  UR                  U5      T5        U R!                  [        5       n[        U5        S S S 5        U R                  WR                  U5        U R                  UR                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [#        5       nU R                  UR                  U5      T5        U R!                  ["        5       n[        U5        S S S 5        U R                  WR                  U5        U R                  UR                  R                  5        U R                  U5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN}= f! , (       d  f       GN'= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN.= f! , (       d  f       GN= f! , (       d  f       GNp= f! , (       d  f       N= f! , (       d  f       g = f)Nc               3   4   >#     Tv   Tv   T $ ! Tv   f = f7fr   r   r  s   r   rT  BTestInterestingEdgeCases.test_close_and_throw_yield.<locals>.inner  s%     %##$$O %$s    c               3   .   >#    T " 5        S h  vN $  N7fr   r   r  s   r   rY  BTestInterestingEdgeCases.test_close_and_throw_yield.<locals>.outer  r  r  r~   r  r  r	  r
  )r  r  r  rb   r  r~   r  r  r   r  r   r   rd   r    r  r  rq   r,  )	r"   rY  re   r  r  rT  r  r  r   s	        @@@@r   test_close_and_throw_yield3TestInterestingEdgeCases.test_close_and_throw_yield  sh   8		( \\'"AMM$q'=1 ==?6	 @f..::;&&q) # \\/0AMM$q'=1"_F ==?6 @f..::;&&q) 1 \\/0AMM$q'=1"_FQWWV_n=<<>&Q ?MM&**66?f..::FFG&&q) 1 \\/0AMM$q'=1"_FQWWV_n=""=1VQ 2MM&**F3f..::;&&q) 1 \\+,AMM$q'=1[FQWWV_n=""9-Q .MM&**F3f..::;&&q) -,O @? #"  @? 10" ?> 10" 21 10  .- -,s   3P:5P(>P:=QQ,>QAR!Q0-A.R4A#R&R#AR&A#S	9R8AS	(
P7	2P::
Q	
Q	Q
Q-0
Q?	:R
R
R#	R&&
R58
S	S		
Sc                   ^^^^ [        5       m[        5       m[        5       mUUU4S jmU4S jnU R                  S5         U" 5       nU R                  [        U5      T5        UR	                  5         U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  U5        U R                  UR                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  R                  T5        U R                  UR                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  R                  T5        U R                  UR                  R                  5        U R                  U5        S S S 5        U R                  S5         U" 5       nU R                  [        U5      T5        [        5       nU R                  [        5       nUR                  U5        S S S 5        U R                  WR                  R                  T5        U R                  UR                  R                  5        U R                  U5        S S S 5        g ! , (       d  f       GNJ= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNL= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNM= f! , (       d  f       N= f! , (       d  f       g = f)Nc               3   6   >#     Tv   Tv   T $ ! T s  s $ = f7fr   r   r  s   r   rT  CTestInterestingEdgeCases.test_close_and_throw_return.<locals>.inner  s!      ##$$xs    c               3   .   >#    T " 5        S h  vN $  N7fr   r   r  s   r   rY  CTestInterestingEdgeCases.test_close_and_throw_return.<locals>.outer  r  r  r~   r  r  r	  r
  )r  r  r  rb   r~   r  r   rq   r   r  r  r   rd   r   r  r,  r  s	        @@@@r   test_close_and_throw_return4TestInterestingEdgeCases.test_close_and_throw_return  s   8	 	( \\'"AMM$q'=1 GGI&&q) # \\/0AMM$q'=1"_F ""=1V 2MM&**F3f..::;&&q) 1 \\/0AMM$q'=1"_F""=1V 2MM&**00(;f..::;&&q) 1 \\/0AMM$q'=1"_F""=1V 2MM&**00(;f..::;&&q) 1 \\+,AMM$q'=1[F""=1V 2MM&**00(;f..::;&&q) -,Q #" 21 10  21	 10 21	 10 21	 -,s   AO	AO-!O3AO-&AP(O?:A$P7AP59P#A$P5AQ
QA$Q	
O
O*	%O--
O<?
P		P
P #
P2	-P55
Q
Q	Q
Q&r   N)r   r   r   r   r  r  r  r  r  r$  r+  r3  r:  rA  r   r   r&   r   r  r  !  sB    8YZ;*zJ*XQ*fL*\L*\E*N@*r&   r  __main__)r  unittestr  test.supportr   r   r   testr   TestCaser   r  r   mainr   r&   r   <module>rI     s]      @ @ O*(++ O*b M*x00 M*` zMMO r&   