Your IP : 216.73.216.196


Current Path : /opt/alt/python312/lib64/python3.12/test/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/test/__pycache__/test_winconsoleio.cpython-312.pyc

�

�#�jf���dZddlZddlZddlZddlZddlZddlmZmZejdk7rejd��ddlmZejZGd�dej�Zed	k(rej$�yy)
zTests for WindowsConsoleIO
�N)�	os_helper�requires_resource�win32ztest only relevant on win32)�write_inputc�`�eZdZd�Zd�Zd�Zejej�dddkd�d��Z
d	�Zd
�Ze
d�d��Zd
�Ze
d�d��Zejdd�d��Ze
d�d��Zejdd�d��Ze
d�d��Zy)�WindowsConsoleIOTestsc��|jtttj��|jtttj��|jtttj��y)N)�
assertTrue�
issubclass�ConIO�io�	RawIOBase�assertFalse�BufferedIOBase�
TextIOBase��selfs �=/opt/alt/python312/lib64/python3.12/test/test_winconsoleio.py�test_abczWindowsConsoleIOTests.test_abcsM�����
�5�"�,�,�7�8�����E�2�+<�+<�=�>�����E�2�=�=�9�:�c��|jtdtd�tj�5}|j�}|jtdt|�ddd�	td�}|j
|j��|j|j��|jd|j��|j�|j�	tdd�}|j|j��|j
|j��|jd|j��|j�|j�	tdd�}|j|j��|j
|j��|jd|j��|j�|j�y#1swY���xYw#t$rY��0wxYw#t$rY��wxYw#t$rYywxYw)Nznegative file descriptor���z&Cannot open (console|non-console file)r��w�)�assertRaisesRegex�
ValueErrorr�tempfile�
TemporaryFile�filenor
�readabler�writable�assertEqual�close)r�tmpfile�fd�fs    r�test_open_fdz"WindowsConsoleIOTests.test_open_fds������z�&��r�	3��
#�
#�
%�����!�B�
�"�"�:�8�%��
E�	&�
	��a��A�

�O�O�A�J�J�L�)����Q�Z�Z�\�*����Q����
�+�
�G�G�I�
�G�G�I�
	��a��
�A�

���Q�Z�Z�\�*��O�O�A�J�J�L�)����Q����
�+�
�G�G�I�
�G�G�I�
	��a��
�A�

���Q�Z�Z�\�*��O�O�A�J�J�L�)����Q����
�+�
�G�G�I�
�G�G�I�S&�
%���	��	���	��	���	��	�sA�-H�'H�1H$�<H3�H�	H!� H!�$	H0�/H0�3	H?�>H?c�&�|jtttj�td�}|j|j
��|j|j��|j|j��|j�|j�td�}|j|j
��|j|j��|j|j��|j�|j�tdd�}|j|j
��|j|j��|j|j��|j�|j�tj�dddkr5tddd	�
�}|j|t�|j�yy)N�CON�CONIN$�CONOUT$r���
ri�UzC:/con�rbr��	buffering)�assertRaisesrr�sys�
executabler
r!rr"�assertIsNotNoner r$�getwindowsversion�open�assertIsInstance�rr's  r�test_open_namez$WindowsConsoleIOTests.test_open_nameGs`�����*�e�S�^�^�<��%�L������
�
��%��������&����Q�X�X�Z�(�	���	�	���	��(�O������
�
��%��������&����Q�X�X�Z�(�	���	�	���	��)�S�!���������&�����
�
��%����Q�X�X�Z�(�	���	�	���	�� � �"�2�A�&��7��X�t�q�1�A��!�!�!�U�+�
�G�G�I�8rNr��rz+test does not work on Windows 7 and earlierc���tddd��}|j|t�|j�tddd��}|j|t�|j�y)Nz
\\.\conin$r0rr1z//?/conout$�wb)r8r9rr$r:s  r�test_conin_conout_namesz-WindowsConsoleIOTests.test_conin_conout_namesesR��
����2�����a��'�	���	�����2�����a��'�	���	rc��tj�}|jtj|�t
jj|d�}t|dd��5}dtj�ddcxkrdkrnn|j|t�n|j|t�ddd�y#1swYyxYw)Nr,r?rr1r<r-r.)r�mkdtemp�
addCleanupr�rmtree�os�path�joinr8r4r7r9r�assertNotIsInstance)r�	temp_path�conout_pathr's    r�test_conout_pathz&WindowsConsoleIOTests.test_conout_pathps����$�$�&�	����	�(�(�)�4��g�g�l�l�9�i�8��
�+�t�q�
1�Q���-�-�/���3�D�n�D��%�%�a��/��(�(��E�2�2�
1�
1�s
�#AB=�=Cc��tdd�5}|j|jd�d�ddd�y#1swYyxYw)Nr,rrr)rr#�writer:s  r�test_write_empty_dataz+WindowsConsoleIOTests.test_write_empty_data}s2��
�9�c�
"�a����Q�W�W�S�\�1�-�#�
"�
"�s	�"8�A�consolec�v�g}tdd�5}dD]�}dD]�}|j||z�tdt|��D]w}||d|z}|j|dz�|j|dz�|j	|��5|j|j
|�t|��ddd��y����|D]G}|j	|��5|j|j
|�t|��ddd��I	ddd�y#1swY��xYw#1swY�ixYw#1swYyxYw)	Nr,r)rsabcs	§☃🐍s
����������)s§s☃s🐍r�z��)�data)r�append�range�len�subTestr#rM)r�	testcasesr'�a�b�irSs       r�
test_writez WindowsConsoleIOTests.test_write�s���	�
�9�c�
"�a���K�A��$�$�Q��U�+�"�1�c�!�f�-�� �1�R�a�5�y��!�(�(����5�!�(�(����8�!�\�\�t�\�4� �,�,�Q�W�W�T�]�C��F�C�5�4�.�K�
�"���\�\�t�\�,��$�$�Q�W�W�T�]�C��I�>�-�,�"�!#�
"�5�4��-�,��##�
"�s<�A9D/�+D�3%D/�+D#�
D/�D �D/�#D,�(D/�/D8c�(�tdd�}tj}	|t_t|jj
|dzj
dd��t�}|t_|j||�y#|t_wxYw)Nr+�rz
�	utf-16-le�
surrogatepass)	r8r4�stdinr�buffer�raw�encode�inputr#)r�textra�	old_stdin�actuals     r�assertStdinRoundTripz*WindowsConsoleIOTests.assertStdinRoundTrip�sw���X�s�#���I�I�	�	"��C�I����� � ����&�&�{�O�D�
��W�F�!�C�I������&��"�C�I�s�AB�
Bc�j�|jd�|jd�|jd�y)N�abc123uϼўТλФЙuA͏B ﬖ̳AA̝�rirs r�
test_inputz WindowsConsoleIOTests.test_input�s/��	
�!�!�(�+��!�!�.�1��!�!�"2�3rTz%Handling Non-BMP characters is brokenc�&�|jd�y)Nu􀀀􏿿􏿽rlrs r�test_input_nonbmpz'WindowsConsoleIOTests.test_input_nonbmp�s��	
�!�!�"B�Crc	��djd�}djd�}tdd�D]�}tddd�	�5}t||�d
}|j	d�s(|j|�}||z
}|j	d�s�(|j
||dj|��ddd���y#1swY��xYw)
NuϼўТλФЙ
r_�utf-8r�r+r0rr1r�
�stdin.read({})�rdrUr8r�endswith�readr#�format�r�source�expected�
read_countrarhrZs       r�test_partial_readsz(WindowsConsoleIOTests.test_partial_reads�s���$�*�*�;�7��%�,�,�W�5����2�,�J��h���2�e��E�6�*��� �/�/�%�0��
�
�:�.�A��a�K�F�!�/�/�%�0�� � ���3C�3J�3J�:�3V�W�3�2�'�2�2���AB5�"B5�5B>	c	��djd�}djd�}tdd�D]�}tddd�	�5}t||�d
}|j	d�s(|j|�}||z
}|j	d�s�(|j
||dj|��ddd���y#1swY��xYw)
Nu
􁿿􁀁
r_rqrrrr+r0rr1rrsrtrurys       r�test_partial_surrogate_readsz2WindowsConsoleIOTests.test_partial_surrogate_reads�s���
,�2�2�;�?��-�4�4�W�=����2�,�J��h���2�e��E�6�*��� �/�/�%�0��
�
�:�.�A��a�K�F�!�/�/�%�0�� � ���3C�3J�3J�:�3V�W�3�2�'�2�2�r~c�<�tddd��5}djd�}djd�}t||�|jd	�|j	�}}|j|dd	|�|j|d	d|�ddd�y#1swYyxYw)
Nr+r0rr1uÄ
r_�Ärqr)r8rdrrw�readallr#)rrarzr{rYrZs      r�test_ctrl_zz!WindowsConsoleIOTests.test_ctrl_z�s���
�(�D�A�
.�%�#�*�*�;�7�F��}�}�W�-�H���v�&��:�:�a�=�%�-�-�/�q�A����X�a��]�A�.����X�a�b�\�1�-�
/�
.�
.�s�A:B�B)�__name__�
__module__�__qualname__rr(r;�unittest�skipIfr4r7r@rKrNrr\rirmror}r�r��rrrrs
��;�
-�^�<�X�_�_�*�S�*�*�,�R�a�0�F�:�5�7��7��3�.��y�!�?�"�?�,'��y�!�4�"�4��X�_�_�T�B�C�D�D�D��y�!�X�"�X�"�X�_�_�T�B�C�X�D�X�"�y�!�.�"�.rr�__main__)�__doc__r
rEr4rr��test.supportrr�platform�SkipTest�_testconsoler�_WindowsConsoleIOr�TestCaserr��mainr�rr�<module>r�s{���
�	�
���5��<�<�7��
�(�
�
�9�
:�:�$�
����O.�H�-�-�O.�b�z���H�M�M�O�r