B
    ÐH/\Ó  ã               @   sJ   d dl Z d dlmZ G dd„ deƒZG dd„ dejƒZedkrFe 	¡  dS )é    Nc               @   s   e Zd ZdS )ÚMyExceptionN)Ú__name__Ú
__module__Ú__qualname__© r   r   ú:lib/python3.7/site-packages/gevent/tests/test__issue330.pyr      s   r   c                   sT   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
‡  ZS )Ú
TestSwitchc                s"   t t| ƒ ¡  ddg| _d | _d S )NF)Úsuperr   ÚsetUpÚswitched_toÚcaught)Úself)Ú	__class__r   r   r
      s    
zTestSwitch.setUpc             C   s   d| j |< d S )NT)r   )r   Úir   r   r   Úshould_never_run   s    zTestSwitch.should_never_runc             C   st   t  ||f¡ |  ddg| j¡ |  |jt j¡ |  |jt j¡ |  |j¡ |  |j¡ |  |j	¡ |  |j	¡ d S )NF)
ÚgeventZjoinallZassertEqualr   ÚassertIsInstanceÚvalueÚGreenletExitÚassertIsNoneÚexc_infoÚ	exception)r   ÚgÚg2r   r   r   Úcheck   s    zTestSwitch.checkc             C   s@   t  | jd¡}t  | jd¡}t  |¡ t  |¡ |  ||¡ d S )Nr   é   )r   Úspawnr   Úkillr   )r   r   r   r   r   r   Útest_gevent_kill#   s
    

zTestSwitch.test_gevent_killc             C   s<   t  | jd¡}t  | jd¡}| ¡  | ¡  |  ||¡ d S )Nr   r   )r   r   r   r   r   )r   r   r   r   r   r   Útest_greenlet_kill+   s
    zTestSwitch.test_greenlet_killc             C   sD   t  | jd¡}t  | jd¡}| t j¡ | t j¡ |  ||¡ d S )Nr   r   )r   r   r   Úthrowr   r   )r   r   r   r   r   r   Ú
test_throw3   s
    zTestSwitch.test_throwc          
   C   sB   yxt  d¡ qW W n( tk
r< } z
|| _W d d }~X Y nX d S )Nr   )r   Úsleepr   r   )r   Úer   r   r   Úcatcher<   s
    zTestSwitch.catcherc             C   sR   t  | j¡}| ¡  t  ¡  t  |tƒ ¡ t  ¡  |  | jt¡ |  	|j
t¡ d S )N)r   r   r$   Ústartr"   r   r   r   r   r   r   )r   r   r   r   r   Útest_kill_exceptionC   s    zTestSwitch.test_kill_exception)r   r   r   r
   r   r   r   r   r!   r$   r&   Ú__classcell__r   r   )r   r   r   
   s   	r   Ú__main__)
r   Zgevent.testingZtestingZ	greentestÚ	Exceptionr   ZTestCaser   r   Úmainr   r   r   r   Ú<module>   s
   F