+
    i                     |   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIt^ RIHt	 ^RI
Ht ^RI
Ht ^RI
Ht ^RI
Ht ^R	I
Ht ^R
IHt  ! R R]4      tR tR t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t]R8X  d   ]P:                  ! 4        R# R# )    N)ABCMeta)abstractmethod)greenlet)TestCase)RUNNING_ON_MANYLINUX)PY313)PY314)RUNNING_ON_FREETHREAD_BUILD)fails_leakcheckc                       ] tR t^tRtR# )	SomeError N__name__
__module____qualname____firstlineno____static_attributes__r       vC:\Users\petid\OneDrive\Desktop\Maestro\MAESTRO\maestro-backend\venv\Lib\site-packages\greenlet/tests/test_greenlet.pyr   r      s    r   r   c                      \         P                  ! 4       P                  P                  4        \        h   T P	                  \
        P                  ! 4       ^ ,          4       h ; ir   )r   
getcurrentparentswitchappendsysexc_infor   seens   &r   fmainr!   "   sJ    $$++- OCLLN1%&s	   -5 .A#c                 F    R  p\        W R7      pVP                  V4       R# )c                     V hNr   )excs   &r   crashersend_exception.<locals>.crasher.   s    	r   r   NRawGreenletr   )gr%   r&   g1s   &&  r   send_exceptionr-   +   s    	W	'BIIcNr   c                     a  ] tR t^4t o R tR tR tR tR tR t	R t
R tR	 tR
 tR tR tR t]P$                  ! ];'       d    ]R4      R 4       tR tR tR tR tR tR tR tR tR tR tR t R t!]"R1R l4       t#]"R 4       t$R t%]"R 4       t&R  t'R! t(R" t)R# t*R$ t+R% t,]P$                  ! ];'       d    ]R&4      R' 4       t-R( t.R) t/R* t0R+ t1R, t2R- t3R. t4R/t5V t6R0# )2TestGreenletc                  a . oV3R  lp\        V4      pSP                  ^ 4       VP                  4        SP                  ^4       VP                  4        SP                  ^4       V P                  S\	        \        ^4      4      4       R# )c                     < S P                  ^4       \        P                  ! 4       P                  P	                  4        S P                  ^4       R#    Nr   r   r   r   r   lsts   r   f'TestGreenlet._do_simple_test.<locals>.f9   s4    JJqM!((//1JJqMr   N)r*   r   r   assertEquallistrange)selfr7   r+   r6   s   &  @r   _do_simple_testTestGreenlet._do_simple_test6   sc    	 N

1	


1	


1d58n-r   c                &    V P                  4        R # r$   )r=   r<   s   &r   test_simpleTestGreenlet.test_simpleE   s    r   c                    \        4       pV P                  \        4      ;_uu_ 4       pVP                  4        R R R 4       V P	                  R\        XP                  4      4       R #   + '       g   i     L7; iNrun)r*   assertRaisesAttributeErrorr   assertInstr	exceptionr<   r+   r%   s   &  r   (test_switch_no_run_raises_AttributeError5TestGreenlet.test_switch_no_run_raises_AttributeErrorH   sL    M~..#HHJ / 	eS/0 /.s   A((A8	c                    \        4       pV P                  \        4      ;_uu_ 4       pVP                  \        4       R R R 4       V P                  R\        XP                  4      4       R #   + '       g   i     L7; irD   )r*   rF   rG   throwr   rH   rI   rJ   rK   s   &  r   'test_throw_no_run_raises_AttributeError4TestGreenlet.test_throw_no_run_raises_AttributeErrorO   sO    M~..#GGI / 	eS/0 /.s   A--A=	c                    \        R R7      pV P                  V4       V P                  VP                  \        P
                  ! 4       4       R # )Nr(   )r*   assertIsNotNoneassertIsr   r   r   r<   r+   s   & r   test_parent_equals_None$TestGreenlet.test_parent_equals_NoneV   s5    t$Qahh 3 3 56r   c                v    \        R R7      pV P                  V4       V P                  VP                  4       R # )NrE   )r*   rS   assertIsNonerE   rU   s   & r   test_run_equals_None!TestGreenlet.test_run_equals_None[   s,    D!Q!%% r   c                  a . oV3R  lp\        V4      p\        V4      pVP                  4        V P                  \        S4      ^4       VP                  4        V P                  \        S4      ^4       VP                  4        V P                  \        S4      ^4       V P                  VP                  R4       VP                  4        V P                  \        S4      ^4       V P                  VP                  R4       R# )c                     < S P                  ^4       \        P                  ! 4       P                  P	                  4        S P                  ^^.4       R# r2   )r   r   r   r   r   extendr5   s   r   r7   )TestGreenlet.test_two_children.<locals>.fc   s9    JJqM!((//1JJ1vr   TN)r*   r   r9   lendead)r<   r7   r+   hr6   s   &   @r   test_two_childrenTestGreenlet.test_two_children`   s    	 NN	
S1%	
S1%	
S1%&	
S1%&r   c                  aa . oV3R  loVV3R lpT P                  \        P                  ! V4      \        '       g   ^M^4       \	        V4      pT P                  \        P                  ! V4      \        '       g   ^M^4       VP                  4        V P                  S. RO4       T P                  \        P                  ! V4      \        '       g	   ^4       R# ^4       R# )c                     < S P                  R 4       \        P                  ! 4       P                  P	                  4        R# )bNr4   r5   s   r   r7   3TestGreenlet.test_two_recursive_children.<locals>.fw   s)    JJsO!((//1r   c                     < SP                  R 4       \        S4      p V P                  4        SP                  R4       R# )acN)r   r*   r   )r+   r7   r6   s    r   r+   3TestGreenlet.test_two_recursive_children.<locals>.g{   s+    JJsOAAHHJJJsOr   N)rk   rh   rl   )r9   r   getrefcountr	   r*   r   )r<   r+   r7   r6   s   & @@r   test_two_recursive_children(TestGreenlet.test_two_recursive_childrent   s    	2	
 	+eeQCN 	+eeQC	
o.+eeQCCr   c                2  a a . oV V3R  lp\        ^
4       Uu. uF  p\        P                  ! VR7      NK  	  ppV F  pVP                  4        K  	  V F  pVP	                  ^
4       K  	  S P                  \        S4      \        V4      4       R# u upi )c                  J   < S P                  4        SP                  R 4       R# TN)r=   r   )r<   successs   r   r7   $TestGreenlet.test_threads.<locals>.f   s      "NN4 r   targetN)r;   	threadingThreadstartjoinr9   ra   )r<   r7   ithsthrt   s   f    @r   test_threadsTestGreenlet.test_threads   sw    	! 499=9ayq)9=BHHJ BGGBK Ws3x0 >s    Bc                   . p\        \        4      p\        \        4      pVP                  V4       VP                  V4       W#n        V P	                  V. 4       V P                  \        VP                  4       V P	                  V\        .4       VP                  4       pV P	                  VR4       V P	                  V\        .4       VP                  ^4      pV P	                  V^4       V P	                  V\        .4       R# )   Nr   )r*   r!   r   r   r9   rF   r   )r<   r    r,   g2values   &    r   test_exceptionTestGreenlet.test_exception   s    
		$
		$	r" 	)RYY/	{+		#	{+		"#	{+r   c                    . p\        \        4      pVP                  V4       V P                  \        \
        V\        4       V P                  V\        .4       R # r$   )r*   r!   r   rF   KeyErrorr-   r9   )r<   r    r,   s   &  r   test_send_exception TestGreenlet.test_send_exception   sB    
		$(NBAz*r   c                   . p\        \        4      p\        \        4      pVP                  V4       VP                  V4       V P                  V. 4       ?\        P
                  ! 4        V P                  V\        P                  .4       ?\        P
                  ! 4        V P                  V\        P                  \        P                  .4       R # r$   )r*   r!   r   r9   gccollectr   GreenletExit)r<   r    r,   r   s   &   r   test_deallocTestGreenlet.test_dealloc   s    
		$
		$r"


 5 567


 5 5x7L7LMNr   c                X   R  p\        V4      pVP                  4        \        P                  p^ RIHp V! 4       ;p\        n         ?V\        n        VP                  4       pV P                  RV4       V P                  RV4       V P                  RV4       R#   T\        n        i ; i)c                       \         P                  ! 4       P                  P                  4        R #   \         P                   d	    \
        R hi ; ir$   )r   r   r   r   r   r   r   r   r   rE   HTestGreenlet.test_dealloc_catches_GreenletExit_throws_other.<locals>.run   s?    *##%,,335(( *T)*s	   -1 A)StringIO	Exceptionignoredr   N)r*   r   r   stderrior   getvaluerH   )r<   rE   r+   	oldstderrr   r   vs   &      r   .test_dealloc_catches_GreenletExit_throws_other;TestGreenlet.test_dealloc_catches_GreenletExit_throws_other   s    	* 	

 JJ	&j(	#"CJOOk1%i#k1% #CJs   B B)z=Sometimes flaky (getting one GreenletExit in the second list)c                :  aaaaaa . o. o\         P                  ! 4       o\         P                  ! 4       o\         P                  ! 4       o\         P                  ! 4       oVVVVVV3R  lp\         P                  ! VR7      pVP                  4        SP	                  ^
4       V P                  S. 4       V P                  \        S4      ^4       SR \        '       g   \        P                  ! 4        V P                  S. 4       SP                  4        SP	                  ^4        V P                  S\        P                  .4       SP                  4        VP                  ^
4       SR SR R#   SP                  4        TP                  ^
4       SR SR i ; i)c                  B  < \        \        4      p V P                  S4       SP                  V 4       ? \        P
                  ! 4        SP                  4        SP                  ^4       \        4        SP                  4        SP                  ^4       \        4        R# )   N)r*   r!   r   r   r   r   setwait)r,   /bg_glet_created_running_and_no_longer_ref_in_bgbg_should_be_clearfg_ref_releasedok_to_exit_bg_threadr    somerefs    r   r7   1TestGreenlet.test_dealloc_other_thread.<locals>.f   sn    U#BIIdONN2JJL;??A  #M""$ %%a(Mr   rv   NNNN)rx   Eventry   rz   r   r9   ra   r
   r   r   r   r   r   r{   )	r<   r7   tr   r   r   r   r    r   s	   &  @@@@@@r   test_dealloc_other_thread&TestGreenlet.test_dealloc_other_thread   sI    :C//:K7#//+&__.(0	 	 A&		7<<R@r"Wq)AJ** JJL 	r""	TH$9$9#:; $$&FF2JQ
 !$$&FF2JQ
s   '!E1 1)Fc                B  a  V 3R  lp\        V4      pVP                  4       pS P                  W2P                  J 4       S P                  V4       VP                  4       pS P	                  V4       S P                  VR4       S P                  VP                  R4       R# )c                     < \         P                  ! ^ 4      p SP                  V P                  R4       \        P
                  ! 4       P                  P                  V 4       R# )r   Nmeaning of life)r   	_getframer9   f_backr   r   r   r   )r7   r<   s    r   f1#TestGreenlet.test_frame.<locals>.f1"  sE    a AQXXt,!((//2$r   r   N)r*   r   
assertTruegr_frameassertFalser9   )r<   r   r+   framefrom_gs   f    r   
test_frameTestGreenlet.test_frame!  s{    	%
 O
+,!23T*r   c                    R  p\         P                  ! VRR7      p\         P                  ! VRR7      pVP                  4        VP                  4        VP                  ^
4       VP                  ^
4       R# )c                 F   a  \        V 3R  l4      pVP                  4        R# )c                  0   < \         P                  ! S 4      # r$   )timesleepxs   r   <lambda>>TestGreenlet.test_thread_bug.<locals>.runner.<locals>.<lambda>3  s    DJJqMr   Nr)   )r   r+   s   f r   runner,TestGreenlet.test_thread_bug.<locals>.runner2  s    12AHHJr   rw   argsN)g?)g333333?)rx   ry   rz   r{   )r<   r   t1t2s   &   r   test_thread_bugTestGreenlet.test_thread_bug1  sU    	 V&9V&9





r   c                p   a  V 3R  lp\        V4      P                  ^^R7      pS P                  V^*4       R# )c                 P   < SP                  V ^4       SP                  V^4       ^*# )   )r9   )rk   rh   r<   s   &&r   rE   ,TestGreenlet.test_switch_kwargs.<locals>.run=  s&    Q"Q"r   )rk   rh   Nr*   r   r9   )r<   rE   r   s   f  r   test_switch_kwargsTestGreenlet.test_switch_kwargs<  s4    	 ##a1#-Br   c                    R  p\        V4      pV P                  R^/VP                  ^4      4       V P                  RR^/3VP                  4       4       V P                  RVP                  4       4       R# )c                     \         P                  ! 4       P                  P                  V R 7       \         P                  ! 4       P                  P                  ^^R 7       W ^,          3# )r   r   r   r   r   r   s   &r   rE   6TestGreenlet.test_switch_kwargs_to_parent.<locals>.runE  sP    !((//!/4!((//Q/71f9r   r   N)   )r   	   )r*   r9   r   )r<   rE   r+   s   &  r   test_switch_kwargs_to_parent)TestGreenlet.test_switch_kwargs_to_parentD  sd    	 #q188A;/$a)188:6,r   c                  aaa / o\         P                  ! 4       o\         P                  ! 4       oVVV3R  lp\         P                  ! VR7      pVP                  4        SP	                  ^
4       V P                  \        P                  4      ;_uu_ 4        SR,          P                  4        RRR4       SP                  4        VP                  ^
4       SP                  4        R#   + '       g   i     LC; i)c                  h   < \        R  4      SR&   S P                  4        SP                  ^
4       R# )c                      R # r$   r   r   r   r   r   ITestGreenlet.test_switch_to_another_thread.<locals>.run.<locals>.<lambda>T      Dr   r+   Nr*   r   r   created_eventdata
done_events   r   rE   7TestGreenlet.test_switch_to_another_thread.<locals>.runS  )    #L1DIOOBr   rv   r+   N)rx   r   ry   rz   r   rF   r   errorr   r   r{   clear)r<   rE   threadr   r   r   s   &  @@@r   test_switch_to_another_thread*TestGreenlet.test_switch_to_another_threadN  s    !)__&
	  !!-2x~~..I /B

 /.s   C**C:	c                V   a a VV 3R  lpV 3R lo\        V4      P                  4        R# )c                     <  \        R 4      h   \        P                  ! 4       p \        S4      P	                  4        SP                  T \        P                  ! 4       4        R# ; i)funN)
