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

�Ke)���ddlZddlZddlZddlZddlZddlZddlmZGd�de��ZGd�de��Z	Gd�de��Z
Gd	�d
e	e
��ZGd�de
e	��ZGd
�de��Z
Gd�dej��ZGd�dej��ZGd�dej��Zedkrej��dSdS)�N)�EEXISTc��eZdZdS)�
SubOSErrorN��__name__�
__module__�__qualname__���G/usr/local/apps/python3/lib/python3.11/test/test_exception_hierarchy.pyrr
��������Drrc���eZdZ�fd�Z�xZS)�SubOSErrorWithInitc�X��||_t���|��dS�N)�bar�super�__init__)�self�messager�	__class__s   �rrzSubOSErrorWithInit.__init__s(������
������!�!�!�!�!r)rrr	r�
__classcell__�rs@rrr
s8�������"�"�"�"�"�"�"�"�"rrc���eZdZ�fd�Z�xZS)�SubOSErrorWithNewc�Z��t���||��}||_|Sr)r�__new__�baz)�clsrrrrs    �rrzSubOSErrorWithNew.__new__s&����w�w���s�G�,�,������r)rrr	rrrs@rrrs8���������������rrc��eZdZdS)�SubOSErrorCombinedInitFirstNrr
rrr!r!r
rr!c��eZdZdS)�SubOSErrorCombinedNewFirstNrr
rrr#r#r
rr#c��eZdZd�ZdS)�SubOSErrorWithStandaloneInitc��dSrr
�rs rrz%SubOSErrorWithStandaloneInit.__init__s���rN)rrr	rr
rrr%r%s#������
�
�
�
�
rr%c�L�eZdZd�Zd�Zd�ZdZd�Zee��Zd�Z	d�Z
dS)	�
HierarchyTestc���|�tjd��|�tt��|�t
t��dS)N�OSError)�assertEqualr+r�assertIs�IOError�EnvironmentErrorr's r�test_builtin_errorsz!HierarchyTest.test_builtin_errors%sJ������)�9�5�5�5��
�
�g�w�'�'�'��
�
�&��0�0�0�0�0rc�B�|�tjt��|�tjjt��|�tjjt��|�tjt��dSr)	r-�socket�errorr+�gaierror�__base__�herror�timeout�TimeoutErrorr's r�test_socket_errorsz HierarchyTest.test_socket_errors*sf���
�
�f�l�G�,�,�,��
�
�f�o�.��8�8�8��
�
�f�m�,�g�6�6�6��
�
�f�n�l�3�3�3�3�3rc�P�|�tjt��dSr)r-�selectr3r+r's r�test_select_errorzHierarchyTest.test_select_error0s���
�
�f�l�G�,�,�,�,�,rae
        +-- BlockingIOError        EAGAIN, EALREADY, EWOULDBLOCK, EINPROGRESS
        +-- ChildProcessError                                          ECHILD
        +-- ConnectionError
            +-- BrokenPipeError                              EPIPE, ESHUTDOWN
            +-- ConnectionAbortedError                           ECONNABORTED
            +-- ConnectionRefusedError                           ECONNREFUSED
            +-- ConnectionResetError                               ECONNRESET
        +-- FileExistsError                                            EEXIST
        +-- FileNotFoundError                                          ENOENT
        +-- InterruptedError                                            EINTR
        +-- IsADirectoryError                                          EISDIR
        +-- NotADirectoryError                                        ENOTDIR
        +-- PermissionError                        EACCES, EPERM, ENOTCAPABLE
        +-- ProcessLookupError                                          ESRCH
        +-- TimeoutError                                            ETIMEDOUT
    c��i}|���D]�}|�d��}|s�|�d��\}}}td|����d����D]I}|dkrtt|��s�tt|��|tt|��<�J��|S)Nz+- � z, �ENOTCAPABLE)	�
