a
    xˆc“  ã                   @   sô   d dl mZ d dl mZ d dl mZ d dlZd dlZd dlZd dlZd dlm	Z	m
Z
 d dlmZ ddlmZ dd	lmZ G d
d„ deƒZdd„ Zdd„ ZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZedkrðd dlZe ¡  dS )é    )Úabsolute_import)Údivision)Úprint_functionN)ÚABCMetaÚabstractmethod)Úgreenleté   )ÚTestCase)Úfails_leakcheckc                   @   s   e Zd ZdS )Ú	SomeErrorN©Ú__name__Ú
__module__Ú__qualname__© r   r   ú_/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/greenlet/tests/test_greenlet.pyr      s   r   c                 C   s<   zt  ¡ j ¡  W n    |  t ¡ d ¡ ‚ Y n0 t‚d S ©Nr   )r   Ú
getcurrentÚparentÚswitchÚappendÚsysÚexc_infor   ©Úseenr   r   r   Úfmain   s    r   c                 C   s"   dd„ }t || d�}| |¡ d S )Nc                 S   s   | ‚d S ©Nr   )Úexcr   r   r   Úcrasher%   s    zsend_exception.<locals>.crasher©r   ©r   r   )Úgr   r   Úg1r   r   r   Úsend_exception"   s    r#   c                   @   sb  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ ZedUd6d7„ƒZed8d9„ ƒZd:d;„ Z ed<d=„ ƒZ!d>d?„ Z"d@dA„ Z#dBdC„ Z$dDdE„ Z%dFdG„ Z&dHdI„ Z'dJdK„ Z(dLdM„ Z)dNdO„ Z*dPdQ„ Z+dRdS„ Z,dTS )VÚTestGreenletc                    s^   g ‰ ‡ fdd„}t |ƒ}ˆ  d¡ | ¡  ˆ  d¡ | ¡  ˆ  d¡ |  ˆ ttdƒƒ¡ d S )Nc                      s&   ˆ   d¡ t ¡ j ¡  ˆ   d¡ d S )Nr   é   ©r   r   r   r   r   r   ©Úlstr   r   Úf0   s    
z'TestGreenlet._do_simple_test.<locals>.fr   é   é   é   )r   r   r   ÚassertEqualÚlistÚrange)Úselfr)   r!   r   r'   r   Ú_do_simple_test-   s    


zTestGreenlet._do_simple_testc                 C   s   |   ¡  d S r   )r1   ©r0   r   r   r   Útest_simple<   s    zTestGreenlet.test_simplec                 C   sN   t ƒ }|  t¡�}| ¡  W d   ƒ n1 s.0    Y  |  dt|jƒ¡ d S ©NÚrun)r   ÚassertRaisesÚAttributeErrorr   ÚassertInÚstrÚ	exception©r0   r!   r   r   r   r   Ú(test_switch_no_run_raises_AttributeError?   s    &z5TestGreenlet.test_switch_no_run_raises_AttributeErrorc                 C   sP   t ƒ }|  t¡�}| t¡ W d   ƒ n1 s00    Y  |  dt|jƒ¡ d S r4   )r   r6   r7   Úthrowr   r8   r9   r:   r;   r   r   r   Ú'test_throw_no_run_raises_AttributeErrorF   s    (z4TestGreenlet.test_throw_no_run_raises_AttributeErrorc                 C   s*   t d d�}|  |¡ |  |jt  ¡ ¡ d S )Nr   )r   ÚassertIsNotNoneÚassertIsr   r   ©r0   r!   r   r   r   Útest_parent_equals_NoneM   s    

z$TestGreenlet.test_parent_equals_Nonec                 C   s$   t d d�}|  |¡ |  |j¡ d S )N)r5   )r   r?   ÚassertIsNoner5   rA   r   r   r   Útest_run_equals_NoneR   s    

z!TestGreenlet.test_run_equals_Nonec                    s    g ‰ ‡ fdd„}t |ƒ}t |ƒ}| ¡  |  tˆ ƒd¡ | ¡  |  tˆ ƒd¡ | ¡  |  tˆ ƒd¡ |  |jd¡ | ¡  |  tˆ ƒd¡ |  |jd¡ d S )Nc                      s*   ˆ   d¡ t ¡ j ¡  ˆ  ddg¡ d S )Nr   )r   r   r   r   r   Úextendr   r'   r   r   r)   Z   s    
z)TestGreenlet.test_two_children.<locals>.fr   r*   r+   Té   )r   r   r-   ÚlenÚdead)r0   r)   r!   Úhr   r'   r   Útest_two_childrenW   s    zTestGreenlet.test_two_childrenc                    sf   g ‰‡fdd„‰ ‡ ‡fdd„}t |ƒ}|  t |¡d¡ | ¡  |  ˆg d¢¡ |  t |¡d¡ d S )Nc                      s   ˆ   d¡ t ¡ j ¡  d S )NÚbr&   r   r'   r   r   r)   n   s    
z3TestGreenlet.test_two_recursive_children.<locals>.fc                     s(   ˆ  d¡ tˆ ƒ} |  ¡  ˆ  d¡ d S )NÚaÚc)r   r   r   ©r!   ©r)   r(   r   r   r!   r   s    
z3TestGreenlet.test_two_recursive_children.<locals>.gr*   )rL   rK   rM   )r   r-   r   Úgetrefcountr   rA   r   rO   r   Útest_two_recursive_childrenk   s    z(TestGreenlet.test_two_recursive_childrenc                    sf   g ‰‡‡fdd„‰ ‡ fdd„t dƒD ƒ}|D ]}| ¡  q,|D ]}| d¡ q>ˆ tˆƒt|ƒ¡ d S )Nc                      s   ˆ   ¡  ˆ d¡ d S ©NT)r1   r   r   )r0   Úsuccessr   r   r)   ‚   s    z$TestGreenlet.test_threads.<locals>.fc                    s   g | ]}t jˆ d �‘qS )©Útarget)Ú	threadingÚThread)Ú.0Úi©r)   r   r   Ú
<listcomp>…   ó    z-TestGreenlet.test_threads.<locals>.<listcomp>é
   )r/   ÚstartÚjoinr-   rG   )r0   ZthsÚthr   )r)   r0   rS   r   Útest_threads   s    