ValueErrorr   r   r*   r   r9   )r   rc   r<   s    r   r7   &TestGreenlet.test_exc_state.<locals>.fb  sK    ; '';<<>A%%'  3<<>:s
    AA&c                  R   < S P                  \        P                  ! 4       R4       R # )N)NNN)r9   r   r   r@   s   r   rc   &TestGreenlet.test_exc_state.<locals>.hj  s    S\\^-?@r   Nr)   )r<   r7   rc   s   f @r   test_exc_stateTestGreenlet.test_exc_statea  s     	;	A 	Ar   c                   R  pR pR p\        V4      pV P                  VP                  / 4       VP                  4        V P                  VP                  ^*4       V P                  VP                  R^*/4       VP                  Vn        V P                  VP                  R^*/4       V P                  \        W$4       V P                  \        W4^*4       R# )c                  :    ^*\         P                  ! 4       n        R# )*   N)r   r   testr   r   r   r7   *TestGreenlet.test_instance_dict.<locals>.fp  s    )+H!&r   c                 
    V = R # r$   __dict__)r+   s   &r   deldict0TestGreenlet.test_instance_dict.<locals>.deldictr  s    
r   c                     Wn         R # r$   r   )r+   r   s   &&r   setdict0TestGreenlet.test_instance_dict.<locals>.setdictt  s    Jr   r   N)r*   r9   r   r   r   rF   	TypeError)r<   r7   r   r  r+   s   &    r   test_instance_dictTestGreenlet.test_instance_dicto  s    	,		NR(	
$fb\2ZZ
fb\2)W0)W4r   c                t   a . oV3R  lp\        V4      pVP                  4        V P                  SR.4       R# )c                  d   < S P                  \        \        P                  ! 4       R 4      4       R# rE   N)r   hasattrr   r   )has_runs   r   func;TestGreenlet.test_running_greenlet_has_no_run.<locals>.func  s"    NN++-u5r   FNr   )r<   r  r+   r
  s   &  @r    test_running_greenlet_has_no_run-TestGreenlet.test_running_greenlet_has_no_run  s4    	
 	
