Your IP : 216.73.216.60


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_winconsoleio.cpython-39.pyc

a

XC?h;�@s�dZddlZddlZddlZddlZddlZddlmZejdkrLe�	d��ddl
mZejZ
Gdd�dej�Zed	kr�e��dS)
zTests for WindowsConsoleIO
�N)�supportZwin32ztest only relevant on win32)�write_inputc@s�eZdZdd�Zdd�Zdd�Ze�e�	�dd�d	kd
�dd��Z
d
d�Zdd�Zdd�Z
dd�Ze�dd�dd��Zdd�Ze�dd�dd��Zdd�ZdS)�WindowsConsoleIOTestscCs:|�tttj��|�tttj��|�tttj��dS)N)�
assertTrue�
issubclass�ConIO�io�	RawIOBase�assertFalse�BufferedIOBase�
TextIOBase��self�r�;/opt/alt/python39/lib64/python3.9/test/test_winconsoleio.py�test_abcszWindowsConsoleIOTests.test_abccCsn|�tdtd�t���(}|��}|�tdt|�Wd�n1sF0Yztd�}WntynYn>0|�|���|�|�	��|�
d|���|��|��ztdd�}Wnty�Yn>0|�|���|�|�	��|�
d|���|��|��ztdd�}Wnt�y,Yn>0|�|���|�|�	��|�
d|���|��|��dS)Nznegative file descriptor���z&Cannot open (console|non-console file)r��w�)ZassertRaisesRegex�
ValueErrorr�tempfileZ
TemporaryFile�filenor�readabler
�writable�assertEqual�close)rZtmpfile�fd�frrr�test_open_fdsF�
�"z"WindowsConsoleIOTests.test_open_fdcCs|�tttj�td�}|�|���|�|���|�	|�
��|��|��td�}|�|���|�|���|�	|�
��|��|��tdd�}|�|���|�|���|�	|�
��|��|��t��dd�dk�rt
ddd	d
�}|�|t�|��dS)NZCON�CONIN$�CONOUT$r���
ri�UzC:/con�rbr��	buffering)ZassertRaisesrr�sys�
executablerrr
rZassertIsNotNonerr�getwindowsversion�open�assertIsInstance�rrrrr�test_open_nameGs.
z$WindowsConsoleIOTests.test_open_nameNr��rz+test does not work on Windows 7 and earliercCsHtdddd�}|�|t�|��tdddd�}|�|t�|��dS)Nz
\\.\conin$r%rr&z//?/conout$�wb)r+r,rrr-rrr�test_conin_conout_namesesz-WindowsConsoleIOTests.test_conin_conout_namescCs�t��}|�tj|�tj�|d�}t|ddd��N}dt	�
�dd�krTdkrfnn|�|t�n|�
|t�Wd�n1s�0YdS)Nr!r1rr&r/r"r#)rZmkdtempZ
addCleanuprZrmtree�os�path�joinr+r(r*r,rZassertNotIsInstance)rZ	temp_pathZconout_pathrrrr�test_conout_pathps$z&WindowsConsoleIOTests.test_conout_pathcCs@tdd��"}|�|�d�d�Wd�n1s20YdS)Nr!r�r)rr�writer-rrr�test_write_empty_data}sz+WindowsConsoleIOTests.test_write_empty_datacCsZtdd�}tj}z0|t_t|jj|d�dd��t�}W|t_n|t_0|�||�dS)Nr �rz
�	utf-16-le�
surrogatepass)	r+r(�stdinr�buffer�raw�encode�inputr)r�textr=Z	old_stdin�actualrrr�assertStdinRoundTrip�s
�z*WindowsConsoleIOTests.assertStdinRoundTripcCs"|�d�|�d�|�d�dS)NZabc123uϼўТλФЙuA͏B ﬖ̳AA̝�rDr
rrr�
test_input�s

z WindowsConsoleIOTests.test_inputTz%Handling Non-BMP characters is brokencCs|�d�dS)Nu􀀀􏿿􏿽rEr
rrr�test_input_nonbmp�sz'WindowsConsoleIOTests.test_input_nonbmpc	Cs�d�d�}d�d�}tdd�D]r}tdddd	��P}t||�d
}|�d�s^|�|�}||7}q@|�||d�|��Wd�q1s�0YqdS)
NuϼўТλФЙ
r;�utf-8r�r r%rr&r7�
�stdin.read({})�r@�ranger+r�endswith�readr�format�r�source�expectedZ
read_countr=rC�brrr�test_partial_reads�s





z(WindowsConsoleIOTests.test_partial_readsc	Cs�d�d�}d�d�}tdd�D]r}tdddd	��P}t||�d
}|�d�s^|�|�}||7}q@|�||d�|��Wd�q1s�0YqdS)
Nu
􁿿􁀁
r;rHrrIr r%rr&r7rJrKrLrQrrr�test_partial_surrogate_reads�s





z2WindowsConsoleIOTests.test_partial_surrogate_readscCs�tdddd��j}d�d�}d�d�}t||�|�d	�|��}}|�|dd	�|�|�|d	d�|�Wd�n1s~0YdS)
Nr r%rr&uÄ
r;�ÄrHr)r+r@rrO�readallr)rr=rRrS�arTrrr�test_ctrl_z�s


z!WindowsConsoleIOTests.test_ctrl_z)�__name__�
__module__�__qualname__rrr.�unittestZskipIfr(r*r2r6r9rDrFrGrUrVrZrrrrrs"/�
	
	



r�__main__)�__doc__rr3r(rr^�testr�platformZSkipTestZ_testconsoler�_WindowsConsoleIOrZTestCaserr[�mainrrrr�<module>s

8