zTestGreenlet.test_threadsc                 C   s    g }t tƒ}t tƒ}| |¡ | |¡ ||_|  |g ¡ |  t|j¡ |  |tg¡ | ¡ }|  |d¡ |  |tg¡ | d¡}|  |d¡ |  |tg¡ d S )Nr   é   )r   r   r   r   r-   r6   r   )r0   r   r"   Úg2Úvaluer   r   r   Útest_exceptionŒ   s    


zTestGreenlet.test_exceptionc                 C   s8   g }t tƒ}| |¡ |  tt|t¡ |  |tg¡ d S r   )r   r   r   r6   ÚKeyErrorr#   r-   )r0   r   r"   r   r   r   Útest_send_exception¨   s
    
z TestGreenlet.test_send_exceptionc                 C   sp   g }t tƒ}t tƒ}| |¡ | |¡ |  |g ¡ ~t ¡  |  |t jg¡ ~t ¡  |  |t jt jg¡ d S r   )r   r   r   r-   ÚgcÚcollectÚGreenletExit)r0   r   r"   rc   r   r   r   Útest_dealloc¯   s    

zTestGreenlet.test_deallocc                 C   s    dd„ }t |ƒ}| ¡  tj}zddlm} W n tyL   ddlm} Y n0 |ƒ  }t_z~W |t_n|t_0 | ¡ }|  	d|¡ |  	d|¡ |  	d|¡ d S )Nc                   S   s0   zt  ¡ j ¡  W n t jy*   t‚Y n0 d S r   )r   r   r   r   rj   r   r   r   r   r   r5   ¾   s    zHTestGreenlet.test_dealloc_catches_GreenletExit_throws_other.<locals>.runr   )ÚStringIOÚ	ExceptionZignoredr   )
r   r   r   ÚstderrÚ	cStringIOrl   ÚImportErrorÚioÚgetvaluer8   )r0   r5   r!   Z	oldstderrrl   rn   Úvr   r   r   Ú.test_dealloc_catches_GreenletExit_throws_other½   s     z;TestGreenlet.test_dealloc_catches_GreenletExit_throws_otherc              	      s  g ‰g ‰t  ¡ ‰ t  ¡ ‰t  ¡ ‰t  ¡ ‰‡ ‡‡‡‡‡fdd„}t j|d�}| ¡  ˆ  d¡ |  ˆg ¡ |  tˆƒd¡ ˆd d …= t ¡  |  ˆg ¡ ˆ 	¡  ˆ d¡ z:|  ˆt
jg¡ W ˆ 	¡  | d¡ ˆd d …= ˆd d …= n(ˆ 	¡  | d¡ ˆd d …= ˆd d …= 0 d S )Nc                     sZ   t tƒ} |  ˆ¡ ˆ | ¡ ~ t ¡  ˆ  ¡  ˆ d¡ t ƒ  ˆ ¡  ˆ d¡ t ƒ  d S )Nr%   )r   r   r   r   rh   ri   ÚsetÚwait)r"   ©Z/bg_glet_created_running_and_no_longer_ref_in_bgZbg_should_be_clearZfg_ref_releasedZok_to_exit_bg_threadr   Zsomerefr   r   r)   ä   s    



z1TestGreenlet.test_dealloc_other_thread.<locals>.frT   r]   r   r%   )rV   ÚEventrW   r^   rv   r-   rG   rh   ri   ru   r   rj   r_   )r0   r)   Útr   rw   r   Útest_dealloc_other_threadÛ   s6    




ý

z&TestGreenlet.test_dealloc_other_threadc                    sf   ‡ fdd„}t |ƒ}| ¡ }ˆ  ||ju ¡ ˆ  |¡ | ¡ }ˆ  |¡ ˆ  |d¡ ˆ  |jd ¡ d S )Nc                     s,   t  d¡} ˆ  | jd ¡ t ¡ j | ¡ dS )Nr   úmeaning of life)r   Ú	_getframer-   Úf_backr   r   r   r   rZ   r2   r   r   Úf1  s    
z#TestGreenlet.test_frame.<locals>.f1r{   )r   r   Ú
assertTrueÚgr_frameÚassertFalser-   )r0   r~   r!   ÚframeZfrom_gr   r2   r   Ú
test_frame  s    

zTestGreenlet.test_framec                 C   sL   dd„ }t j|dd�}t j|dd�}| ¡  | ¡  | d¡ | d¡ d S )Nc                    s   t ‡ fdd„ƒ}| ¡  d S )Nc                      s
   t  ˆ ¡S r   )ÚtimeÚsleepr   ©Úxr   r   Ú<lambda>  r\   z>TestGreenlet.test_thread_bug.<locals>.runner.<locals>.<lambda>r    )r‡   r!   r   r†   r   Úrunner  s    z,TestGreenlet.test_thread_bug.<locals>.runner)gš™™™™™É?©rU   Úargs)g333333Ó?r]   )rV   rW   r^   r_   )r0   r‰   Út1Út2r   r   r   Útest_thread_bug  s    
zTestGreenlet.test_thread_bugc                    s.   ‡ fdd„}t |ƒjddd�}ˆ  |d¡ d S )Nc                    s   ˆ   | d¡ ˆ   |d¡ dS )Nr+   r*   é*   )r-   ©rL   rK   r2   r   r   r5   #  s    z,TestGreenlet.test_switch_kwargs.<locals>.runr+   r*   r�   r�   ©r   r   r-   )r0   r5   r‡   r   r2   r   Útest_switch_kwargs"  s    zTestGreenlet.test_switch_kwargsc                 C   sR   dd„ }t |ƒ}|  ddi| d¡¡ |  dddif| ¡ ¡ |  d| ¡ ¡ d S )Nc                 S   s2   t  ¡ jj| d� t  ¡ jjddd� | | d fS )Nr†   r*   r%   ©r   r   r   r   r†   r   r   r   r5   +  s    z6TestGreenlet.test_switch_kwargs_to_parent.<locals>.runr‡   r%   )r*   )r%   é	   )r   r-   r   )r0   r5   r!   r   r   r   Útest_switch_kwargs_to_parent*  s
    z)TestGreenlet.test_switch_kwargs_to_parentc                    s˜   i ‰t  ¡ ‰ t  ¡ ‰‡ ‡‡fdd„}t j|d�}| ¡  ˆ  d¡ |  tj¡� ˆd  ¡  W d   ƒ n1 sp0    Y  ˆ 	¡  | 