5'*r   c                    ^ RI pV P                  \        VP                   \        4       4       V P                  \        VP                  \        4       4       R# r   N)copyrF   r  r*   deepcopy)r<   r  s   & r   test_deepcopyTestGreenlet.test_deepcopy  s5    )TYY>)T]]KMBr   c                F  aaa \        R  4      o\        P                  ! 4       o. oVVV3R lp\        VSR7      pVP                  4        ?V P	                  S4       V P                  S^ ,          S4       V P                  S^,          P                  S4       SR RoRoR# )c                      R # r$   r   r   r   r   r   ;TestGreenlet.test_parent_restored_on_kill.<locals>.<lambda>  s    $r   c                  &  <  SP                  4        R #   \        P                   dg    SP                  \        P                  ! 4       P
                  4       SP                  \        P                  ! 4       4       S P                  4         R # i ; ir$   )r   r   r   r   r   r   )hubmainresults   r   worker9TestGreenlet.test_parent_restored_on_kill.<locals>.worker  s_    (( h113::;h1134

	s    A7BBr(   r   N)r*   r   r   r   r   rT   r   )r<   r  r+   r  r  r  s   &  @@@r   test_parent_restored_on_kill)TestGreenlet.test_parent_restored_on_kill  s    ,'""$	 s+	
fQi&fQi&&, 1Ir   c                    \        4       p\        R  VR7      pV P                  \        4      ;_uu_ 4        VP                  4        RRR4       R#   + '       g   i     R# ; i)c                      R # r$   r   r   r   r   r   9TestGreenlet.test_parent_return_failure.<locals>.<lambda>      r   r(   N)r*   rF   rG   r   )r<   r,   r   s   &  r   test_parent_return_failure'TestGreenlet.test_parent_return_failure  s>    ]b1~..IIK /...s   AA"	c                     ! R  R\         4      pV! R 4      pV P                  \        VP                  \        4       4       R# )c                   &   a  ] tR tRt o R tRtV tR# )>TestGreenlet.test_throw_exception_not_lost.<locals>.mygreenleti  c                J     \         h    M; i\        P                  ! Y4      # r$   )r   r*   __getattribute__r<   names   &&r   r*  OTestGreenlet.test_throw_exception_not_lost.<locals>.mygreenlet.__getattribute__  s'    #O"33D??s    r   Nr   r   r   r   r*  r   __classdictcell____classdict__s   @r   
mygreenletr(    s     @ @r   r2  c                      R # r$   r   r   r   r   r   <TestGreenlet.test_throw_exception_not_lost.<locals>.<lambda>      tr   N)r*   rF   r   rO   )r<   r2  r+   s   &  r   test_throw_exception_not_lost*TestGreenlet.test_throw_exception_not_lost  s4    	@ 	@ |$)QWWik:r   c                j  aaa . oR  oVVV3R lp\         P                  ! VR7      pVP                  4        VP                  ^
4       ?S'       d   V P	                  4        V P                  \        P                  4      ;_uu_ 4       pS^ ,          P                  \        4       RRR4       S'       g8   \        XP                  4      pT P                  VR8H  ;'       g    RV9   4       M%V P                  \        XP                  4      R4       \        S^ ,          P                  R4      '       dH   V P                  \         4      ;_uu_ 4        S^ ,          P                  P#                  4        RRR4       S'       gZ   \        S^ ,          P                  P$                  R4      '       d,   S^ ,          P                  P$                  P#                  4        M"V P'                  S^ ,          P                  4       ?RoSR RV n        R#   + '       g   i     ELq; i  + '       g   i     L; i)	c                  `    \         P                  ! 4       P                  P                  4        R # r$   r   r   r   r   r  GTestGreenlet._do_test_throw_to_dead_thread_doesnt_crash.<locals>.worker      !((//1r   c                     < \        S4      p V P                  4        SP                  V 4       S'       d(   V P                  4        \        P                  ! 4        R # R # r$   )r*   r   r   r   r   )r+   r  wait_for_cleanupr  s    r   creatorHTestGreenlet._do_test_throw_to_dead_thread_doesnt_crash.<locals>.creator  s?    F#AHHJMM!
##%  r   rv   NBcannot switch to a different thread (which happens to have exited)zCannot switchr   r   T)rx   ry   rz   r{   wait_for_pending_cleanupsrF   r   r   rO   r   rI   rJ   r   r9   r	  r   RuntimeErrorr   f_localsrZ   expect_greenlet_leak)r<   r=  r>  r   r%   sr  r  s   &f    @@r   *_do_test_throw_to_dead_thread_doesnt_crash7TestGreenlet._do_test_throw_to_dead_thread_doesnt_crash  s   	2	& G,			r
 **,x~~..#1IOOI& /  CMM"AOOYY ( ("a'
 CMM"T
 6!9%%w//""<00q	""((* 1  vay))22G<<q	""++113fQi0011I %)!C /.." 10s   	H"H"H	"H2	c                &    V P                  4        R # r$   rF  r@   s   &r   &test_throw_to_dead_thread_doesnt_crash3TestGreenlet.test_throw_to_dead_thread_doesnt_crash  s    779r   c                (    V P                  R 4       R# rs   rI  r@   s   &r   +test_throw_to_dead_thread_doesnt_crash_wait8TestGreenlet.test_throw_to_dead_thread_doesnt_crash_wait  s    77=r   c                     ! R  R\         4      pV! 4       pV P                  VP                  ^*4      ^+4       RV n        R# )c                   2   a  ] tR tRt o R tR tR tRtV tR# )7TestGreenlet.test_recursive_startup.<locals>.convolutedi  c                @    \         P                  ! V 4       ^ V n        R# r  )r*   __init__countr@   s   &r   rS  @TestGreenlet.test_recursive_startup.<locals>.convoluted.__init__  s    $$T*
r   c                    VR 8X  d*   V P                   ^ 8X  d   ^V n         V P                  ^+4       \        P                  ! W4      # rY   )rT  r   r*   r*  r+  s   &&r   r*  HTestGreenlet.test_recursive_startup.<locals>.convoluted.__getattribute__  s6    5=TZZ1_!"DJKKO"33D??r   c                >     V P                   P                  V4       K  )Tr   r   )r<   r   s   &&r   rE   ;TestGreenlet.test_recursive_startup.<locals>.convoluted.run  s    KK&&u-r   )rT  N)	r   r   r   r   rS  r*  rE   r   r/  r0  s   @r   
convolutedrQ    s     @
. .r   r[  TN)r*   r9   r   rD  )r<   r[  r+   s   &  r   test_recursive_startup#TestGreenlet.test_recursive_startup   s9    	. 	. L"r*
 %)!r   c                l  aaa \         P                  ! 4       oSP                  4        \         P                  ! 4       oSP                  4         ! VV3R  lR\        4      pR pVVV3R lp\        P
                  ! 4       p\        V4      .oV! 4       S^ ,          n        S^ ,          P                  4        \         P                  ! VR7      pVP                  4        SP                  4        SP                  4        V P                  \        P
                  ! 4       V4       VP                  ^
