Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_baseexception.cpython-311.pyc
�

�Ke���ddlZddlZddlZddlmZGd�dej��ZGd�dej��Ze	dkrej
��dSdS)�N)�systemc�F�eZdZdZd�Zd�Zd�ZdZd�Zd�Z	d�Z
d	�Zd
�ZdS)�ExceptionClassTestsz]Tests for anything relating to exception objects themselves (e.g.,
    inheritance hierarchy)c�`�|�ttt����dS�N)�
assertTrue�
issubclass�	Exception�object��selfs �A/usr/local/apps/python3/lib/python3.11/test/test_baseexception.py�test_builtins_new_stylez+ExceptionClassTests.test_builtins_new_styles$�����
�9�f�5�5�6�6�6�6�6�c�x�dD]6}|�t||��|jj�d|�d����7dS)N)�args�__str__�__repr__z	 missing z
 attribute)r�hasattr�	__class__�__name__)r
�ins�attrs   r�verify_instance_interfacez-ExceptionClassTests.verify_instance_interfaces[��3�	8�	8�D��O�O�G�C��.�.���/�/�/����7�
8�
8�
8�
8�	8�	8rc�t�t��}tj���D]B}	t	|t
��r|�|j���3#t$rY�?wxYwttj�tj�
t��dd��d���}	|������}	t#t|��}n(#t$$r|�d|z��YnwxYw|�||d|z��|�|��g}d}|D�]�}|���}|�d��}	||	dzd�}
d	|
vrW|
�d	��}|
|d
zd�}|
d|d
z
�}
t1��|kr|�|
����d|
vr"|
�d��}
|
d|
d
z
�}
	t#t|
��}n(#t$$r|�d
|
z��YnwxYw||	kr|�||f��n>||	kr8|dd|	kr&|���|dd|	k�&|�t	||dd
��|j�d|dd
j����	|�|����n#t$rYnwxYw|�|
|��|�|
��|}|	}��	|���n#|���wxYw|�t?|��dd|z��dS)Nrzexception_hierarchy.txtzutf-8)�encodingzbase class %s not a built-inz%s not foundu─��(�����[z%s not a built-in exceptionz is not a subclass of z%s not accounted for) �set�builtins�__dict__�valuesr	�
BaseException�addr�	TypeError�open�os�path�join�split�__file__�readline�rstrip�getattr�AttributeError�fail�assertIn�discard�rindex�index�platform_system�append�poprr�close�assertEqual�len)r
�exc_set�object_�inheritance_tree�superclass_name�last_exc�superclasses�
last_depth�exc_line�depth�exc_name�paren_index�
platform_name�left_bracket�excs               r�test_inheritancez$ExceptionClassTests.test_inheritances#���%�%���(�/�/�1�1�	�	�G�
��g�}�5�5�2��K�K�� 0�1�1�1����
�
�
���
���� �����R�W�]�]�8�4�4�Q�7�9R�S�S� �"�"�"��.	%�.�7�7�9�9�@�@�B�B�O�
L�"�8�_�=�=����!�
L�
L�
L��	�	�8�?�J�K�K�K�K�K�
L�����M�M�/�7�(�?�:�
<�
<�
<��O�O�O�,�,�,��L��J�,�!
#�!
#��#�?�?�,�,�� ����.�.��#�E�!�G�H�H�-���(�?�?�"*�.�.��"5�"5�K�$,�[��]�2�-=�$>�M�'���Q���7�H�&�(�(�M�9�9�����1�1�1� ��(�?�?�#+�>�>�#�#6�#6�L�'���a���8�H�H�!�(�H�5�5�C�C��%�H�H�H��I�I�;�h�F�G�G�G�G�G�H������%�%� �'�'��X�(>�?�?�?�?��%�'�'�&�r�*�1�-��6�6�$�(�(�*�*�*�'�r�*�1�-��6�6����
�3��R�0@��0C� D� D�03���� ��$�Q�'�0�0�2�3�3�3���2�2�3�3�5�5�9�9�9�9�� �����D������
�
�h��0�0�0�����)�)�)���"�
�
�C!
#�F
�"�"�$�$�$�$���"�"�$�$�$�$��������W���q�*@�7�*J�K�K�K�K�Ks��/A � 
A-�,A-�&M8�/D�M8�"D*�'M8�)D*�*C2M8�H3�2M8�3"I�M8�I�B*M8�L!� M8�!
L.�+M8�-L.�.4M8�8N)�lengthr�str�reprc
��t|j|��D]'\}\}}|�|||�d|�d|�����(dS)Nz: z != )�zip�interface_testsr<)r
�results�	test_name�given�expecteds     r�interface_test_driverz)ExceptionClassTests.interface_test_driverUsi��,/��0D�g�,N�,N�	"�	"�(�I�(��x����U�H�	�	�	����x�x�/!�
"�
"�
"�
"�	"�	"rc��d}t|��}t|j��dg|jd|gt|��t|��gt	|��|jj�d|�d�gf}|�|��dS)N�spamrrr�))r
r=rrNrOrrrW)r
�argrKrSs    r�test_interface_single_argz-ExceptionClassTests.test_interface_single_argZs�������n�n�����M�M�1�%�����S�'9���H�H�c�#�h�h�'�
�#�Y�Y�C�M�$:�$:�$:�C�C�C�@�A�C��	
�"�"�7�+�+�+�+�+rc�T�d}tt|����}t|�}t|j��|g|j|gt|��t|��gt
|��|jjt
|j��zgf}|�	|��dS)N�)
�tuple�ranger
r=rrNrOrrrW)r
�	arg_countrrKrSs     r�test_interface_multi_argz,ExceptionClassTests.test_interface_multi_argcs����	��U�9�%�%�&�&���������M�M�9�-���$�/?��S���3�t�9�9�%��c���C�M�2�T�#�(�^�^�C�D�F��	
�"�"�7�+�+�+�+�+rc��t��}t|j��dg|jt��gt	|��dgt|��|jjdzgf}|�|��dS)Nr�z())	r
r=rr_rNrOrrrW)r
rKrSs   r�test_interface_no_argz)ExceptionClassTests.test_interface_no_argmsp���k�k�����M�M�1�%���%�'�'�':��S���2���c���C�M�2�T�9�:�<��	
�"�"�7�+�+�+�+�+rc���ddl}i�G�fd�dt��}Gd�dt��}t��}|���|��<|����|���dS)Nrc�(���eZdZdef��fd�Z�xZS)�XExceptionClassTests.test_setstate_refcount_no_crash.<locals>.HashThisKeyWillClearTheDict�returnc�l������t�����Sr)�clear�super�__hash__)r
r�ds ��rrmzaExceptionClassTests.test_setstate_refcount_no_crash.<locals>.HashThisKeyWillClearTheDict.__hash__{s&������	�	�	��w�w�'�'�)�)�)r)r�
__module__�__qualname__�intrm�
__classcell__)rrns@�r�HashThisKeyWillClearTheDictrhzsJ��������
*�#�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*rrsc��eZdZdS)�BExceptionClassTests.test_setstate_refcount_no_crash.<locals>.ValueN�rrorp�rr�Valueru~��������Drrx)�gcrNr
�__setstate__�collect)r
rzrsrxrKrns     @r�test_setstate_refcount_no_crashz3ExceptionClassTests.test_setstate_refcount_no_crashus����	�	�	�	���	*�	*�	*�	*�	*�	*�	*�#�	*�	*�	*�	�	�	�	�	�C�	�	�	��k�k��+0�5�7�7��
%�
%�
'�
'�(�	�������	�
�
�����rN)
rrorp�__doc__rrrLrRrWr\rbrer}rwrrrrs���������7�7�7�8�8�8�<L�<L�<L�|8�O�"�"�"�
,�,�,�,�,�,�,�,�,�����rrc�<�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
�
UsageTestszTest usage of exceptionsc�*�	|�#t$rYdSwxYw)z6Make sure that raising 'object_' triggers a TypeError.N)r(r3�type�r
r?s  r�raise_failszUsageTests.raise_fails�s.��	��M���	�	�	��F�F�	���s��
�c�\�		t�#|$rYnwxYwn@#t$rYn4t$r(|�dt|��z��YnwxYw		t�#|f$rYdSwxYw#t$rYdSt$r)|�dt|��z��YdSwxYw)z,Catching 'object_' should raise a TypeError.z#TypeError expected when catching %sNz;TypeError expected when catching %s as specified in a tuple)r
r(r3r�r�s  r�catch_failszUsageTests.catch_fails�s.��	M�
�����
�
�
���
�������	�	�	��D��	M�	M�	M��I�I�;�d�7�m�m�K�L�L�L�L�L�	M����		1�
�����:�
�
�
����
������	�	�	��F�F��	1�	1�	1��I�I� �"&�w�-�-�0�
1�
1�
1�
1�
1�
1�	1���sT�
�����
A�.A�A�A�A)�%A,�(A)�)A,�,
B+�9.B+�*B+c��Gd�dt��}|�|��|�|����dS)Nc��eZdZdS)�DUsageTests.test_raise_new_style_non_exception.<locals>.NewStyleClassNrvrwrr�
NewStyleClassr��ryrr�)rr�)r
r�s  r�"test_raise_new_style_non_exceptionz-UsageTests.test_raise_new_style_non_exception�s`��
	�	�	�	�	�F�	�	�	�����'�'�'��������)�)�)�)�)rc�0�|�d��dS�NrY)r�rs r�test_raise_stringzUsageTests.test_raise_string�������� � � � � rc��Gd�dt��}|�|��|�|����dS)Nc��eZdZdS)�AUsageTests.test_catch_non_BaseException.<locals>.NonBaseExceptionNrvrwrr�NonBaseExceptionr��ryrr�)rr�)r
r�s  r�test_catch_non_BaseExceptionz'UsageTests.test_catch_non_BaseException�se��	�	�	�	�	�v�	�	�	����)�*�*�*����)�)�+�+�,�,�,�,�,rc�H�|�t����dSr)r�r&rs r�!test_catch_BaseException_instancez,UsageTests.test_catch_BaseException_instance�s ��������)�)�)�)�)rc�0�|�d��dSr�)r�rs r�test_catch_stringzUsageTests.test_catch_string�r�rN)rrorpr~r�r�r�r�r�r�r�rwrrr�r��s�������"�"�G�G�G�1�1�1�.*�*�*�!�!�!�-�-�-�*�*�*�!�!�!�!�!rr��__main__)�unittestr#r*�platformrr8�TestCaserr�r�mainrwrr�<module>r�s�����������	�	�	�	�.�.�.�.�.�.�D�D�D�D�D�(�+�D�D�D�N?!�?!�?!�?!�?!��"�?!�?!�?!�D�z����H�M�O�O�O�O�O��r