d¡ ˆ ¡  d S )Nc                      s&   t dd„ ƒˆd< ˆ  ¡  ˆ d¡ d S )Nc                   S   s   d S r   r   r   r   r   r   rˆ   :  r\   zITestGreenlet.test_switch_to_another_thread.<locals>.run.<locals>.<lambda>r!   r]   ©r   ru   rv   r   ©Zcreated_eventÚdataÚ
done_eventr   r   r5   9  s    z7TestGreenlet.test_switch_to_another_thread.<locals>.runrT   r]   r!   )rV   rx   rW   r^   rv   r6   r   Úerrorr   ru   r_   Úclear)r0   r5   Úthreadr   r—   r   Útest_switch_to_another_thread4  s    
*
z*TestGreenlet.test_switch_to_another_threadc                    s*   ‡ ‡fdd„}‡fdd„‰ t |ƒ ¡  d S )Nc                     sB   zt dƒ‚W n0   t ¡ } tˆ ƒ ¡  ˆ | t ¡ ¡ Y n0 d S )NZfun)Ú
ValueErrorr   r   r   r   r-   )r   ©rI   r0   r   r   r)   H  s    z&TestGreenlet.test_exc_state.<locals>.fc                      s   ˆ   t ¡ d¡ d S )N)NNN)r-   r   r   r   r2   r   r   rI   P  s    z&TestGreenlet.test_exc_state.<locals>.hr    )r0   r)   r   rŸ   r   Útest_exc_stateG  s    zTestGreenlet.test_exc_statec                 C   s’   dd„ }dd„ }dd„ }t |ƒ}|  |ji ¡ | ¡  |  |jd¡ |  |jddi¡ |j|_|  |jddi¡ |  t||¡ |  t||d¡ d S )	Nc                   S   s   dt  ¡ _d S ©Nr�   )r   r   Útestr   r   r   r   r)   V  s    z*TestGreenlet.test_instance_dict.<locals>.fc                 S   s   | ` d S r   ©Ú__dict__rN   r   r   r   ÚdeldictX  s    z0TestGreenlet.test_instance_dict.<locals>.deldictc                 S   s
   || _ d S r   r£   )r!   rd   r   r   r   ÚsetdictZ  s    z0TestGreenlet.test_instance_dict.<locals>.setdictr�   r¢   )r   r-   r¤   r   r¢   r6   Ú	TypeError)r0   r)   r¥   r¦   r!   r   r   r   Útest_instance_dictU  s    zTestGreenlet.test_instance_dictc                    s2   g ‰ ‡ fdd„}t |ƒ}| ¡  |  ˆ dg¡ d S )Nc                      s   ˆ   tt ¡ dƒ¡ d S r4   )r   Úhasattrr   r   r   ©Zhas_runr   r   Úfunch  s    ÿz;TestGreenlet.test_running_greenlet_has_no_run.<locals>.funcFr‘   )r0   r«   r!   r   rª   r   Ú test_running_greenlet_has_no_runf  s
    z-TestGreenlet.test_running_greenlet_has_no_runc                 C   s0   dd l }|  t|j tƒ ¡ |  t|jtƒ ¡ d S r   )Úcopyr6   r§   r   Údeepcopy)r0   r­   r   r   r   Útest_deepcopyq  s    zTestGreenlet.test_deepcopyc                    s€   t dd„ ƒ‰ t  ¡ ‰g ‰‡ ‡‡fdd„}t |ˆ d�}| ¡  ~|  ˆ¡ |  ˆd ˆ¡ |  ˆd jˆ ¡ ˆd d …= d ‰ d ‰d S )Nc                   S   s   d S r   r   r   r   r   r   rˆ   w  r\   z;TestGreenlet.test_parent_restored_on_kill.<locals>.<lambda>c                      sL   zˆ  ¡  W n: tjyF   ˆ t ¡ j¡ ˆ t ¡ ¡ ˆ   ¡  Y n0 d S r   )r   r   rj   r   r   r   r   ©ZhubÚmainÚresultr   r   Úworkerz  s    z9TestGreenlet.test_parent_restored_on_kill.<locals>.workerr   r   r   )r   r   r   r   r@   r   )r0   r³   r!   r   r°   r   Útest_parent_restored_on_killv  s    	

z)TestGreenlet.test_parent_restored_on_killc                 C   sL   t ƒ }t dd„ |d�}|  t¡� | ¡  W d   ƒ n1 s>0    Y  d S )Nc                   S   s   d S r   r   r   r   r   r   rˆ   •  r\   z9TestGreenlet.test_parent_return_failure.<locals>.<lambda>r   )r   r6   r7   r   )r0   r"   rc   r   r   r   Útest_parent_return_failure‘  s    z'TestGreenlet.test_parent_return_failurec                 C   s2   G dd„ dt ƒ}|dd„ ƒ}|  t|jtƒ ¡ d S )Nc                   @   s   e Zd Zdd„ ZdS )z>TestGreenlet.test_throw_exception_not_lost.<locals>.mygreenletc                 S   s$   z
t ƒ ‚W n   Y n0 t | |¡S r   )rm   r   Ú__getattribute__©r0   Únamer   r   r   r¶   œ  s
    
zOTestGreenlet.test_throw_exception_not_lost.<locals>.mygreenlet.__getattribute__N©r   r   r   r¶   r   r   r   r   Ú
mygreenlet›  s   rº   c                   S   s   d S r   r   r   r   r   r   rˆ   ¢  r\   z<TestGreenlet.test_throw_exception_not_lost.<locals>.<lambda>)r   r6   r   r=   )r0   rº   r!   r   r   r   Útest_throw_exception_not_lostš  s    z*TestGreenlet.test_throw_exception_not_lostFc                    s:  g ‰ dd„ ‰‡ ‡‡fdd„}t j|d�}| ¡  | d¡ ~ˆrH|  ¡  |  tj¡�}ˆ d  t	¡ W d   ƒ n1 sx0    Y  ˆsž|  
t|jƒdd	g¡ n|  t|jƒd¡ tˆ d jd
ƒrø|  t¡� ˆ d j ¡  W d   ƒ n1 sî0    Y  ˆ�sˆ d jj ¡  n|  ˆ d j¡ ~d ‰ˆ d d …= d| _d S )Nc                   S   s   t  ¡ j ¡  d S r   r“   r   r   r   r   r³   ¨  s    zGTestGreenlet._do_test_throw_to_dead_thread_doesnt_crash.<locals>.workerc                     s2   t ˆƒ} |  ¡  ˆ  | ¡ ˆr.|  ¡  t  ¡  d S r   )r   r   r   r   rN   ©r²   Úwait_for_cleanupr³   r   r   Úcreator«  s    
zHTestGreenlet._do_test_throw_to_dead_thread_doesnt_crash.<locals>.creatorrT   r]   r   úBcannot switch to a different thread (which happens to have exited)ú#cannot switch to a different threadr›   T)rV   rW   r^   r_   Úwait_for_pending_cleanupsr6   r   rš   r=   r   r8   r9   r:   r-   r©   r€   ÚRuntimeErrorr›   Úf_localsrC   Úexpect_greenlet_leak)r0   r½   r¾   ry   r   r   r¼   r   Ú*_do_test_throw_to_dead_thread_doesnt_crash¥  s@    
,þÿþ,
z7TestGreenlet._do_test_throw_to_dead_thread_doesnt_crashc                 C   s   |   ¡  d S r   ©rÅ   r2   r   r   r   Ú&test_throw_to_dead_thread_doesnt_crashÞ  s    z3TestGreenlet.test_throw_to_dead_thread_doesnt_crashc                 C   s   |   d¡ d S rR   rÆ   r2   r   r   r   Ú+test_throw_to_dead_thread_doesnt_crash_waitâ  s    z8TestGreenlet.test_throw_to_dead_thread_doesnt_crash_waitc                 C   s2   G dd„ dt ƒ}|ƒ }|  | d¡d¡ d| _d S )Nc                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )z7TestGreenlet.test_recursive_startup.<locals>.convolutedc                 S   s   t  | ¡ d| _d S r   )r   Ú__init__Úcountr2   r   r   r   rÉ   è  s    
z@TestGreenlet.test_recursive_startup.<locals>.convoluted.__init__c                 S   s.   |dkr"| j dkr"d| _ |  d¡ t | |¡S )Nr5   r   r   é+   )rÊ   r   r   r¶   r·   r   r   r   r¶   ë  s    
zHTestGreenlet.test_recursive_startup.<locals>.convoluted.__getattribute__c                 S   s   | j  |¡ q d S r   ©r   r   ©r0   rd   r   r   r   r5   ð  s    z;TestGreenlet.test_recursive_startup.<locals>.convoluted.runN)r   r   r   rÉ   r¶   r5   r   r   r   r   Ú
convolutedç  s   rÎ   r�   rË   T)r   r-   r   rÄ   )r0   rÎ   r!   r   r   r   Útest_recursive_startupå  s    z#TestGreenlet.test_recursive_startupc                    sº   t  ¡ ‰ˆ ¡  t  ¡ ‰ˆ ¡  G ‡‡fdd„dtƒ}dd„ }‡ ‡‡fdd„}t ¡ }t|ƒg‰ |ƒ ˆ d _ˆ d  ¡  t j|d�}| 	¡  ˆ 
¡  ˆ ¡  |  t ¡ |¡ | d	¡ d S )
Nc                       s   e Zd Z‡ ‡fdd„ZdS )z;TestGreenlet.test_threaded_updatecurrent.<locals>.finalizedc                    s   ˆ  ¡  ˆ  ¡  d S r   ©ÚreleaseÚacquirer2   ©Úlock1Úlock2r   r   Ú__del__  s    zCTestGreenlet.test_threaded_updatecurrent.<locals>.finalized.__del__N©r   r   r   rÖ   r   rÓ   r   r   Ú	finalized  s   rØ   c                   S   s   t  ¡ j ¡  d S r   r“   r   r   r   r   Údeallocator
  s    z=TestGreenlet.test_threaded_updatecurrent.<locals>.deallocatorc                      s:   ˆ  ¡  t ¡  ˆ d= ˆ ¡  ˆ  ¡  t ¡  ˆ ¡  d S r   ©rÒ   r   r   rÑ   r   ©r!   rÔ   rÕ   r   r   Úfthread  s    z9TestGreenlet.test_threaded_updatecurrent.<locals>.fthreadr   rT   r]   )rV   ÚLockrÒ   Úobjectr   r   Zbombr   rW   r^   rÑ   r-   r_   )r0   rØ   rÙ   rÜ   r±   ry   r   rÛ   r   Útest_threaded_updatecurrentû  s"    

z(TestGreenlet.test_threaded_updatecurrentc                    sb   g ‰‡ ‡‡fdd„‰dd„ ‰ t ˆƒg‰ˆd  ¡  t ˆ ˆd ƒ‰ ˆ  ¡ }|  ˆ¡ |  |d¡ d S )Nc               
      sX   t  ¡ j ¡ } ˆd= t  ¡ jˆ _z"t  ¡ j | ¡ W ˆ t  ¡ ¡ nˆ t  ¡ ¡ 0 d S r   )r   r   r   r   r   )rd   ©Ú	initiatorr   r³   r   r   r³   ,  s    z>TestGreenlet.test_dealloc_switch_args_not_lost.<locals>.workerc                   S   s   dS r¡   r   r   r   r   r   rá   9  s    zATestGreenlet.test_dealloc_switch_args_not_lost.<locals>.initiatorr   r�   )r   r   r   r-   rÍ   r   rà   r   Ú!test_dealloc_switch_args_not_lost*  s    

z.TestGreenlet.test_dealloc_switch_args_not_lostc                    sh   t jd dkrdd„ ‰ nt‰ G dd„ dtƒ}|ƒ ‰tdd�‰‡ ‡‡fd	d
„}t|ƒ}|  | ¡ ˆ¡ d S )Nr   r*   c                 S   s   | |i |¤Ž d S r   r   )r«   rL   Úkr   r   r   Ú_applyU  s    z0TestGreenlet.test_tuple_subclass.<locals>._applyc                   @   s   e Zd Zdd„ ZdS )z1TestGreenlet.test_tuple_subclass.<locals>.mytuplec                 S   s   t  ¡  ¡  t | ¡S r   )r   r   r   ÚtupleÚ__len__r2   r   r   r   ræ   [  s    z9TestGreenlet.test_tuple_subclass.<locals>.mytuple.__len__N)r   r   r   ræ   r   r   r   r   ÚmytupleZ  s   rç   r�   )rL   c                      s   ˆ t  ¡ jjˆˆƒ d S r   r“   r   ©rä   r‹   Úkwargsr   r   Úswitchapply`  s    z5TestGreenlet.test_tuple_subclass.<locals>.switchapply)r   Úversion_infoÚapplyrå   Údictr   r-   r   )r0   rç   rê   r!   r   rè   r   Útest_tuple_subclassD  s    