4       R# )c                   0   <a  ] tR tRt o VV3R ltRtV tR# );TestGreenlet.test_threaded_updatecurrent.<locals>.finalizedi  c                H   < SP                  4        SP                  4        R # r$   releaseacquire)r<   lock1lock2s   &r   __del__CTestGreenlet.test_threaded_updatecurrent.<locals>.finalized.__del__  s     r   r   Nr   r   r   r   rg  r   r/  )r1  re  rf  s   @r   	finalizedr`    s        r   rj  c                  `    \         P                  ! 4       P                  P                  4        R # r$   r   r   r   r   deallocator=TestGreenlet.test_threaded_updatecurrent.<locals>.deallocator%  r;  r   c                     < SP                  4        \        P                  ! 4        S ^  SP                  4        SP                  4        \        P                  ! 4        SP                  4        R# r  rd  r   r   rc  )r+   re  rf  s   r   fthread9TestGreenlet.test_threaded_updatecurrent.<locals>.fthread'  sF    MMO!!MMOMMO!MMOr   rv   N)rx   Lockrd  objectr   r   r*   bombr   ry   rz   rc  r9   r{   )	r<   rj  rl  rp  r  r   r+   re  rf  s	   &     @@@r   test_threaded_updatecurrent(TestGreenlet.test_threaded_updatecurrent  s      	  	  	 	2	 ""$%&K!		!G,		 	,,.5	r
r   c                   aaa . oVVV3R  loR o\        S4      .oS^ ,          P                  4        \        SS^ ,          4      oSP                  4       pV P                  S4       V P                  V^*4       R# )c                    < \         P                  ! 4       P                  P                  4       p S^  \         P                  ! 4       P                  Sn         \         P                  ! 4       P                  P                  V 4       SP	                  \         P                  ! 4       4       R#   SP	                  \         P                  ! 4       4       i ; ir  )r   r   r   r   r   )r   	initiatorr    r  s    r   r  >TestGreenlet.test_dealloc_switch_args_not_lost.<locals>.workerG  s    '')00779Eq	'224;;I3##%,,33E:H//12H//12s   .B+ +&Cc                      ^*# r   r   r   r   r   ry  ATestGreenlet.test_dealloc_switch_args_not_lost.<locals>.initiatorT      r   N)r*   r   r   r9   )r<   r   ry  r    r  s   & @@@r   !test_dealloc_switch_args_not_lost.TestGreenlet.test_dealloc_switch_args_not_lostE  sk    	3	 f%&q		6!95	  "#r   c                   aaa R  o ! R R\         4      pV! 4       o\        ^*R7      oVVV3R lp\        V4      pV P                  VP	                  4       S4       R# )c                     V ! V/ VB  R # r$   r   )r  rk   ks   &&&r   _apply0TestGreenlet.test_tuple_subclass.<locals>._applym  s    !MqMr   c                   &   a  ] tR tRt o R tRtV tR# )1TestGreenlet.test_tuple_subclass.<locals>.mytupleip  c                r    \         P                  ! 4       P                  4        \        P	                  V 4      # r$   )r   r   r   tuple__len__r@   s   &r   r  9TestGreenlet.test_tuple_subclass.<locals>.mytuple.__len__q  s&    ##%,,.}}T**r   r   N)r   r   r   r   r  r   r/  r0  s   @r   mytupler  p  s     + +r   r  )rk   c                  j   < S ! \         P                  ! 4       P                  P                  SS4       R # r$   r   )r  r   kwargss   r   switchapply5TestGreenlet.test_tuple_subclass.<locals>.switchapplyv  s$    8&&(//66fEr   N)r  dictr*   r9   r   )r<   r  r  r+   r  r   r  s   &   @@@r   test_tuple_subclass TestGreenlet.test_tuple_subclass_  sL    		+e 	+ y	F$V,r   c                    \        R \        3R\        R 4      /4      p ! R RV4      p ! R RV4      pV! 4        V P                  \        V4       R# )AbstractSubclassrE   c                     R # r$   r   r@   s   &r   r   7TestGreenlet.test_abstract_subclasses.<locals>.<lambda>  s    r   c                       ] tR tRtRtR# ):TestGreenlet.test_abstract_subclasses.<locals>.BadSubclassi  r   Nr   r   r   r   BadSubclassr        r   r  c                   &   a  ] tR tRt o R tRtV tR# );TestGreenlet.test_abstract_subclasses.<locals>.GoodSubclassi  c                    R # r$   r   r@   s   &r   rE   ?TestGreenlet.test_abstract_subclasses.<locals>.GoodSubclass.run  s    r   r   N)r   r   r   r   rE   r   r/  r0  s   @r   GoodSubclassr    s      r   r  N)r   r*   r   rF   r  )r<   r  r  r  s   &   r   test_abstract_subclasses%TestGreenlet.test_abstract_subclasses{  sT    "NN#4568
	* 		+ 	 	)[1r   c                   a a \         P                  ! 4       '       g   R # \         P                  ! 4       ^ ,          oS^28  d   R # VV 3R lp\        ^4       F  pV! 4       '       g   K   R # 	  R # )Nc                  V  <a	a
aa \         P                  ! 4       o
S
P                  4        \         P                  ! 4       oSP                  4        R .oV
V3R lp \         P                  ! V R7      pVP	                  4         ! V
VV3R lR\
        4      o	 ! V	3R lR\
        4      p. p\        S^,          4      p\        P                  ! 4       pV! 4       pV FT  pRpS^ ,          '       d   VP                  ^
4        R # \        4       pS^ ,          '       d    MLVP                  V4       KV  	  \        P                  ! 4        S^ ,          '       d   VP                  ^
4       R # SP                  VP                  V4       V F  pSP                  VP                  V4       K!  	  R# )	Fc                  r   < S P                  4        \        P                  ! 4        SP                  4        R # r$   ro  )re  rf  s   r   another_threadWTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.another_thread  s!    ##%r   rv   c                   2   <a  ] tR tRt o VVV3R ltRtV tR# )TTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.gc_callbacki  c                R   < SP                  4        SP                  4        R S^ &   R# rs   rb  )r<   re  rf  recycleds   &r   rg  \TestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.gc_callback.__del__  s    MMOMMO"&HQKr   r   Nri  )r1  re  rf  r  s   @r   gc_callbackr    s     ' 'r   r  c                   .   <a  ] tR tRt o V3R ltRtV tR# )PTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.garbagei  c                ,   < W n         S! 4       V n        R # r$   )cyclecallback)r<   r  s   &r   rS  YTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.garbage.__init__  s    !%J$/MDMr   )r  r  N)r   r   r   r   rS  r   r/  )r1  r  s   @r   garbager    s     2 2r   r  NT)rx   rr  rd  ry   rz   rs  r;   r   r   r{   r*   r   r   r   r9   r   )r  r   r  lr   currentr+   _lastr  re  rf  r  Nr<   s            @@@@r   attempt?TestGreenlet.test_implicit_parent_with_threads.<locals>.attempt  s5   NN$EMMONN$EMMOwH    7AGGI' 'f '
2& 2 Aac
A))+G	AA;;FF2J "}A;;  

