Viewing File: /opt/hc_python/lib/python3.12/site-packages/greenlet/tests/__pycache__/test_throw.cpython-312.pyc

�

i0i���@�ddlZddlmZddlmZd�ZGd�de�Zy)�N)�greenlet�)�TestCasec�X�tj�jj|�S)N)r�
getcurrent�parent�switch)�argss �J/opt/hc_python/lib64/python3.12/site-packages/greenlet/tests/test_throw.pyr	r	s$��.�8��� �'�'�.�.��5�5�c�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�
ThrowTestsc��d�}t|�}|j�}|j|d�|jt�}|j|d�y)Nc�f�	td�td�y#t$rtd�YywxYw�N�ok�fail)r	�RuntimeError�rr�fz ThrowTests.test_class.<locals>.f
s2��
��t��
�6�N�� �
��t���
�s��0�0r�rr	�assertEqual�throwr��selfr�g�ress    r�
test_classzThrowTests.test_classsK��	�
�Q�K���h�h�j������d�#��g�g�l�#������d�#rc�f�d�}t|�}|j�}|j|d�|jt	d��}|j|d�t|�}|j�}|j|d�|jtd�}|j|d�y)Nc��	td�td�y#t$r5tj�d}t	|�dk(r
td�YyY�IwxYw)Nrr�ciaor)r	r�sys�exc_info�str)�vals rrzThrowTests.test_val.<locals>.fsS��
��t��
�6�N�� �
��l�l�n�Q�'���s�8�v�%��4�L��&�
�s��9A�Arr!rrs    r�test_valzThrowTests.test_vals���	�
�Q�K���h�h�j������d�#��g�g�l�6�*�+������d�#��Q�K���h�h�j������d�#��g�g�l�F�+������d�#rc�~�d�}t|�}|j�}|j|d�|j�}|j	t|tj��|j	|j�|j�}|j	t|tj��y)Nc�0�td�td�yr�r	rrrrzThrowTests.test_kill.<locals>.f2s���4�L��6�Nrr)rr	rr�
assertTrue�
isinstance�GreenletExit�deadrs    r�	test_killzThrowTests.test_kill1s���	�
�Q�K���h�h�j������d�#��g�g�i�����
�3��(=�(=�>�?���������g�g�i�����
�3��(=�(=�>�?rc���tj���fd�}�fd�}t|�}t||��}|jt�5|j	t�ddd�|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#1swY���xYw)Nc�H��	�jd�y#t$rYywxYw)N�f1 ready to catch�caughtznormal exit)r	�
IndexError��mains�r�f1z9ThrowTests.test_throw_goes_to_original_parent.<locals>.f1As.���
 ����/�0�!���
 ��
 �s��	!�!c�(���jd�y)N�from f2r)r4s�r�f2z9ThrowTests.test_throw_goes_to_original_parent.<locals>.f2Hs����K�K�	�"r)rr1r2r8)	rr�assertRaisesr3rr*r-r	r)rr6r9�g1�g2rr5s      @r�"test_throw_goes_to_original_parentz-ThrowTests.test_throw_goes_to_original_parent>ss����"�"�$��	!�	#��b�\��
�b��
$��
�
�
�z�
*��H�H�Z� �+������� ������� �
�b�\��
�b��
$���i�i�k������1�2��h�h�z�"������h�'������� ������� �
�b�\��
�b��
$���i�i�k������1�2��i�i�k������i�(��h�h�z�"������h�'������� ������� �/+�
*�s�
G2�2G<c��|jt�5}tj�j	t
t�|�ddd�|j
tj�d�y#1swY�/xYw)Nz1throw() third argument must be a traceback object)	r:�	TypeErrorrrr�	Exceptionrr$�	exception�r�excs  r�test_non_traceback_paramz#ThrowTests.test_non_traceback_paramfsa��
�
�
�y�
)�S����!�'�'�����
�*�	
����S�]�]�+�L�	N�
*�
)�s�2A6�6A?c�
�|jt�5}tj�j	t�t
��ddd�|jtj�d�y#1swY�/xYw)Nz0instance exception may not have a separate value)
r:r?rrrr@�
BaseExceptionrr$rArBs  r�test_instance_of_wrong_typez&ThrowTests.test_instance_of_wrong_typeps`��
�
�
�y�
)�S����!�'�'�����
�*�	
����S�]�]�+�K�	M�
*�
)�s�5A9�9Bc���|jt�5}tj�j	d�ddd�|jt
j�d�y#1swY�/xYw)N�abcz1exceptions must be classes, or instances, not str)r:r?rrrrr$rArBs  r�test_not_throwablezThrowTests.test_not_throwablezsY��
�
�
�y�
)�S����!�'�'��
�*�	
����S�]�]�+�L�	N�	*�
)�s�$A(�(A1N)
�__name__�
__module__�__qualname__rr&r.r=rDrGrJrrrrrs*��$�$�.@�&!�PN�M�Nrr)r"r�rr	rrrr�<module>rOs%��
���6�uN��uNr
Back to Directory File Manager