z TestGreenlet.test_tuple_subclassc                 C   sP   t dtfdtdd„ ƒiƒ}G dd„ d|ƒ}G dd„ d|ƒ}|ƒ  |  t|¡ d S )	NÚAbstractSubclassr5   c                 S   s   d S r   r   r2   r   r   r   rˆ   i  r\   z7TestGreenlet.test_abstract_subclasses.<locals>.<lambda>c                   @   s   e Zd ZdS )z:TestGreenlet.test_abstract_subclasses.<locals>.BadSubclassNr   r   r   r   r   ÚBadSubclassk  s   rð   c                   @   s   e Zd Zdd„ ZdS )z;TestGreenlet.test_abstract_subclasses.<locals>.GoodSubclassc                 S   s   d S r   r   r2   r   r   r   r5   o  s    z?TestGreenlet.test_abstract_subclasses.<locals>.GoodSubclass.runN)r   r   r   r5   r   r   r   r   ÚGoodSubclassn  s   rñ   )r   r   r   r6   r§   )r0   rï   rð   rñ   r   r   r   Útest_abstract_subclassese  s    ýz%TestGreenlet.test_abstract_subclassesc                    sN   t  ¡ sd S t  ¡ d ‰ ˆ dk r$d S ‡ ‡fdd„}tdƒD ]}|ƒ r: qJq:d S )Nr   é2   c            	         s  t  ¡ ‰ˆ ¡  t  ¡ ‰ˆ ¡  dg‰‡‡fdd„} t j| d�}| ¡  G ‡‡‡fdd„dtƒ‰ G ‡ fdd„dtƒ}g }tˆd	 ƒ}t ¡ }|ƒ }|D ]<}d }ˆd
 r¶| 	d¡  dS tƒ }ˆd
 rÈ qò| 