A;;FF2JT[['2  73 r   )r   	isenabledget_thresholdr;   )r<   r  r  r  s   f  @r   !test_implicit_parent_with_threads.TestGreenlet.test_implicit_parent_with_threads  sN    ||~~q!r6,	Z qAyy r   c                  a aa ^ RI Ho ^ RI Ho  ! R R\        4      p\        P
                  ! V4      p. S n        VVV 3R lp\        ^
4       F  pV! V4      P                  4        K  	  S =\        '       d)   S P                  \        P
                  ! V4      V4       R# S P                  \        P
                  ! V4      V4       R# )r   r   )r   c                       ] tR tRtRtR# )TTestGreenlet.test_issue_245_reference_counting_subclass_no_threads.<locals>.Greenleti  r   Nr   r   r   r   Greenletr    r  r   r  c                     <  S! 4       P                   P                  4        R #   S  d%    SP                  P                  S! 4       4        R # i ; ir$   )r   r   gletsr   )r   r   r<   s   r   greenlet_mainYTestGreenlet.test_issue_245_reference_counting_subclass_no_threads.<locals>.greenlet_main  s?    0##**, 0

!!*,/0s   $ 'AAN)r   r   r   r*   r   rn   r  r;   r   r
   assertGreaterEqualr9   )r<   r  initial_refsr  r  r   r   s   f    @@r   5test_issue_245_reference_counting_subclass_no_threadsBTestGreenlet.test_issue_245_reference_counting_subclass_no_threads  s     	()	{ 	 x0 
	0 rA]#**,  J&& ##COOH$=|LS__X6Er   z;The manylinux images appear to hang on this test on 3.13rc2c                0  aaaaa ^ RI Hp ^ RI Hp ^ RIHo  ! R R\
        4      o. oV! 4       oV3R loVVVVV3R lp\        P                  ! S4      p. pV^-,           p\        '       d   ^2p\        V4       F5  pV! 4       pV! W83R7      p	VP                  V4       V	P                  4        K7  	  V F  p
V
P                  ^
4       K  	  SR	 SP                  4        V P                  4        V P                  \        P                  ! S4      V4       R
# )r   )ry   )r   r  c                       ] tR tRtRtR# )STestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.MyGreenleti  r   Nr   r   r   r   
MyGreenletr    r  r   r  c                  F   < S ! 4       P                   P                  4        R # r$   rY  r  s   r   r  VTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.greenlet_main   s    L&&(r   c                    < S! S4      pSP                  V4       VP                  4        ?V P                  4        SP                  ^
4       S! 4        R# )
   N)r   r   r   r   )greenlet_running_eventminer  r   r  r  ref_cleareds   & r   thread_mainTTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.thread_main  sH    m,DLLKKM"&&( R  Lr   r   r   N)rx   ry   r   r   r   r*   r   rn   r
   r;   r   rz   r   r   rA  r9   )r<   ry   r   r  r  thread_ready_eventsthread_countr  eventr   r   r  r   r  r  r  s   &          @@@@@r   2test_issue_245_reference_counting_subclass_threads?TestGreenlet.test_issue_245_reference_counting_subclass_threads  s     	%#'	 	 g	)	 	8 z2 #b(&& L|$AGE;X>F&&u-LLN	 % .JOOB . !H 	&&(4lCr   c                    R  p\        V4      pR p\        W24      pV P                  \        4      ;_uu_ 4        VP                  4        RRR4       R#   + '       g   i     R# ; i)c                      ^# )   r   r   r   r   no_args\TestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error.<locals>.no_args:  r~  r   c                      ^*# r|  r   r   r   r   leafYTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error.<locals>.leaf?  r~  r   N)r*   rF   r  r   )r<   r  parent_never_startedr  childs   &    r   >test_falling_off_end_switches_to_unstarted_parent_raises_errorKTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error9  sP    	  +73	 D7 y))LLN *)))s   AA&	c                    R  p\        V4      pR p\        W24      pVP                  4       pV P                  VR4       R# )c                 
    V ^3#    r   r   s   &r   one_argUTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_works.<locals>.one_argI  s    r7Nr   c                      ^*# r|  r   r   r   r   r  RTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_works.<locals>.leafN  r~  r   N)r   r  r   )r<   r  r  r  r  r  s   &     r   7test_falling_off_end_switches_to_unstarted_parent_worksDTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_worksH  s@    	  +73	 D7*r   c                  a  ! R  R\         4      pV! 4       p. o\        V3R lV4      pV P                  \        4      ;_uu_ 4        VP                  4        RRR4       V P	                  S^*.4       V P                  \        4      ;_uu_ 4        VP                  4        RRR4       V P	                  S^*.4       R#   + '       g   i     Ln; i  + '       g   i     L8; i)c                   &   a  ] tR tRt o R tRtV tR# )XTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.ParentiW  c                     VR 8X  d   \         hR# r  )r   r+  s   &&r   r*  iTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.Parent.__getattribute__X  s    5=#O !r   r   Nr.  r0  s   @r   Parentr  W  s     $ $r   r  c                  &   < S P                  ^*4      # r|  r   r   s   r   r   ZTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.<lambda>_      DKKOr   N)r*   rF   r   r   r9   )r<   r  r  r  r    s   &   @r   ;test_switch_to_dead_greenlet_with_unstarted_perverse_parentHTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parentV  s    	$[ 	$  &x35IJ y))LLN * 	t$y))LLN *t$ *)
 *)s   B>C>C	C!	c                  a . o\        V3R  l4      p\        V3R l4      pVP                  4        V P                  S^*.4       Wn        VP                  4       pV P	                  V4       V P                  S^*^.4       R# )c                  &   < S P                  ^4      # r  r  r   s   r   r   DTestGreenlet.test_switch_to_dead_greenlet_reparent.<locals>.<lambda>m  s    4;;r?r   c                  &   < S P                  ^*4      # r|  r  r   s   r   r   r  n  r  r   N)r*   r   r9   r   rZ   )r<   r  r  r  r    s   &   @r   %test_switch_to_dead_greenlet_reparent2TestGreenlet.test_switch_to_dead_greenlet_reparentk  sl    *+BC34t$+&!Bx(r   c                l  aa \         P                  ! 4       oV3R  lpV3R lo\        V4      pVP                  4        \        R 4      pVP                  4        V P	                  VP
                  4       V P                  VP
                  P                  P                  R4       V P	                  VP
                  P                  4       V P                  VP
                  P                  P                  P                  R4       V P                  VP
                  P                  P                  4       R# )c                     < S ! 4        R # r$   r   inners   r   outerHTestGreenlet.test_can_access_f_back_of_suspended_greenlet.<locals>.outer  s    Gr   c                  R   < S P                  \        P                  ! ^ 4      4       R# r  )r   r   r   r  s   r   r
  HTestGreenlet.test_can_access_f_back_of_suspended_greenlet.<locals>.inner  s    KKa()r   c                      R # r$   r   r   r   r   r   KTestGreenlet.test_can_access_f_back_of_suspended_greenlet.<locals>.<lambda>      r   r
  r  N)r   r   r*   r   rS   r   r9   f_codeco_namer   rZ   )r<   r  r  	unrelatedr
  r  s   &   @@r   ,test_can_access_f_back_of_suspended_greenlet9TestGreenlet.test_can_access_f_back_of_suspended_greenlety  s     ""$		* % 

  -	 	S\\*,,44g>S\\001,,33;;WE#,,--445r   c                  aaa ^ RI Ho ^RIHo VVV3R lo\	        S4      pVP                  ^4       VP                  p\        ^4       F2  pV P                  VP                  R,          V4       VP                  pK4  	  V P                  VP                  R,          ^4       V P                  VP                  4       V P                  VP                  ^
