Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib64/python3.7/test/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/test/__pycache__/test_exception_hierarchy.cpython-37.pyc

B

� f��@s�ddlZddlZddlZddlZddlZddlZddlmZGdd�de�ZGdd�de�Z	Gdd�de�Z
Gd	d
�d
e	e
�ZGdd�de
e	�ZGd
d�de�Z
Gdd�dej�ZGdd�dej�ZGdd�dej�Zedkr�e��dS)�N)�EEXISTc@seZdZdS)�
SubOSErrorN)�__name__�
__module__�__qualname__�rr�B/opt/alt/python37/lib64/python3.7/test/test_exception_hierarchy.pyr
srcseZdZ�fdd�Z�ZS)�SubOSErrorWithInitcs||_t��|�dS)N)�bar�super�__init__)�self�messager
)�	__class__rrrszSubOSErrorWithInit.__init__)rrrr�
__classcell__rr)rrr	
sr	cseZdZ�fdd�Z�ZS)�SubOSErrorWithNewcst��||�}||_|S)N)r�__new__�baz)�clsrrr
)rrrrszSubOSErrorWithNew.__new__)rrrrrrr)rrrsrc@seZdZdS)�SubOSErrorCombinedInitFirstN)rrrrrrrrsrc@seZdZdS)�SubOSErrorCombinedNewFirstN)rrrrrrrrsrc@seZdZdd�ZdS)�SubOSErrorWithStandaloneInitcCsdS)Nr)r
rrrrsz%SubOSErrorWithStandaloneInit.__init__N)rrrrrrrrrsrc@sHeZdZdd�Zdd�Zdd�ZdZdd	�Zee�Zd
d�Z	dd
�Z
dS)�
HierarchyTestcCs*|�tjd�|�tt�|�tt�dS)N�OSError)�assertEqualrr�assertIs�IOError�EnvironmentError)r
rrr�test_builtin_errors%sz!HierarchyTest.test_builtin_errorscCsB|�tjt�|�tjjt�|�tjjt�|�tjjt�dS)N)	r�socket�errorrZgaierror�__base__rZherrorZtimeout)r
rrr�test_socket_errors*sz HierarchyTest.test_socket_errorscCs|�tjt�dS)N)r�selectr r)r
rrr�test_select_error0szHierarchyTest.test_select_errorae
        +-- 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
        +-- ProcessLookupError                                          ESRCH
        +-- TimeoutError                                            ETIMEDOUT
    cCsli}xb|��D]V}|�d�}|s"q|�d�\}}}x0td|���d��D]}tt|�|tt|�<qHWqW|S)Nz+- � z, )�
splitlines�strip�	partition�filter�split�getattr�builtins�errno)�s�_map�lineZexcname�_ZerrnamesZerrnamerrr�	_make_mapFs
zHierarchyTest._make_mapcCs�ttd�}|�t|�t�x0|j��D]"\}}t|d�}|�t|�|�q&Wttj	�t|j�}x&|D]}t|d�}|�t|�t�qfWdS)NzBad file descriptorzSome message)
rrr�type�FileExistsErrorr/�items�setr-Z	errorcode)r
�eZerrcode�excZ
othercodesrrr�test_errno_mappingRs



z HierarchyTest.test_errno_mappingcCstd}yt|�Wntk
r$YnX|�d�|�tj�|��yt�|�Wntk
rdYnX|�d�dS)NZ some_hopefully_non_existing_filez&should have raised a FileNotFoundError)�open�FileNotFoundErrorZfailZassertFalse�os�path�exists�unlink)r
�filenamerrr�test_try_except`s
zHierarchyTest.test_try_exceptN)rrrrr"r$Z_pep_mapr2r/r9rArrrrr#s
rc@s>eZdZdd�Zdd�Ze�ejdkd�dd��Z	d	d
�Z
dS)�AttributesTestcCs0tjdkr|�dtt��n|�dtt��dS)N�nt�winerror)r<�nameZassertIn�dirrZassertNotIn)r
rrr�test_windows_errorzs
z!AttributesTest.test_windows_errorcCsdttdd�}|�|jt�|�|jdt�|�|jd�|�|jd�tjdkr`|�|j	d�dS)NzFile already existszfoo.txtrrC)
rrrr-�args�strerrorr@r<rErD)r
r7rrr�test_posix_error�s
zAttributesTest.test_posix_errorrCzWindows-specific testcCs\tdddd�}|�|jd�|�|jt�|�|jdt�|�|jd�|�|jd�dS)NrzFile already existszfoo.txt�)rrrDr-rrHrIr@)r
r7rrr�test_errno_translation�sz%AttributesTest.test_errno_translationc
Cstd}x<td�D]0}t|d|��}|�t��|jWdQRXqWtddd�}|�|jd�d|_|�|jd�dS)N)�a�b�c�dr7�rMrN��)�range�BlockingIOErrorZassertRaises�AttributeError�characters_writtenr)r
rH�nr7rrr�test_blockingioerror�sz#AttributesTest.test_blockingioerrorN)rrrrGrJ�unittestZ
skipUnlessr<rErLrYrrrrrBxs	
rBc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ExplicitSubclassingTestcCsttd�}|�t|�t�dS)NzBad file descriptor)rrrr3)r
r7rrrr9�s
z*ExplicitSubclassingTest.test_errno_mappingcCs*tdd�}|�|jd�|�|jd�dS)Nzsome messager)zsome message)r	rr
rH)r
r7rrr�test_init_overridden�s
z,ExplicitSubclassingTest.test_init_overriddencCs,tddd�}|�|jd�|�|jd�dS)Nzsome messager)r
)zsome message)r	rr
rH)r
r7rrr�test_init_kwdargs�sz)ExplicitSubclassingTest.test_init_kwdargscCs*tdd�}|�|jd�|�|jd�dS)Nzsome messager)zsome message)rrrrH)r
r7rrr�test_new_overridden�s
z+ExplicitSubclassingTest.test_new_overriddencCs,tddd�}|�|jd�|�|jd�dS)Nzsome messager)r)zsome message)rrrrH)r
r7rrr�test_new_kwdargs�sz(ExplicitSubclassingTest.test_new_kwdargscCsltdd�}|�|jd�|�|jd�|�|jd�tdd�}|�|jd�|�|jd�|�|jd�dS)Nzsome messager)zsome message)rrr
rrHr)r
r7rrr�test_init_new_overridden�s

z0ExplicitSubclassingTest.test_init_new_overriddencCs(t�}|�|jd�|�t|�d�dS)Nr�)rrrH�str)r
r7rrr�test_init_standalone�sz,ExplicitSubclassingTest.test_init_standaloneN)
rrrr9r\r]r^r_r`rcrrrrr[�s
r[�__main__)r,r<r#rrZr-rrrr	rrrrZTestCaserrBr[r�mainrrrr�<module>s"U',