Your IP : 216.73.216.85


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_winconsoleio.cpython-310.opt-2.pyc

o

0�iG�@s�	ddlZddlZddlZddlZddlZddlmZejdkr%e�d��ddl	m
Z
ejZGdd�dej
�ZedkrAe��dSdS)	�N)�	os_helperZwin32ztest 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/python310/lib64/python3.10/test/test_winconsoleio.py�test_abcszWindowsConsoleIOTests.test_abccCsn|�tdtd�t���}|��}|�tdt|�Wd�n1s#wYztd�}Wn	ty7Ynw|�|���|�|�	��|�
d|���|��|��ztdd�}Wn	tyfYnw|�|���|�|�	��|�
d|���|��|��ztdd�}Wn
ty�YdSw|�|���|�|�	��|�
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_fdsN�
�����z"WindowsConsoleIOTests.test_open_fdcCs|�tttj�td�}|�|���|�|���|�	|�
��|��|��td�}|�|���|�|���|�	|�
��|��|��tdd�}|�|���|�|���|�	|�
��|��|��t��dd�dkr�t
ddd	d
�}|�|t�|��dSdS)NZCON�CONIN$�CONOUT$r���
ri�UzC:/con�rbr��	buffering)ZassertRaisesrr�sys�
executablerrr
rZassertIsNotNonerr�getwindowsversion�open�assertIsInstance�rrrrr�test_open_nameGs0
�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��0}dt	�
�dd�kr*dkr3nn|�|t�n|�
|t�Wd�dSWd�dS1sLwYdS)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_pathcCsBtdd��}|�|�d�d�Wd�dS1swYdS)Nr!r�r)rr�writer-rrr�test_write_empty_data}s"�z+WindowsConsoleIOTests.test_write_empty_datacCsZtdd�}tj}z|t_t|jj|d�dd��t�}W|t_n|t_w|�||�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	C�d�d�}d�d�}tdd�D]=}tdddd	��,}t||�d
}|�d�s3|�|�}||7}|�d�r%|�||d�|��Wd�n1sGwYqdS)
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	CrH)
Nu
􁿿􁀁
r;rIrrJr r%rr&r7rKrLrMrRrrr�test_partial_surrogate_reads�s





����z2WindowsConsoleIOTests.test_partial_surrogate_readscCs�tdddd��6}d�d�}d�d�}t||�|�d	�|��}}|�|dd	�|�|�|d	d�|�Wd�dS1s@wYdS)
Nr r%rr&uÄ
r;�ÄrIr)r+r@rrP�readallr)rr=rSrT�arUrrr�test_ctrl_z�s


"�z!WindowsConsoleIOTests.test_ctrl_z)�__name__�
__module__�__qualname__rrr.�unittestZskipIfr(r*r2r6r9rDrFrGrVrWr[rrrrrs$/�
	

	


r�__main__)rr3r(rr_Ztest.supportr�platformZSkipTestZ_testconsoler�_WindowsConsoleIOrZTestCaserr\�mainrrrr�<module>s 

8