4      R4       R# )r   )partial)_test_extension_cppc                    < V ^ 8  d'   V SP                  S! SV ^,
          4      4      ,          # \        P                  ! 4       P                  P	                  4       # r   )	test_callr   r   r   r   )r   r  r  recurses   &r   r  @TestGreenlet.test_get_stack_with_nested_c_calls.<locals>.recurse  sJ    1u.88!a%9PQQQ&&(//6688r   r   i  N)	functoolsr   r  r*   r   r   r;   r9   rC  r   rZ   )r<   grr   r|   r  r  r  s   &   @@@r   "test_get_stack_with_nested_c_calls/TestGreenlet.test_get_stack_with_nested_c_calls  s    %)	9
 !
		!qAU^^C0!4LLE  	,a0%,,'2-r   c                <  aa \         P                  ! 4       oV3R  lpV3R lo\        V4      pVP                  4       p\        R 4      pVP                  4        V P	                  VP
                  P                  R4       V P                  VP                  4       R# )c                  @   < S ! \         P                  ! ^ 4      4       R# r  )r   r   r	  s   r   r  6TestGreenlet.test_frames_always_exposed.<locals>.outer  s    #--"#r   c                 *   < SP                  V 4       R # r$   )r   )r   r  s   &r   r
  6TestGreenlet.test_frames_always_exposed.<locals>.inner  s    KKr   c                      R # r$   r   r   r   r   r   9TestGreenlet.test_frames_always_exposed.<locals>.<lambda>  r  r   r  N)	r   r   r*   r   r9   r  r  rZ   r   )r<   r  r!  r   r  r
  r  s   &    @@r   test_frames_always_exposed'TestGreenlet.test_frames_always_exposed  sx     ""$	$	 		  -	--w7%,,'r   )rD  r  N)F)7r   r   r   r   r=   rA   rL   rP   rV   r[   rd   ro   r   r   r   r   r   unittestskipIfr   r   r   r   r   r   r   r   r   r  r  r  r  r$  r6  r   rF  rJ  rM  r\  ru  r  r  r  r  r  r  r  r  r  r  r  r"  r+  r   r/  r0  s   @r   r/   r/   4   so    .117
!
'(D,1,8+O&6 __&&&G55n+ 	 -& 5"	+C
6	; 7) 7)r : :> ) )*-^$4-82 5n(FT __&&&EDDDDL+%*)6:.&( (r   r/   c                   \   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tRtV tR# )TestGreenletSetParentErrorsi  c                :  aaa / o\         P                  ! 4       o\         P                  ! 4       oVVV3R  lpR p\         P                  ! VR7      pVP                  4        SP	                  ^
4       \        V4      pVP                  4        V P                  \        4      ;_uu_ 4       pSR,          Vn	        RRR4       SP                  4        VP                  ^
4       V P                  \        XP                  4      R4       R#   + '       g   i     LX; i)c                  h   < \        R  4      SR&   S P                  4        SP                  ^
4       R# )c                      R # r$   r   r   r   r   r   QTestGreenletSetParentErrors.test_threaded_reparent.<locals>.run.<locals>.<lambda>  r   r   r+   Nr   r   s   r   rE   ?TestGreenletSetParentErrors.test_threaded_reparent.<locals>.run  r   r   c                  `    \         P                  ! 4       P                  P                  4        R # r$   r   r   r   r   blankATestGreenletSetParentErrors.test_threaded_reparent.<locals>.blank  r;  r   rv   r+   Nz&parent cannot be on a different thread)rx   r   ry   rz   r   r*   r   rF   r   r   r   r{   r9   rI   rJ   )	r<   rE   r7  r   r+   r%   r   r   r   s	   &     @@@r   test_threaded_reparent2TestGreenletSetParentErrors.test_threaded_reparent  s    !)__&
	 
	2 !!-2	
z**cCyAH +BS]]+-UV +*s   +D

D	c                  a . oV3R  lp\         P                  ! VR7      pVP                  4        VP                  ^
4       V P	                  V P
                  ^,           R7        ! V3R lR\        4      pV! R 4      pV P                  \        P                  4      ;_uu_ 4       pVP                  4        RRR4       V P                  \        XP                  4      R4       SR R#   + '       g   i     L:; i)	c                  b   < \        R  4      p SP                  V 4       V P                  4        R# )c                      R # r$   r   r   r   r   r   YTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.worker.<locals>.<lambda>      Dr   N)r*   r   r   )r+   anothers    r   r  GTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.worker  s"    L)ANN1HHJr   rv   )initial_main_greenletsc                   .   <a  ] tR tRt o V3R ltRtV tR# )KTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.convolutedi  c                Z   < VR 8X  d   S^ ,          V n         \        P                  ! W4      # rY   r   r*   r*  r<   r,  r@  s   &&r   r*  \TestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.convoluted.__getattribute__  &    5=")!*DK"33D??r   r(   Nr.  r1  r@  s   @r   r[  rD         @ @r   r[  c                      R # r$   r   r   r   r   r   ITestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.<lambda>  r5  r   Nr@  r   )rx   ry   rz   r{   rA  main_greenlets_before_testr*   rF   r   r   r   r9   rI   rJ   )r<   r  r   r[  r+   r%   r@  s   &     @r   test_unexpected_reparenting7TestGreenletSetParentErrors.test_unexpected_reparenting  s    	 F+			r
& 	&&d>]>]`a>a&b	@ 	@
 |$x~~..#HHJ /S]]+]	_AJ	 /.s   'C**C:	c                :  aaa . o\         P                  ! 4       o\         P                  ! 4       oVVV3R  lp ! V3R lR\        4      p\         P                  ! VR7      pVP	                  4        SP                  ^
4        V! R 4      pV P                  \        P                  4      ;_uu_ 4       pVP                  4        RRR4       V P                  R\        XP                  4      4       V P                  R\        VP                  4      4       V P                  R\        VP                  4      4       SP                  4        VP                  ^
4       SR	 R#   + '       g   i     L; i  SP                  4        TP                  ^
4       SR	 i ; i)
c                     < \        R  4      p SP                  V 4       V P                  4        SP                  4        SP	                  ^
4       R# )c                      R # r$   r   r   r   r   r   hTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.worker.<locals>.<lambda>  r?  r   N)r*   r   r   r   r   )r+   r@  keep_main_aliveswitched_to_greenlets    r   r  VTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.worker  s<    L)ANN1HHJ $$&  $r   c                   .   <a  ] tR tRt o V3R ltRtV tR# )ZTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.convolutedi  c                Z   < VR 8X  d   S^ ,          V n         \        P                  ! W4      # rY   rF  rG  s   &&r   r*  kTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.convoluted.__getattribute__  rI  r   r(   Nr.  rJ  s   @r   r[  rY    rK  r   r[  rv   c                      R # r$   r   r   r   r   r   XTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.<lambda>      4r   Nz#Cannot switch to a different threadExpectedCurrentr   )rx   r   r*   ry   rz   r   rF   r   r   r   rH   rI   rJ   r   r{   )	r<   r  r[  r   r+   r%   r@  rU  rV  s	   &     @@@r   *test_unexpected_reparenting_thread_runningFTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running  s!    (0#//+	%	@ 	@ F+		!!"%	<(A""8>>22c
 3MM?S]]ASTMM*c#--&89MM)S%78!FF2J
 32 !FF2J
s%   0E4 3E!A7E4 !E1	,E4 4&Fc                <   \        R  4      pV P                  VP                  \        P                  ! 4       4       V P                  \        4      ;_uu_ 4       pV=RRR4       V P                  \        XP                  4      R4       R#   + '       g   i     L7; i)c                      R # r$   r   r   r   r   r   GTestGreenletSetParentErrors.test_cannot_delete_parent.<locals>.<lambda>*      Tr   Ncan't delete attribute)
r*   rT   r   r   r   rF   rG   r9   rI   rJ   )r<   r  r%   s   &  r   test_cannot_delete_parent5TestGreenletSetParentErrors.test_cannot_delete_parent)  sg    \*fmmX%8%8%:;~..# /S]]+-EF /.s   BB	c                    V P                  \        4      ;_uu_ 4       p\        P                  ! 4       =R R R 4       V P                  \        XP                  4      R4       R #   + '       g   i     L7; i)Nrg  rF   rG   r   r   r   r9   rI   rJ   r<   r%   s   & r   !test_cannot_delete_parent_of_main=TestGreenletSetParentErrors.test_cannot_delete_parent_of_main1  sL    ~..###%, /S]]+-EF /.s   A##A3	c                b    V P                  \        P                  ! 4       P                  4       R # r$   )rZ   r   r   r   r@   s   &r   !test_main_greenlet_parent_is_none=TestGreenletSetParentErrors.test_main_greenlet_parent_is_none7  s    (--/667r   c                   a  R  pV 3R lp\        V4      pS P                  V4       V! V4       VP                  4        S P                  V4       V! V4       VP                  4        R# )c                  `    \         P                  ! 4       P                  P                  4        R # r$   r   r   r   r   bgCTestGreenletSetParentErrors.test_set_parent_wrong_types.<locals>.bg<  s    !((//1r   c                   < R ^SR3 Fn  pSP                  \        4      ;_uu_ 4       pWn        R R R 4       SP                  \	        XP
                  4      R\        V4      P                  ,           4       Kp  	  R #   + '       g   i     LU; i)N42z4GreenletChecker: Expected any type of greenlet, not )rF   r  r   r9   rI   rJ   typer   )gletpr%   r<   s   &  r   checkFTestGreenletSetParentErrors.test_set_parent_wrong_types.<locals>.check@  sj    1dD(&&y11S"#K 2   &JTRSWM]M]]_	 )11s   A<<BN)r*   r   r   r   )r<   rt  r{  r+   s   f   r   test_set_parent_wrong_types7TestGreenletSetParentErrors.test_set_parent_wrong_types;  sW    	2	_ Oa 	