|¡ q–t ¡  ˆd
 rî| 	d¡ dS ˆ |j|¡ |D ]}ˆ |j|¡ �qdS )NFc                      s   ˆ   ¡  t ¡  ˆ ¡  d S r   rÚ   r   rÓ   r   r   Úanother_thread�  s    zWTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.another_threadrT   c                       s   e Zd Z‡ ‡‡fdd„ZdS )zTTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.gc_callbackc                    s   ˆ   ¡  ˆ ¡  dˆd< d S )NTr   rÐ   r2   ©rÔ   rÕ   Úrecycledr   r   rÖ   ˆ  s    z\TestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.gc_callback.__del__Nr×   r   rõ   r   r   Úgc_callback‡  s   r÷   c                       s   e Zd Z‡ fdd„ZdS )zPTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.garbagec                    s   | | _ ˆ ƒ | _d S r   )ÚcycleÚcallbackr2   ©r÷   r   r   rÉ   �  s    zYTestGreenlet.test_implicit_parent_with_threads.<locals>.attempt.<locals>.garbage.__init__N)r   r   r   rÉ   r   rú   r   r   ÚgarbageŒ  s   rû   r*   r   r]   T)rV   rÝ   rÒ   rW   r^   rÞ   r/   r   r   r_   r   rh   ri   r-   r   )	rô   ry   rû   Úlr‡   Úcurrentr!   Ú_Úlast©ÚNr0   )r÷   rÔ   rÕ   rö   r   Úattempt{  s>    

z?TestGreenlet.test_implicit_parent_with_threads.<locals>.attemptr,   )rh   Ú	isenabledZget_thresholdr/   )r0   r  rþ   r   r   r   Ú!test_implicit_parent_with_threadsu  s    -z.TestGreenlet.test_implicit_parent_with_threadsc                    s|   ddl m‰ ddl m‰  G dd„ dt ƒ}t |¡}g ˆ_‡ ‡‡fdd„}tdƒD ]}||ƒ ¡  qPˆ`ˆ t |¡|¡ d S )	Nr   ©r   )rj   c                   @   s   e Zd ZdS )zTTestGreenlet.test_issue_245_reference_counting_subclass_no_threads.<locals>.GreenletNr   r   r   r   r   ÚGreenletµ  s   r  c                      s6   zˆƒ j  ¡  W n  ˆ y0   ˆj ˆƒ ¡ Y n0 d S r   )r   r   Úgletsr   r   ©rj   r   r0   r   r   Úgreenlet_main¾  s    zYTestGreenlet.test_issue_245_reference_counting_subclass_no_threads.<locals>.greenlet_mainr]   )	r   r   rj   r   rP   r  r/   r   r-   )r0   r  Úinitial_refsr	  rþ   r   r  r   Ú5test_issue_245_reference_counting_subclass_no_threads¬  s    
zBTestGreenlet.test_issue_245_reference_counting_subclass_no_threadsc           
         sè   ddl m} ddl m} ddlm‰ G dd„ dtƒ‰ g ‰|ƒ ‰‡fdd„‰‡ ‡‡‡‡fd	d
„}t ˆ ¡}g }t|d ƒD ]*}|ƒ }|||fd�}| |¡ | 	¡  qx|D ]}	|	 
d¡ q¨ˆd d …= ˆ ¡  |  ¡  |  t ˆ ¡|¡ d S )Nr   )rW   )rx   r  c                   @   s   e Zd ZdS )zSTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.MyGreenletNr   r   r   r   r   Ú
MyGreenletÒ  s   r  c                      s   ˆ ƒ j  ¡  d S r   rÌ   r   r  r   r   r	  Ø  s    zVTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.greenlet_mainc                    s8   ˆ ˆƒ}ˆ  |¡ | ¡  ~|  ¡  ˆ d¡ ˆƒ  d S )Nr]   )r   r   ru   rv   )Zgreenlet_running_eventZmine©r  r   r  r	  Zref_clearedr   r   Úthread_mainÛ  s    

zTTestGreenlet.test_issue_245_reference_counting_subclass_threads.<locals>.thread_mainé-   rŠ   r]   )rV   rW   rx   r   r   r   rP   r/   r   r^   rv   ru   rÁ   r-   )
r0   rW   rx   r  r
  Zthread_ready_eventsrþ   Úeventrœ   r™   r   r  r   Ú2test_issue_245_reference_counting_subclass_threadsË  s.    
ÿ


z?TestGreenlet.test_issue_245_reference_counting_subclass_threadsc                 C   sX   dd„ }t |ƒ}dd„ }t ||ƒ}|  t¡� | ¡  W d   ƒ n1 sJ0    Y  d S )Nc                   S   s   dS )Né   r   r   r   r   r   Úno_args  s    z\TestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error.<locals>.no_argsc                   S   s   dS r¡   r   r   r   r   r   Úleaf  s    zYTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_error.<locals>.leaf)r   r6   r§   r   )r0   r  Úparent_never_startedr  Úchildr   r   r   Ú>test_falling_off_end_switches_to_unstarted_parent_raises_error  s    
zKTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_raises_errorc                 C   s:   dd„ }t |ƒ}dd„ }t ||ƒ}| ¡ }|  |d¡ d S )Nc                 S   s   | dfS ©Né   r   r†   r   r   r   Úone_arg  s    zUTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_works.<locals>.one_argc                   S   s   dS r¡   r   r   r   r   r   r  #  s    zRTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_works.<locals>.leaf)r�   r  r‘   )r0   r  r  r  r  r²   r   r   r   Ú7test_falling_off_end_switches_to_unstarted_parent_works  s    
zDTestGreenlet.test_falling_off_end_switches_to_unstarted_parent_worksc                    s°   G dd„ dt ƒ}|ƒ }g ‰ t ‡ fdd„|ƒ}|  t¡� | ¡  W d   ƒ n1 sT0    Y  |  ˆ dg¡ |  t¡� | ¡  W d   ƒ n1 s”0    Y  |  ˆ dg¡ d S )Nc                   @   s   e Zd Zdd„ ZdS )zXTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.Parentc                 S   s   |dkrt ‚d S r4   )r   r·   r   r   r   r¶   -  s    ziTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.Parent.__getattribute__Nr¹   r   r   r   r   ÚParent,  s   r  c                      s
   ˆ   d¡S r¡   ©r   r   r   r   r   rˆ   4  r\   zZTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parent.<locals>.<lambda>r�   )r   r6   r   r   r-   )r0   r  r  r  r   r   r   Ú;test_switch_to_dead_greenlet_with_unstarted_perverse_parent+  s    &&zHTestGreenlet.test_switch_to_dead_greenlet_with_unstarted_perverse_parentc                    sf   g ‰ t ‡ fdd„ƒ}t ‡ fdd„ƒ}| ¡  |  ˆ dg¡ ||_| ¡ }|  |¡ |  ˆ ddg¡ d S )Nc                      s
   ˆ   d¡S r  r  r   r   r   r   rˆ   B  r\   zDTestGreenlet.test_switch_to_dead_greenlet_reparent.<locals>.<lambda>c                      s
   ˆ   d¡S r¡   r  r   r   r   r   rˆ   C  r\   r�   r  )r   r   r-   r   rC   )r0   r  r  r²   r   r   r   Ú%test_switch_to_dead_greenlet_reparent@  s    
z2TestGreenlet.test_switch_to_dead_greenlet_reparentN)F)-r   r   r   r1   r3   r<   r>   rB   rD   rJ   rQ   ra   re   rg   rk   rt   rz   rƒ   rŽ   r’   r•   r�   r    r¨   r¬   r¯   r´   rµ   r»   r
   rÅ   rÇ   rÈ   rÏ   rß   râ   rî   rò   r  r  r  r  r  r  r  r   r   r   r   r$   +   sX   ,
	8

/!7Cr$   c                   @   s\   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )ÚTestGreenletSetParentErrorsc                    s¶   i ‰t  ¡ ‰ t  ¡ ‰‡ ‡‡fdd„}dd„ }t j|d�}| ¡  ˆ  d¡ t|ƒ}| ¡  |  t¡�}ˆd |_	W d   ƒ n1 s„0    Y  ˆ 
¡  | d¡ |  t|jƒd¡ d S )	Nc                      s&   t dd„ ƒˆd< ˆ  ¡  ˆ d¡ d S )Nc                   S   s   d S r   r   r   r   r   r   rˆ   V  r\   zQTestGreenletSetParentErrors.test_threaded_reparent.<locals>.run.<locals>.<lambda>r!   r]   r–   r   r—   r   r   r5   U  s    z?TestGreenletSetParentErrors.test_threaded_reparent.<locals>.runc                   S   s   t  ¡ j ¡  d S r   r“   r   r   r   r   ÚblankZ  s    zATestGreenletSetParentErrors.test_threaded_reparent.<locals>.blankrT   r]   r!   z&parent cannot be on a different thread)rV   rx   rW   r^   rv   r   r   r6   rž   r   ru   r_   r-   r9   r:   )r0   r5   r!  rœ   r!   r   r   r—   r   Útest_threaded_reparentP  s    
(
z2TestGreenletSetParentErrors.test_threaded_reparentc                    s´   g ‰ ‡ fdd„}t j|d�}| ¡  | d¡ | j| jd d� G ‡ fdd„dtƒ}|d	d
„ ƒ}|  tj¡�}| 	¡  W d   ƒ n1 sŠ0    Y  |  
t|jƒd¡ ˆ d d …= d S )Nc                     s"   t dd„ ƒ} ˆ  | ¡ |  ¡  d S )Nc                   S   s   d S r   r   r   r   r   r   rˆ   l  r\   zYTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.worker.<locals>.<lambda>)r   r   r   rN   ©Úanotherr   r   r³   k  s    
zGTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.workerrT   r]   r   )Zinitial_main_greenletsc                       s   e Zd Z‡ fdd„ZdS )zKTestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.convolutedc                    s   |dkrˆ d | _ t | |¡S ©Nr5   r   ©r   r   r¶   r·   r#  r   r   r¶   ‡  s    
z\TestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.convoluted.__getattribute__Nr¹   r   r#  r   r   rÎ   †  s   rÎ   c                   S   s   d S r   r   r   r   r   r   rˆ   ‹  r\   zITestGreenletSetParentErrors.test_unexpected_reparenting.<locals>.<lambda>r¿   )rV   rW   r^   r_   rÁ   Zmain_greenlets_before_testr   r6   rš   r   r-   r9   r:   )r0   r³   ry   rÎ   r!   r   r   r#  r   Útest_unexpected_reparentingi  s    
&ÿz7TestGreenletSetParentErrors.test_unexpected_reparentingc              	      sì   g ‰ t  ¡ ‰t  ¡ ‰‡ ‡‡fdd„}G ‡ fdd„dtƒ}t j|d�}| ¡  ˆ d¡ zr|dd„ ƒ}|  tj¡�}| ¡  W d   ƒ n1 sŽ0    Y  |  	t
|jƒd	¡ W ˆ ¡  | d¡ ˆ d d …= nˆ ¡  | d¡ ˆ d d …= 0 d S )
Nc                     s4   t dd„ ƒ} ˆ  | ¡ |  ¡  ˆ ¡  ˆ d¡ d S )Nc                   S   s   d S r   r   r   r   r   r   rˆ   ™  r\   zhTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.worker.<locals>.<lambda>r]   )r   r   r   ru   rv   rN   ©r$  Zkeep_main_aliveZswitched_to_greenletr   r   r³   ˜  s
    
zVTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.workerc                       s   e Zd Z‡ fdd„ZdS )zZTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.convolutedc                    s   |dkrˆ d | _ t | |¡S r%  r&  r·   r#  r   r   r¶   Ÿ  s    
zkTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.convoluted.__getattribute__Nr¹   r   r#  r   r   rÎ   ž  s   rÎ   rT   r]   c                   S   s   d S r   r   r   r   r   r   rˆ   ©  r\   zXTestGreenletSetParentErrors.test_unexpected_reparenting_thread_running.<locals>.<lambda>rÀ   )rV   rx   r   rW   r^   rv   r6   rš   r   r-   r9   r:   ru   r_   )r0   r³   rÎ   ry   r!   r   r   r(  r   Ú*test_unexpected_reparenting_thread_running’  s&    
&
ý
zFTestGreenletSetParentErrors.test_unexpected_reparenting_thread_runningc                 C   sb   t dd„ ƒ}|  |jt  ¡ ¡ |  t¡�}|`W d   ƒ n1 sB0    Y  |  t|jƒd¡ d S )Nc                   S   s   d S r   r   r   r   r   r   rˆ   µ  r\   zGTestGreenletSetParentErrors.test_cannot_delete_parent.<locals>.<lambda>úcan't delete attribute)	r   r@   r   r   r6   r7   r-   r9   r:   )r0   r³   r   r   r   r   Útest_cannot_delete_parent´  s
    "z5TestGreenletSetParentErrors.test_cannot_delete_parentc                 C   sH   |   t¡�}t ¡ `W d   ƒ n1 s(0    Y  |  t|jƒd¡ d S )Nr*  ©r6   r7   r   r   r   r-   r9   r:   ©r0   r   r   r   r   Ú!test_cannot_delete_parent_of_main¼  s    &z=TestGreenletSetParentErrors.test_cannot_delete_parent_of_mainc                 C   s   |   t ¡ j¡ d S r   )rC   r   r   r   r2   r   r   r   Ú!test_main_greenlet_parent_is_noneÂ  s    z=TestGreenletSetParentErrors.test_main_greenlet_parent_is_nonec                    sT   dd„ }‡ fdd„}t |ƒ}ˆ  |¡ ||ƒ | ¡  ˆ  |¡ ||ƒ | ¡  d S )Nc                   S   s   t  ¡ j ¡  d S r   r“   r   r   r   r   ÚbgÇ  s    zCTestGreenletSetParentErrors.test_set_parent_wrong_types.<locals>.bgc              	      sX   d dˆ dfD ]F}ˆ   t¡�}|| _W d   ƒ n1 s60    Y  ˆ  t|jƒd¡ qd S )Nr   Z42zExpected a greenlet)r6   r§   r   r-   r9   r:   )ÚgletÚpr   r2   r   r   ÚcheckË  s    $zFTestGreenletSetParentErrors.test_set_parent_wrong_types.<locals>.check)r   r�   r   r   )r0   r0  r3  r!   r   r2   r   Útest_set_parent_wrong_typesÆ  s    

