
    h                     @    d dl Z d dlmZ ddlmZ d Z G d de      Zy)    N)greenlet   )TestCasec                  X     t        j                         j                  j                  |  S )N)r   
getcurrentparentswitch)argss    BD:\EasyAligner\venv\Lib\site-packages\greenlet/tests/test_throw.pyr	   r	      s$    .8 ''..55    c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	
ThrowTestsc                     d }t        |      }|j                         }| j                  |d       |j                  t              }| j                  |d       y )Nc                  f    	 t        d       t        d       y # t        $ r t        d       Y y w xY wNokfail)r	   RuntimeError r   r   fz ThrowTests.test_class.<locals>.f   s2    t 6N   ts    00r   r   r	   assertEqualthrowr   selfr   gress       r   
test_classzThrowTests.test_class   sK    	 QKhhjd#ggl#d#r   c                 f   d }t        |      }|j                         }| j                  |d       |j                  t	        d            }| j                  |d       t        |      }|j                         }| j                  |d       |j                  t        d      }| j                  |d       y )Nc                      	 t        d       t        d       y # t        $ r5 t        j                         d   } t	        |       dk(  rt        d       Y y Y Iw xY w)Nr   r   ciaor   )r	   r   sysexc_infostr)vals    r   r   zThrowTests.test_val.<locals>.f   sS    t 6N   llnQ's8v%4L &s    9AAr   r!   r   r   s       r   test_valzThrowTests.test_val   s    	 QKhhjd#ggl6*+d#QKhhjd#gglF+d#r   c                 ~   d }t        |      }|j                         }| j                  |d       |j                         }| j	                  t        |t         j                               | j	                  |j                         |j                         }| j	                  t        |t         j                               y )Nc                  0    t        d       t        d       y r   r	   r   r   r   r   zThrowTests.test_kill.<locals>.f2   s    4L6Nr   r   )r   r	   r   r   
assertTrue
isinstanceGreenletExitdeadr   s       r   	test_killzThrowTests.test_kill1   s    	 QKhhjd#ggi
3(=(=>?ggi
3(=(=>?r   c                    t        j                         fd}fd}t        |      }t        ||      }| j                  t              5  |j	                  t               d d d        | j                  |j                         | j                  |j                         t        |      }t        ||      }|j                         }| j                  |d       |j	                  t              }| j                  |d       | j                  |j                         | j                  |j                         t        |      }t        ||      }|j                         }| j                  |d       |j                         }| j                  |d       |j	                  t              }| j                  |d       | j                  |j                         | j                  |j                         y # 1 sw Y   xY w)Nc                  H    	  j                  d       y# t        $ r Y yw xY w)Nf1 ready to catchcaughtznormal exit)r	   
IndexErrormains   r   f1z9ThrowTests.test_throw_goes_to_original_parent.<locals>.f1A   s.     /0 !    s    	!!c                  (     j                  d       y )Nfrom f2r)   r4   s   r   f2z9ThrowTests.test_throw_goes_to_original_parent.<locals>.f2H   s    KK	"r   )r   r1   r2   r8   )	r   r   assertRaisesr3   r   r*   r-   r	   r   )r   r6   r9   g1g2r   r5   s         @r   "test_throw_goes_to_original_parentz-ThrowTests.test_throw_goes_to_original_parent>   ss   ""$	!	# b\b$z*HHZ  +  b\b$iik12hhz"h'  b\b$iik12iiki(hhz"h'  / +*s   G22G<c                    | j                  t              5 }t        j                         j	                  t
        t               |        d d d        | j                  t        j                        d       y # 1 sw Y   /xY w)Nz1throw() third argument must be a traceback object)	r:   	TypeErrorr   r   r   	Exceptionr   r$   	exceptionr   excs     r   test_non_traceback_paramz#ThrowTests.test_non_traceback_paramf   sa    y)S!'' * 	S]]+L	N *)s   2A66A?c                 
   | j                  t              5 }t        j                         j	                  t               t                      d d d        | j                  t        j                        d       y # 1 sw Y   /xY w)Nz0instance exception may not have a separate value)
r:   r?   r   r   r   r@   BaseExceptionr   r$   rA   rB   s     r   test_instance_of_wrong_typez&ThrowTests.test_instance_of_wrong_typep   s`    y)S!'' * 	S]]+K	M *)s   5A99Bc                     | j                  t              5 }t        j                         j	                  d       d d d        | j                  t        j                        d       y # 1 sw Y   /xY w)Nabcz1exceptions must be classes, or instances, not str)r:   r?   r   r   r   r   r$   rA   rB   s     r   test_not_throwablezThrowTests.test_not_throwablez   sY    y)S!'' * 	S]]+L	N	 *)s   $A((A1N)
__name__
__module____qualname__r   r&   r.   r=   rD   rG   rJ   r   r   r   r   r      s*    $$.@&!PNMNr   r   )r"   r    r   r	   r   r   r   r   <module>rO      s%    
  6uN uNr   