a 	

r   c                    \        R  4      pV P                  \        4      ;_uu_ 4       pWn        RRR4       V P	                  \        XP                  4      R4       R#   + '       g   i     L7; i)c                      R # r$   r   r   r   r   r   @TestGreenletSetParentErrors.test_trivial_cycle.<locals>.<lambda>X  r^  r   Ncyclic parent chain)r*   rF   r   r   r9   rI   rJ   )r<   ry  r%   s   &  r   test_trivial_cycle.TestGreenletSetParentErrors.test_trivial_cycleW  sL    <(z**cK +S]]+-BC +*s   A  A0	c                   V P                  \        4      ;_uu_ 4       p\        P                  ! 4       \        P                  ! 4       n        R R R 4       V P                  \        XP                  4      R4       R #   + '       g   i     L7; i)Nz(cannot set the parent of a main greenletrk  rl  s   & r   test_trivial_cycle_main3TestGreenletSetParentErrors.test_trivial_cycle_main]  sW    ~..#+3+>+>+@H!( /S]]+-WX /.s   .A;;B	c                .   \        R  4      p\        R 4      p\        R 4      pW!n        W2n        V P                  \        4      ;_uu_ 4       pWn        RRR4       V P	                  \        XP                  4      R4       R#   + '       g   i     L7; i)c                      R # r$   r   r   r   r   r   ?TestGreenletSetParentErrors.test_deeper_cycle.<locals>.<lambda>d  r#  r   c                      R # r$   r   r   r   r   r   r  e  r#  r   c                      R # r$   r   r   r   r   r   r  f  r#  r   Nr  )r*   r   rF   r   r9   rI   rJ   )r<   r,   r   g3r%   s   &    r   test_deeper_cycle-TestGreenletSetParentErrors.test_deeper_cyclec  sj    &&&		z**cI +S]]+-BC +*s   BB	r   N)r   r   r   r   r9  rO  ra  rh  rm  rp  r}  r  r  r  r   r/  r0  s   @r   r0  r0    sE     W2'R"HGG88DY	D 	Dr   r0  c                   l   a  ] tR tRt o ]! ]R4      '       g   RR ltR tR tR t	R t
R	 tR
 tRtV tR# )TestReprio  assertEndsWithNc                L    V P                  VP                  V4      WV34       R # r$   )r   endswith)r<   rE  suffixmsgs   &&&&r   r  TestRepr.assertEndsWithr  s    OOAJJv.C0@Ar   c                f    \        \        P                  ! 4       4      pV P                  VR 4       R# ) current active started main>N)reprr   r   r  r<   rs   & r   test_main_while_running TestRepr.test_main_while_runningu  s&    $$&'A>?r   c                   a \         P                  ! 4       oV3R  lp\        V4      pVP                  4       pV P	                  VR4       R# )c                     < \        S 4      # r$   )r  r  s   r   rE   -TestRepr.test_main_in_background.<locals>.run{  s    :r    suspended active started main>N)r   r   r*   r   r  )r<   rE   r+   r  r  s   &   @r   test_main_in_background TestRepr.test_main_in_backgroundy  s>    ""$	 HHJA@Ar   c                P    \        \        4       4      pV P                  VR 4       R# )z	 pending>N)r  r*   r  r  s   & r   test_initialTestRepr.test_initial  s    A{+r   c                6  a \         P                  ! 4       o ! V3R  lR\        P                  4      pV! 4       pVP	                  4        VP                  ^