z7TestGreenletSetParentErrors.test_set_parent_wrong_typesc                 C   sR   t dd„ ƒ}|  t¡�}||_W d   ƒ n1 s20    Y  |  t|jƒd¡ d S )Nc                   S   s   d S r   r   r   r   r   r   rˆ   à  r\   z@TestGreenletSetParentErrors.test_trivial_cycle.<locals>.<lambda>úcyclic parent chain)r   r6   rž   r   r-   r9   r:   )r0   r1  r   r   r   r   Útest_trivial_cycleß  s    $z.TestGreenletSetParentErrors.test_trivial_cyclec                 C   sN   |   t¡�}t ¡ t ¡ _W d   ƒ n1 s.0    Y  |  t|jƒd¡ d S )Nz(cannot set the parent of a main greenletr,  r-  r   r   r   Útest_trivial_cycle_mainå  s    ,z3TestGreenletSetParentErrors.test_trivial_cycle_mainc                 C   sv   t dd„ ƒ}t dd„ ƒ}t dd„ ƒ}||_||_|  t¡�}||_W d   ƒ n1 sV0    Y  |  t|jƒd¡ d S )Nc                   S   s   d S r   r   r   r   r   r   rˆ   ì  r\   z?TestGreenletSetParentErrors.test_deeper_cycle.<locals>.<lambda>c                   S   s   d S r   r   r   r   r   r   rˆ   í  r\   c                   S   s   d S r   r   r   r   r   r   rˆ   î  r\   r5  )r   r   r6   rž   r-   r9   r:   )r0   r"   rc   Zg3r   r   r   r   Útest_deeper_cycleë  s    $z-TestGreenletSetParentErrors.test_deeper_cycleN)r   r   r   r"  r'  r)  r+  r.  r/  r4  r6  r7  r8  r   r   r   r   r   O  s   )"r   c                   @   sD   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )ÚTestReprc                 C   s   |   | |¡||f¡ d S r   )r   Úendswith)r0   ÚgotÚsuffixr   r   r   ÚassertEndsWithù  s    zTestRepr.assertEndsWithc                 C   s   t t ¡ ƒ}|  |d¡ d S )Nú current active started main>)Úreprr   r   r=  ©r0   Úrr   r   r   Útest_main_while_runningü  s    z TestRepr.test_main_while_runningc                    s4   t  ¡ ‰ ‡ fdd„}t |ƒ}| ¡ }|  |d¡ d S )Nc                      s   t ˆ ƒS r   )r?  r   ©r±   r   r   r5     s    z-TestRepr.test_main_in_background.<locals>.runú suspended active started main>)r   r   r   r=  )r0   r5   r!   rA  r   rC  r   Útest_main_in_background   s
    z TestRepr.test_main_in_backgroundc                 C   s   t tƒ ƒ}|  |d¡ d S )Nz	 pending>)r?  r   r=  r@  r   r   r   Útest_initial	  s    