splitlines�strip�	partition�filter�split�hasattr�errno�getattr�builtins)�s�_map�line�excname�_�errnames�errnames       r�	_make_mapzHierarchyTest._make_mapFs������L�L�N�N�	K�	K�D��:�:�e�$�$�D��
��#'�>�>�#�#6�#6� �G�Q��!�$����(8�(8�(>�(>�t�(D�(D�E�E�
K�
K���m�+�+�G�E�7�4K�4K�+��07��'�0J�0J��W�U�G�,�,�-�-�
K��rc��ttd��}|�t|��t��|j���D]8\}}t|d��}|�t|��|���9ttj	��t|j��z
}|D]H}t|d��}|�t|��tt|�����IdS)N�Bad file descriptorzSome message)r+rr-�type�FileExistsErrorrJ�items�setrF�	errorcode�repr)r�e�errcode�exc�
othercodess     r�test_errno_mappingz HierarchyTest.test_errno_mappingTs���
�F�1�2�2���
�
�d�1�g�g��/�/�/� �I�O�O�-�-�	(�	(�L�G�S����0�0�A��M�M�$�q�'�'�3�'�'�'�'����)�)�C��	�N�N�:�
�!�	5�	5�G����0�0�A��M�M�$�q�'�'�7�D��G�G�4�4�4�4�	5�	5rc�P�d}	t|��|�d��n#t$rYnwxYw|�tj�|����	t	j|��|�d��dS#t$rYdSwxYw)N� some_hopefully_non_existing_filez&should have raised a FileNotFoundError)�open�fail�FileNotFoundError�assertFalse�os�path�exists�unlink)r�filenames  r�test_try_exceptzHierarchyTest.test_try_exceptbs���5��	@���N�N�N�
�I�I�>�?�?�?�?��!�	�	�	��D�	����	
��������1�1�2�2�2�	@��I�h����
�I�I�>�?�?�?�?�?��!�	�	�	��D�D�	���s�)�
6�6�,B�
B%�$B%N)rrr	r0r9r<�_pep_maprPrJr]rir
rrr)r)#s�������1�1�1�
4�4�4�-�-�-�
�H�"����9�X���D�5�5�5�@�@�@�@�@rr)c�f�eZdZd�Zd�Zejejdkd��d���Z	d�Z
dS)�AttributesTestc���tjdkr*|�dtt����dS|�dtt����dS)N�nt�winerror)rd�name�assertIn�dirr+�assertNotInr's r�test_windows_errorz!AttributesTest.test_windows_error|sO��
�7�d�?�?��M�M�*�c�'�l�l�3�3�3�3�3����Z��W���6�6�6�6�6rc��ttdd��}|�|jt��|�|jdt��|�|jd��|�|jd��tjdkr|�|j	d��dSdS)N�File already exists�foo.txtrrn)
r+rr,rF�args�strerrorrhrdrpro�rrYs  r�test_posix_errorzAttributesTest.test_posix_error�s����F�1�9�=�=�������&�)�)�)��������F�+�+�+������%:�;�;�;������Y�/�/�/�
�7�d�?�?����Q�Z��.�.�.�.�.��?rrnzWindows-specific testc�X�tdddd��}|�|jd��|�|jt��|�|jdt��|�|jd��|�|jd��dS)Nrrvrw�)r+r,rorFrrxryrhrzs  r�test_errno_translationz%AttributesTest.test_errno_translation�s���
�A�,�i��=�=�������S�)�)�)������&�)�)�)��������F�+�+�+������%:�;�;�;������Y�/�/�/�/�/rc�>�d}td��D]�}t|d|��}|�t��5|jddd��n#1swxYwY|�t��5|`ddd��n#1swxYwY��tddd��}|�|jd��d|_|�|jd��|`|�t��5|jddd��dS#1swxYwYdS)N)�a�b�c�drY�r�r���)�range�BlockingIOError�assertRaises�AttributeError�characters_writtenr,)rrx�nrYs    r�test_blockingioerrorz#AttributesTest.test_blockingioerror�s���(���q���	)�	)�A���b�q�b��*�A��"�"�>�2�2�
%�
%��$�$�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%����
%�
%�
%�
%��"�"�>�2�2�
)�
)��(�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)����
)�
)�
)�
)���C��a�(�(������-�q�1�1�1� �������-�q�1�1�1�
� �
�
�
�~�
.�
.�	!�	!�
� � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!�	!�	!s5�A�A	�A	�8B�B	�B	�=D�D�DN)rrr	rtr{�unittest�
skipUnlessrdrpr~r�r
rrrlrlzst������7�7�7�/�/�/��X����D��*A�B�B�0�0�C�B�0�!�!�!�!�!rrlc�8�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	dS)	�ExplicitSubclassingTestc��ttd��}|�t|��t��dS)NrR)rrr-rSrzs  rr]z*ExplicitSubclassingTest.test_errno_mapping�s2���v�4�5�5���
�
�d�1�g�g�z�*�*�*�*�*rc��tdd��}|�|jd��|�|jd��dS�N�some messager�r��rr,rrxrzs  r�test_init_overriddenz,ExplicitSubclassingTest.test_init_overridden�sH���~�u�5�5��������&�&�&������!2�3�3�3�3�3rc��tdd���}|�|jd��|�|jd��dS)Nr�r)rr�r�rzs  r�test_init_kwdargsz)ExplicitSubclassingTest.test_init_kwdargs�sK���~�5�9�9�9��������&�&�&������!2�3�3�3�3�3rc��tdd��}|�|jd��|�|jd��dSr��rr,rrxrzs  r�test_new_overriddenz+ExplicitSubclassingTest.test_new_overridden�sH���n�e�4�4��������&�&�&������!2�3�3�3�3�3rc��tdd���}|�|jd��|�|jd��dS)Nr�r)rr�r�rzs  r�test_new_kwdargsz(ExplicitSubclassingTest.test_new_kwdargs�sK���n�%�8�8�8��������&�&�&������!2�3�3�3�3�3rc��tdd��}|�|jd��|�|jd��|�|jd��tdd��}|�|jd��|�|jd��|�|jd��dSr�)r!r,rrrxr#rzs  r�test_init_new_overriddenz0ExplicitSubclassingTest.test_init_new_overridden�s���'���>�>��������&�&�&�������&�&�&������!2�3�3�3�&�~�u�=�=��������&�&�&�������&�&�&������!2�3�3�3�3�3rc��t��}|�|jd��|�t|��d��dS)Nr
�)r%r,rx�strrzs  r�test_init_standalonez,ExplicitSubclassingTest.test_init_standalone�sG��(�*�*��������$�$�$�����Q����$�$�$�$�$rN)
rrr	r]r�r�r�r�r�r�r
rrr�r��s}������+�+�+�
4�4�4�
4�4�4�
4�4�4�
4�4�4�
4�4�4�%�%�%�%�%rr��__main__)rHrdr;r2r�rFrr+rrrr!r#r%�TestCaser)rlr�r�mainr
rr�<module>r�s������	�	�	�	�
�
�
�
�
�
�
�
���������������	�	�	�	�	��	�	�	�"�"�"�"�"��"�"�"�
���������	�	�	�	�	�"4�6G�	�	�	�	�	�	�	�	�!2�4F�	�	�	�
�
�
�
�
�7�
�
�
�
T@�T@�T@�T@�T@�H�%�T@�T@�T@�n)!�)!�)!�)!�)!�X�&�)!�)!�)!�X)%�)%�)%�)%�)%�h�/�)%�)%�)%�X�z����H�M�O�O�O�O�O��r