4       V P                  VP                  R4       V P                  VP                  R4       \        ^4       F  p\        P                  ! R4       K  	  \        ^4       FO  pV P                  VP                  P                  4       \        VP                  4      pV P                  VR4       KQ  	  R# )c                   :   <a  ] tR tRt o R;ttRtV3R ltRtV t	R# )/TestRepr.test_main_from_other_thread.<locals>.Ti  Nc                   < \        S4      V n        \        P                  ! 4       V n        \        V P                  4      V n        R # r$   )r  original_mainr   r   	main_gletr  )r<   r  s   &r   rE   3TestRepr.test_main_from_other_thread.<locals>.T.run  s0    %)$Z"!)!4!4!6#'#7 r   )r  r  r  )
r   r   r   r   r  r  r  rE   r   r/  )r1  r  s   @r   Tr    s     *..MKI8 8r   r  r  r  gMbP?z (thread exited) dead>N)r   r   rx   ry   rz   r{   r  r  r  r;   r   r   r   r  rb   r  )r<   r  r   r  r  r  s   &    @r   test_main_from_other_thread$TestRepr.test_main_from_other_thread  s    ""$	8	   	8 C			r
AOO-NOAMM+JK qAJJu  qAOOAKK,,-Q[[!A#;< r   c                   \        R  4      pVP                  4        V P                  \        V4      R4       V P	                  R\        V4      4       V P	                  R\        V4      4       V P	                  R\        V4      4       R# )c                      R # r$   r   r   r   r   r   $TestRepr.test_dead.<locals>.<lambda>  s    r   z dead>	suspendedstartedactiveN)r*   r   r  r  assertNotInrU   s   & r   	test_deadTestRepr.test_dead  se    %	
DGX.d1g.DG,47+r   c                    \        R  4      p\        R 4      p\        P                  ! 4       pWV3 F3  pV P                  V: \        4       V P                  V: \        4       K5  	  R# )c                      R # r$   r   r   r   r   r   >TestRepr.test_formatting_produces_native_str.<locals>.<lambda>  rf  r   c                      R # r$   r   r   r   r   r   r    r   r   N)r*   r   r   assertIsInstancerI   )r<   g_deadg_not_startedg_curr+   s   &    r   #test_formatting_produces_native_str,TestRepr.test_formatting_produces_native_str  s_     \*#L1##%-A!! !! .r   r   r$   )r   r   r   r   r	  r   r  r  r  r  r  r  r  r   r/  r0  s   @r   r  r  o  s?     8-..	B@B,!=F, r   r  c                   2   a  ] tR tRt o R tR tR tRtV tR# )TestMainGreenleti  c                    R \        \        P                  ! 4       4      9   g   Q h\        \        P                  ! 4       4      pR \        V4      9  g   Q hV# r  )r  r   r   rx  )r<   r   s   & r   _check_current_is_main'TestMainGreenlet._check_current_is_main  sH    h1134444$$&'T!W$$$r   c                d    V P                  4       p\        R V3/ 4      pV P                  V4       R# )subclassN)r  rx  rS   )r<   	main_typer  s   &  r   )test_main_greenlet_type_can_be_subclassed:TestMainGreenlet.test_main_greenlet_type_can_be_subclassed  s.    //1	
YL"5X&r   c                x    V P                  4        V P                  \        P                  ! 4       \        4       R # r$   )r  r  r   r   r*   r@   s   &r   test_main_greenlet_is_greenlet/TestMainGreenlet.test_main_greenlet_is_greenlet  s'    ##%h113[Ar   r   N)	r   r   r   r   r  r  r  r   r/  r0  s   @r   r  r    s     '
B Br   r  c                   P   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
tV tR# )TestBrokenGreenletsi  c                    R  p\         P                  P                  V4      pRVn        V P	                  \
        R4      ;_uu_ 4        VP                  4        RRR4       R#   + '       g   i     R# ; i)c                      \        R 4      h)zNever get here)AssertionErrorr   r   r   r  <TestBrokenGreenlets.test_failed_to_initialstub.<locals>.func  s     !122r   Tz;Failed to switch stacks into a greenlet for the first time.N)r   	_greenletUnswitchableGreenletforce_switch_errorassertRaisesRegexSystemErrorr   )r<   r  r+   s   &  r   test_failed_to_initialstub.TestBrokenGreenlets.test_failed_to_initialstub  sc    	3 33D9###K$ac cHHJc c c cs   A##A4	c                  a . oV3R  lp\         P                  P                  V4      pVP                  4        V P	                  S^.4       VP                  4        V P	                  S^^.4       RVn        V P                  \        R4      ;_uu_ 4        VP                  4        RRR4       RVn        VP                  4        V P	                  S. RO4       R#   + '       g   i     L=; i)c                  "  < S P                  ^4       \        P                  ! 4       P                  P	                  4        S P                  ^4       \        P                  ! 4       P                  P	                  4        S P                  ^4       R# r2   r4   )runss   r   r  DTestBrokenGreenlets.test_failed_to_switch_into_running.<locals>.func  sZ    KKN!((//1KKN!((//1KKNr   Tz0Failed to switch stacks into a running greenlet.NF)r3   r   r   )r   r  r  r   r9   r  r  r  )r<   r  r+   r  s   &  @r   "test_failed_to_switch_into_running6TestBrokenGreenlets.test_failed_to_switch_into_running  s    	 33D9	
s#	
1v&###K$VX XHHJX  %	
y)X Xs   CC+	c                    V P                  R 4      pV P                  RVP                  4       V P                  VP                  V P	                  4       4       R# )zfail_slp_switch.pyzfail_slp_switch is runningN)assertScriptRaisesrH   output
returncode,get_expected_returncodes_for_aborted_processr<   exs   & r   &test_failed_to_slp_switch_into_running:TestBrokenGreenlets.test_failed_to_slp_switch_into_running  sA    $$%9:2BII>bmmT%V%V%XYr   c                    V P                  R 4      pV P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       R# )zfail_switch_two_greenlets.pyz	In g1_runTRACEzLEAVE TRACEzFalling off end of mainzFalling off end of g1_runzFalling off end of g2N
run_scriptrH   r<   r  s   & r   #test_reentrant_switch_two_greenlets7TestBrokenGreenlets.test_reentrant_switch_two_greenlets  sh    !?@k6*gv&mV,/816:-v6r   c                    V P                  R RR7      pV P                  RVP                  4       V P                  RVP                  4       R# )zfail_switch_three_greenlets.py)	exitcodesr  zpositional argumentsN)r3   )r  rH   r  r  s   & r   %test_reentrant_switch_three_greenlets9TestBrokenGreenlets.test_reentrant_switch_three_greenlets  s@     $$%EQU$Vk299-,bii8r   c                L    V P                  R 4      pV P                  RV4       R# )zfail_switch_three_greenlets2.pya  RESULTS: [('trace', 'switch'), ('trace', 'switch'), ('g2 arg', 'g2 from tracefunc'), ('trace', 'switch'), ('main g1', 'from g2_run'), ('trace', 'switch'), ('g1 arg', 'g1 from main'), ('trace', 'switch'), ('main g2', 'from g1_run'), ('trace', 'switch'), ('g1 from parent', 'g1 from main 2'), ('trace', 'switch'), ('main g1.2', 'g1 done'), ('trace', 'switch'), ('g2 from parent', ()), ('trace', 'switch'), ('main g2.2', 'g2 done')]Nr  r  s   & r   &test_reentrant_switch_three_greenlets2:TestBrokenGreenlets.test_reentrant_switch_three_greenlets2!  s)     !BC= 		
r   c                L    V P                  R 4      pV P                  RV4       R# )z#fail_initialstub_already_started.pya!  RESULTS: ['Begin C', 'Switch to b from B.__getattribute__ in C', ('Begin B', ()), '_B_run switching to main', ('main from c', 'From B'), 'B.__getattribute__ back from main in C', ('Begin A', (None,)), ('A dead?', True, 'B dead?', True, 'C dead?', False), 'C done', ('main from c.2', None)]Nr  r  s   & r   4test_reentrant_switch_GreenletAlreadyStartedInPythonHTestBrokenGreenlets.test_reentrant_switch_GreenletAlreadyStartedInPython3  s'    !FG1
 	
r   c                L    V P                  R 4      pV P                  RV4       R# )zfail_clearing_run_switches.pyzRESULTS [('G.__getattribute__', 'run'), ('RunCallable', '__del__'), ('main: g.switch()', 'from RunCallable'), ('run_func', 'enter')]Nr  r  s   & r   *test_reentrant_switch_run_callable_has_del>TestBrokenGreenlets.test_reentrant_switch_run_callable_has_del?  s'    !@A 	
r   r   N)r   r   r   r   r  r  r  r  r  r  r  r   r   r/  r0  s   @r   r  r    s3     
*8Z79
$


 
r   r  c                   `   a  ] tR tRt o ]P
                  ! ]! ]R4      R4      R 4       tRt	V t
R# )
TestModuleiI  _is_gil_enabledz,Needs 3.13 and above for sys._is_gil_enabledc                    \         '       d'   V P                  \        P                  ! 4       4       R # V P	                  \        P                  ! 4       4       R # r$   )r
   r   r   r  r   r@   s   &r   test_no_gil_on_free_threaded'TestModule.test_no_gil_on_free_threadedK  s6     '&S0023OOC//12r   r   N)r   r   r   r   r-  
skipUnlessr	  r   r  r   r/  r0  s   @r   r  r  I  s1     &78GI3I3r   r  __main__)r   r   r   rx   r-  abcr   r   r   r*   r   r   r   r   r	   r
   	leakcheckr   r   r   r!   r-   r/   r0  r  r  r  r  r   r  r   r   r   <module>r     s    	 
       ,  "   ) &		 	K(8 K(\jD( jDZSx SlBx B.k
( k
Z	3 	3 zMMO r   