zTestRepr.test_initialc                    s    t  ¡ ‰ G ‡ fdd„dtjƒ}|ƒ }| ¡  | d¡ |  |jd¡ |  |jd¡ t	dƒD ]}t
 d¡ qZt	dƒD ](}|  |jj¡ t|jƒ}|  |d¡ qrd S )	Nc                       s$   e Zd Zd ZZdZ‡ fdd„ZdS )z/TestRepr.test_main_from_other_thread.<locals>.TNc                    s$   t ˆ ƒ| _t ¡ | _t | jƒ| _d S r   )r?  Úoriginal_mainr   r   Ú	main_gletr  r2   rC  r   r   r5     s    

z3TestRepr.test_main_from_other_thread.<locals>.T.run)r   r   r   rG  r  rH  r5   r   rC  r   r   ÚT  s   rI  r]   rD  r>  r%   gü©ñÒMbP?z (thread exited) dead>)r   r   rV   rW   r^   r_   r=  rG  r  r/   r„   r…   r   rH  rH   r?  )r0   rI  ry   rþ   rA  r   rC  r   Útest_main_from_other_thread  s    

z$TestRepr.test_main_from_other_threadc                 C   sX   t dd„ ƒ}| ¡  |  t|ƒd¡ |  dt|ƒ¡ |  dt|ƒ¡ |  dt|ƒ¡ d S )Nc                   S   s   d S r   r   r   r   r   r   rˆ   1  r\   z$TestRepr.test_dead.<locals>.<lambda>z dead>Z	suspendedÚstartedÚactive)r   r   r=  r?  ZassertNotInrA   r   r   r   Ú	test_dead0  s    zTestRepr.test_deadc                 C   sX   t dd„ ƒ}t dd„ ƒ}t  ¡ }|||fD ](}|  d|f t¡ |  d|f t¡ q*d S )Nc                   S   s   d S r   r   r   r   r   r   rˆ   <  r\   z>TestRepr.test_formatting_produces_native_str.<locals>.<lambda>c                   S   s   d S r   r   r   r   r   r   rˆ   =  r\   z%sz%r)r   r   ÚassertIsInstancer9   )r0   Zg_deadZg_not_startedZg_curr!   r   r   r   Ú#test_formatting_produces_native_str8  s    þþz,TestRepr.test_formatting_produces_native_strN)
r   r   r   r=  rB  rE  rF  rJ  rM  rO  r   r   r   r   r9  ÷  s   	#r9  c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚTestMainGreenletc                 C   s4   dt t ¡ ƒv sJ ‚tt ¡ ƒ}dt |ƒvs0J ‚|S )Nr±   )r?  r   r   Útype)r0   ry   r   r   r   Ú_check_current_is_mainP  s    z'TestMainGreenlet._check_current_is_mainc                 C   s$   |   ¡ }td|fi ƒ}|  |¡ d S )NÚsubclass)rR  rQ  r?   )r0   Z	main_typerS  r   r   r   Ú)test_main_greenlet_type_can_be_subclassedX  s    z:TestMainGreenlet.test_main_greenlet_type_can_be_subclassedc                 C   s   |   ¡  |  t ¡ t¡ d S r   )rR  rN  r   r   r2   r   r   r   Útest_main_greenlet_is_greenlet]  s    z/TestMainGreenlet.test_main_greenlet_is_greenletN)r   r   r   rR  rT  rU  r   r   r   r   rP  L  s   rP  Ú__main__)Ú
__future__r   r   r   rh   r   r„   rV   Úabcr   r   r   Ú r	   Z	leakcheckr
   rm   r   r   r#   r$   r   r9  rP  r   Zunittestr±   r   r   r   r   Ú<module>   s6   		      * )U