
    [h                         d dl mZ d dl mZ d dlZd dlZddlmZ ddlmZ  G d de          Ze	d	k    rd dl
Z
 e
j                     dS dS )
    )print_function)absolute_importN   )_test_extension)TestCasec                   P    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )	CAPITestsc                 |    |                      dt          j        t          j        d                                d S )N2   c                      dS )Nr    r       v/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/greenlet/tests/test_extension_interface.py<lambda>z'CAPITests.test_switch.<locals>.<lambda>   s    b r   )assertEqualr   test_switchgreenletselfs    r   r   zCAPITests.test_switch   sF    +H,=jj,I,IJJ	L 	L 	L 	L 	Lr   c                     d }t          j         |          }|                     dt          j        |dd                     d S )Nc                     | |z  S Nr   xys     r   adderz+CAPITests.test_switch_kwargs.<locals>.adder   s    q5Lr            r   )r   r   r   test_switch_kwargs)r   r   gs      r   r    zCAPITests.test_switch_kwargs   sO    	 	 	e$$O>qAKKKLLLLLr   c                     d }t          j         |                                          }|                     d t          j        |                     d S )Nc                  "   d } t          j         |           }|                                 t          j                    j                            |           t          j                    j                            t          d                     d S )Nc                      t          j                    j                                         t          j                    j                                         t	          d          )Nz#Should never have reached this code)r   
getcurrentparentswitchAssertionErrorr   r   r   barz2CAPITests.test_setparent.<locals>.foo.<locals>.bar   sO    #%%,33555
 #%%,33555$%JKKKr   zShould never reach this code)r   r'   r%   r&   throwr(   )r)   childs     r   fooz%CAPITests.test_setparent.<locals>.foo   s    L L L %c**ELLNNN!!(//666!!(..=>>@ @ @ @ @r   )r   r'   r   r   test_setparent)r   r,   	foo_childs      r   r-   zCAPITests.test_setparent   sY    	@ 	@ 	@ %c**1133	=iHHIIIIIr   c                 ,    t          j                     d S r   )r   test_getcurrentr   s    r   r0   zCAPITests.test_getcurrent*   s    ')))))r   c                 X    |                      dt          j        d                      d S )Nc                      dS )Nr2   r   r   r   r   r   z-CAPITests.test_new_greenlet.<locals>.<lambda>.   s     r   )r   r   test_new_greenletr   s    r   r4   zCAPITests.test_new_greenlet-   s+    o?LLMMMMMr   c                 Z    |                      t          j        t          j                   d S r   )assertRaisesr   GreenletExitr   test_raise_dead_greenletr   s    r   test_raise_greenlet_deadz"CAPITests.test_raise_greenlet_dead0   s4    !?#K	M 	M 	M 	M 	Mr   c                 Z    |                      t          j        t          j                   d S r   )r6   r   errorr   test_raise_greenlet_errorr   s    r   r<   z#CAPITests.test_raise_greenlet_error4   s3    NOE	G 	G 	G 	G 	Gr   c                    g fd}t          j         |          }|                                 t          j        |           |                     t                    d           |                     t          d         t                    d           |                     t          d                   dd           d S )Nc                     	 t          j                    j                                         d S # t          $ r0                      t          j                    d                    Y d S t           j        $ r t          w xY w)Nr   )
r   r%   r&   r'   
ValueErrorappendsysexc_infor7   r(   )seens   r   r,   z!CAPITests.test_throw.<locals>.foo;   s    %#%%,3355555 / / /CLNN1-......( % % %$$%s   */ 6A>(A>r   r   z"ValueError was not raised in foo()ztake that sucka!zmessage doesn't match)
r   r'   r   
test_throwr   len
assertTrue
isinstancer?   str)r   r,   r!   rC   s      @r   rD   zCAPITests.test_throw8   s    	% 	% 	% 	% 	% c""	


"1%%%TA&&&tAw
++0	2 	2 	2 	QLL#	% 	% 	% 	% 	%r   c                 ,   |                      t                    5 }t          j        t	          j                    t          t                      |            d d d            n# 1 swxY w Y   |                     t          |j	                  d           d S )Nz1throw() third argument must be a traceback object)
r6   	TypeErrorr   test_throw_exactr   r%   	Exceptionr   rH   	exceptionr   excs     r   test_non_traceback_paramz"CAPITests.test_non_traceback_paramN   s    y)) 	S,#%%	  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	S]++L	N 	N 	N 	N 	Ns   :A!!A%(A%c                 :   |                      t                    5 }t          j        t	          j                    t                      t                      d            d d d            n# 1 swxY w Y   |                     t          |j
                  d           d S )Nz0instance exception may not have a separate value)r6   rJ   r   rK   r   r%   rL   BaseExceptionr   rH   rM   rN   s     r   test_instance_of_wrong_typez%CAPITests.test_instance_of_wrong_typeY   s    y)) 	S,#%%	  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	S]++K	M 	M 	M 	M 	Ms   AA((A,/A,c                 
   |                      t                    5 }t          j        t	          j                    dd d            d d d            n# 1 swxY w Y   |                     t          |j                  d           d S )Nabcz1exceptions must be classes, or instances, not str)	r6   rJ   r   rK   r   r%   r   rH   rM   rN   s     r   test_not_throwablezCAPITests.test_not_throwablee   s    y)) 	S,#%%	  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	S]++L	N 	N 	N 	N 	Ns   )AAAN)__name__
__module____qualname__r   r    r-   r0   r4   r9   r<   rD   rP   rS   rV   r   r   r   r	   r	      s        L L LM M MJ J J&* * *N N NM M MG G G% % %,	N 	N 	N
M 
M 
M	N 	N 	N 	N 	Nr   r	   __main__)
__future__r   r   rA   r    r   r   r	   rW   unittestmainr   r   r   <module>r_      s    % % % % % % & & & & & & 



             bN bN bN bN bN bN bN bNJ zOOOHMOOOOO r   