Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_io.cpython-312.opt-2.pyc

�

'Μg����
�	ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZmZddlmZmZddlmZddlmZmZmZddlmZddlmZddlmZdd	lmZdd
lm Z ddl!m"Z"ddl#Z#ddl$Z$ddl%Z&	ddl'Z'd�Z(Gd
�de'jR�Z*ejXxsejZj\Z/d�Z0ejbe2ed�d�Z3Gd�d�Z4Gd�d�Z5Gd�de5e$jl�Z7Gd�de5e&jl�Z8Gd�de5�Z9Gd�de9e$jl�Z:Gd�d e9e&jl�Z;Gd!�d"e9�Z<Gd#�d$e<e$jl�Z=Gd%�d&e<e&jl�Z>Gd'�d(e9�Z?Gd)�d*e?e$jl�Z@Gd+�d,e?e&jl�ZAGd-�d.e9�ZBGd/�d0eBe$jl�ZCGd1�d2eBe&jl�ZDGd3�d4�ZEGd5�d6eEe$j��ZGGd7�d8eEe&j��ZHGd9�d:�ZIGd;�d<eIe$j��ZJGd=�d>eIe&j��ZKGd?�d@eE�ZLGdA�dBeLe$j��ZMGdC�dDeLe&j��ZNGdE�dF�ZOGdG�dHeOe$jl�ZPGdI�dJeOe&jl�ZQGdK�dLej��ZSGdM�dNeS�ZTej�GdO�dPej���ZVGdQ�dReS�ZWej�GdS�dTej���ZXGdU�dV�ZYGdW�dX�ZZGdY�dZej�eY�Z[Gd[�d\e[eZ�Z\Gd]�d^e[�Z]Gd_�d`ej�eY�Z^Gda�dbe^eZ�Z_Gdc�dde^�Z`Gde�dfej��ZaGdg�dhea�ZbGdi�djea�ZcGdk�dle[e^�ZdGdm�dnedeZ�ZeGdo�dped�ZfGdq�dre#j��Zhds�ZiGdt�duej��ZjGdv�dwej��ZkGdx�dye$j��Zldz�ZmGd{�d|ek�ZnGd}�d~ek�ZoGd�d�ej��ZpGd��d�ep�ZqGd��d�ep�ZrGd��d�ej��ZsGd��d�es�ZtGd��d�es�Zuej�ej�d�k(d��Gd��d�ej���ZxGd��d�ex�ZyGd��d�ex�Zzd��Z{e|d�k(rej��yy#e+$rd�Z(Y���wxYw)��N)�deque�UserList)�cycle�count)�support)�assert_python_ok�assert_python_failure�run_python_until_end)�
import_helper)�	os_helper)�threading_helper)�warnings_helper)�skip_if_sanitizer)�FakePathc��	t|i|��}t�}tj|t	|��|t|�j
d�dd|S)N�B)�bytes�EmptyStruct�ctypes�resize�len�
memoryview�cast)�pos�kw�data�objs    �)/usr/local/lib/python3.12/test/test_io.py�	bytesliker;sK��M��c� �R� ���m���
�
�c�3�t�9�%�'+�
�3����S�!�!�$��
�c��eZdZy)rN��__name__�
__module__�__qualname__�r rrrBs��r rc�@�tjdt|i|���S)N�b)�arrayr)rrs  rrr8s���{�{�3��s� 1�b� 1�2�2r c�l�	ttdd��5}|jcddd�S#1swYyxYw)N�r�latin-1��encoding)�open�__file__�_CHUNK_SIZE)�fs r�_default_chunk_sizer3Js&��2�	
�h��i�	0�A��}�}�
1�	0�	0�s�*�3�alarmztest requires signal.alarm()c��eZdZd�Zy)�BadIndexc��ddzy�N�rr&��selfs r�	__index__zBadIndex.__index__U�	��	�!�r N)r#r$r%r<r&r rr6r6Ts��r r6c�N�eZdZ	dd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
d�Zy
)�MockRawIOWithoutReadc�N�t|�|_g|_d|_d|_y�Nr)�list�_read_stack�_write_stack�_reads�_extraneous_reads)r;�
read_stacks  r�__init__zMockRawIOWithoutRead.__init__\s&���
�+���������!"��r c�`�|jjt|��t|�S�N)rD�appendrr�r;r(s  r�writezMockRawIOWithoutRead.writebs#����� � ��q��*��1�v�
r c��y�NTr&r:s r�writablezMockRawIOWithoutRead.writablef���r c��y�N�*r&r:s r�filenozMockRawIOWithoutRead.filenois��r c��yrOr&r:s r�readablezMockRawIOWithoutRead.readablelrQr c��yrOr&r:s r�seekablezMockRawIOWithoutRead.seekableorQr c��yrAr&�r;r�whences   r�seekzMockRawIOWithoutRead.seekr���r c��yrAr&r:s r�tellzMockRawIOWithoutRead.tellur^r c�\�|xjdz
c_t|�}	|jd}|�|jd=yt|�}t|�|kr|jd=||d||S|d||dd||d|jd<|S#t$r|xjdz
c_YywxYwr8)rErrC�
IndexErrorrF)r;�buf�max_lenr�ns     r�readintozMockRawIOWithoutRead.readintoxs������q����c�(��	��#�#�A�&�D��<�� � ��#����I���t�9���� � ��#��C���G��H��(�7�^�C��F�"&�w�x�.�D���Q���N���	��"�"�a�'�"��	�s�B
�
B+�*B+Nc��|SrJr&)r;rs  r�truncatezMockRawIOWithoutRead.truncate�s���
r )r&rJ)
r#r$r%rHrMrPrUrWrYr]r`rfrhr&r rr?r?Xs9��,�#���������*r r?c��eZdZy)�CMockRawIOWithoutReadNr"r&r rrjrj����r rjc��eZdZy)�PyMockRawIOWithoutReadNr"r&r rrmrm�rkr rmc��eZdZdd�Zy)�	MockRawIONc��|xjdz
c_	|jjd�S#|xjdz
c_YyxYw)Nr9rr )rErC�poprF�r;res  r�readzMockRawIO.read�sG�����q���	��#�#�'�'��*�*��	��"�"�a�'�"��s	�2�ArJ�r#r$r%rsr&r rroro�s��r roc��eZdZy)�
CMockRawIONr"r&r rrvrv�rkr rvc��eZdZy)�PyMockRawIONr"r&r rrxrx�rkr rxc�@��eZdZ�fd�Zd�fd�	Zd�Zd�Z�fd�Z�xZS)�MisbehavedRawIOc�(��t�|�|�dzS�N�)�superrM)r;r(�	__class__s  �rrMzMisbehavedRawIO.write�s����w�}�Q��!�#�#r c�(��t�|�|�dzSr|)r~rs)r;rers  �rrszMisbehavedRawIO.read�s����w�|�A���"�"r c��y)Ni����r&r[s   rr]zMisbehavedRawIO.seek�rQr c��y)Ni8���r&r:s rr`zMisbehavedRawIO.tell�rQr c�>��t�|�|�t|�dzS�N�)r~rfr)r;rcrs  �rrfzMisbehavedRawIO.readinto�s���
������3�x�!�|�r rJ)	r#r$r%rMrsr]r`rf�
__classcell__�rs@rrzrz�s!���$�#����r rzc��eZdZy)�CMisbehavedRawIONr"r&r rr�r��rkr r�c��eZdZy)�PyMisbehavedRawIONr"r&r rr�r��rkr r�c�$��eZdZ�fd�Zd�Z�xZS)�SlowFlushRawIOc�T��t�|��tj�|_yrJ)r~rH�	threading�Event�in_flush)r;rs �rrHzSlowFlushRawIO.__init__�s���
����!���)��
r c�b�|jj�tjd�y)Ng�?)r��set�time�sleepr:s r�flushzSlowFlushRawIO.flush�s���
�
�����
�
�4�r )r#r$r%rHr�r�r�s@rr�r��s
���*�r r�c��eZdZy)�CSlowFlushRawIONr"r&r rr�r��rkr r�c��eZdZy)�PySlowFlushRawIONr"r&r rr�r��rkr r�c��eZdZdZd�Zy)�CloseFailureIOrc�6�|js
d|_t�y�Nr9��closed�OSErrorr:s r�closezCloseFailureIO.close�s���{�{��D�K��M�r N)r#r$r%r�r�r&r rr�r��s��
�F�r r�c��eZdZy)�CCloseFailureIONr"r&r rr�r��rkr r�c��eZdZy)�PyCloseFailureIONr"r&r rr�r��rkr r�c�4��eZdZ�fd�Zd�fd�	Z�fd�Z�xZS)�
MockFileIOc�2��g|_t�|�	|�yrJ)�read_historyr~rH�r;rrs  �rrHzMockFileIO.__init__�s������
����r c���t�|�|�}|jj|�d�|St	|��|SrJ)r~rsr�rKr)r;re�resrs   �rrszMockFileIO.read�s>����g�l�1�o����� � ����C��
�;>�c�(�C��
r c�\��t�|�|�}|jj|�|SrJ)r~rfr�rK)r;r(r�rs   �rrfzMockFileIO.readinto�s+����g��q�!����� � ��%��
r rJ)r#r$r%rHrsrfr�r�s@rr�r��s�����
�r r�c��eZdZy)�CMockFileIONr"r&r rr�r��rkr r�c��eZdZy)�PyMockFileIONr"r&r rr�r��rkr r�c�$�eZdZd�Zd�Zd�Zd�Zy)�MockUnseekableIOc��y�NFr&r:s rrYzMockUnseekableIO.seekable�s��r c�$�|jd���Nznot seekable��UnsupportedOperation�r;�argss  rr]zMockUnseekableIO.seek�����'�'��7�7r c�$�|jd��r�r�r�s  rr`zMockUnseekableIO.tell�r�r c�$�|jd��r�r�r�s  rrhzMockUnseekableIO.truncater�r N)r#r$r%rYr]r`rhr&r rr�r��s���8�8�8r r�c�$�eZdZejZy)�CMockUnseekableION)r#r$r%�ior�r&r rr�r�s���2�2�r r�c�$�eZdZejZy)�PyMockUnseekableION)r#r$r%�pyior�r&r rr�r�s���4�4�r r�c�*��eZdZ�fd�Zd�Zd�Z�xZS)�MockCharPseudoDevFileIOc�$��t�|�|�yrJ)r~rHr�s  �rrHz MockCharPseudoDevFileIO.__init__s���
����r c��yrAr&r�s  rr]zMockCharPseudoDevFileIO.seekr^r c��yrAr&r�s  rr`zMockCharPseudoDevFileIO.tellr^r )r#r$r%rHr]r`r�r�s@rr�r�
s���
��r r�c��eZdZy)�CMockCharPseudoDevFileIONr"r&r rr�r�rkr r�c��eZdZy)�PyMockCharPseudoDevFileIONr"r&r rr�r�rkr r�c�>�eZdZd�Zd�Zd�Zd�Zd�Zd
d�Zd�Z	d�Z
y	)�MockNonBlockWriterIOc� �g|_d|_yrJ)rD�
_blocker_charr:s rrHzMockNonBlockWriterIO.__init__!s�����!��r c�Z�dj|j�}g|jdd|S�Nr )�joinrD)r;�ss  r�pop_writtenz MockNonBlockWriterIO.pop_written%s+���H�H�T�&�&�'��!����!���r c��	||_yrJ)r�)r;�chars  r�block_onzMockNonBlockWriterIO.block_on*s
��5�!��r c��yrOr&r:s rrWzMockNonBlockWriterIO.readable.rQr c��yrOr&r:s rrYzMockNonBlockWriterIO.seekable1rQr c��yrAr&r[s   rr]zMockNonBlockWriterIO.seek4s��r c��yrOr&r:s rrPzMockNonBlockWriterIO.writable8rQr c�0�t|�}d}|jrI	|j|j�}|dkDr |jj	|d|�|Sd|_y|jj	|�t
|�S#t
$rY�1wxYw)N���r)rr��indexrDrK�
ValueErrorr)r;r(res   rrMzMockNonBlockWriterIO.write;s����!�H�������
 ��G�G�D�.�.�/���q�5��%�%�,�,�Q�r��U�3��H�*.�D�&����� � ��#��1�v�
���
��
�s�B	�		B�BN�r)r#r$r%rHr�r�rWrYr]rPrMr&r rr�r�s*��"��
"�����r r�c�$�eZdZejZy)�CMockNonBlockWriterION)r#r$r%r��BlockingIOErrorr&r rr�r�Os
���(�(�Or r�c�$�eZdZejZy)�PyMockNonBlockWriterION)r#r$r%r�r�r&r rr�r�Rs
���*�*�Or r�c��eZdZd�Zd�Zd�Zd6d�ZdZd�Zd�Z	e
jejd�e
jeed	�d
�d���Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d �Z&d!�Z'd"�Z(d#�Z)d$�Z*d%�Z+d&�Z,d'�Z-d(�Z.d)�Z/d*�Z0d+�Z1d,�Z2d-�Z3d.�Z4d/�Z5d0�Z6d1�Z7d2�Z8d3�Z9d4�Z:y5)7�IOTestc�J�tjtj�yrJ�r�unlink�TESTFNr:s r�setUpzIOTest.setUpX�������)�)�*r c�J�tjtj�yrJr�r:s r�tearDownzIOTest.tearDown[r�r c��|j|jd�d�|jd�|j|j�d�|j	d�|j|jd�d�|j|j	d�d�|j|jd�d�|j|j�d�|j|j	dd�d�|j|j�d�td�}|j|j|�d	�d
|dd|j|j	d�d�|j|jd�d�|j|j	dd�d
�|j|j�d
�|j|jd�d�|j|j�d
�|j
t|jd�y)Nsblah.r�rsHello.�r�r9s	 world


�	s	*********�hr}�
��)�assertEqualrMrhr`r]�	bytearray�assertRaises�	TypeError)r;r2�buffers   r�	write_opszIOTest.write_ops^s����������*�A�.�	�
�
�1�
��������1�%�	���q�	��������*�A�.���������A�&��������+�Q�/��������1�%��������A���*��������1�%��?�+����������!�,���q�	���������A�&����������*��������A���+��������2�&�������B���,��������2�&����)�Q�V�V�S�1r c��|jd�}|j|d�t|�}|j|j|�d�|jt	|�d�td�}|j|j|�d�|jt
|�d�|j|ddd�|j|jd�d�|j|jd�d�|j|jd	�d
�|j|jtd��d�|j|jdd�d
�|j|jd�d�|j|jd�d
�|j|jt��d�|j|jdd	�d�|j|jd�d�|j|j�d�|jt|jd�|r�|jd�|j|j�d�|jd
�|j|j�d�|j|j�d
�|jd�td�}|j|j|�d�|jt	|�d�yy)Nr�shellos worlr}�d
r��hello world
r9r �xi����r�sworld�
r�sworld
)rsr�rrfrr�rr]r`r�r��	readinto1)r;r2�bufferedrs    r�read_opszIOTest.read_opsvsl���v�v�a�y������x�(�����������D�)�1�-�����t��h�/���|��������D�)�1�-�����T��A�&�����b�q��6�*���������A�&���������%5�6���������C�(�������I�d�O�4�a�8��������A���*���������H�-���������C�(�������I�K�0�!�4��������A���*���������H�-��������2�&����)�Q�V�V�S�1��
�F�F�1�I����Q�V�V�X�'7�8�
�F�F�1�I����Q�V�V�X�z�2����Q�V�V�X�s�+�
�F�F�1�I��Q�<�D����Q�[�[��.��2����U�4�[�(�3�r lc���	|j|j|j�|j�|j|j
�|j�|j|jd�d�|j|j
�|jdz�|j|jdd�|jdz�|j|j�|jdz�|j|j
�|jdz�|j|jdd�|jdz�|j|j|jdz�|jdz�|j|j
�|jdz�|j|jdd�|jdz�|j|jdd�|j�|j|jd�d�y#ttf$r|jd�Y��8wxYw)	Nzno largefile support�xxx�r�r9r}rr)
r�r]�LARGE�
OverflowErrorr��skipTestr`rMrhrs�r;r2s  r�large_file_opszIOTest.large_file_ops�s���	2����Q�V�V�D�J�J�/����<�	
�������4�:�:�.���������!�,��������4�:�:��>�2��������A���
�
�Q��7��������t�z�z�A�~�6��������4�:�:��>�2��������1��t�z�z�A�~�6�������D�J�J��N�3�T�Z�Z�!�^�D��������4�:�:��>�2��������1��t�z�z�A�~�6��������A���
�
�3���������D�)���z�*�	2��M�M�0�1�	2�s�5I� I0�/I0c��|j}|jtjdd��5}|j	||j
�|j	||j�ddd�|jtjd�5}|j	||j
�|j	||j�ddd�|jtjdd��5}|j	||j
�|j	||j�ddd�|jtjdd��5}|j	||jd�|j	||jd	g�ddd�|jtjd�5}|j	||jd�|j	||jd	g�ddd�|jtjd
d��5}|j	||jd�|j	||jdg�|j	||jd
|j�|j	||jd|j�ddd�y#1swY��OxYw#1swY���xYw#1swY���xYw#1swY��LxYw#1swY��xYw#1swYyxYw)N�w�utf-8r-�wbr��	buffering�rbsblahsblah
r+�blahzblah
r9r�)r�r/rr�r�rs�readlinerM�
writelinesr]�SEEK_CUR�SEEK_END)r;�exc�fps   r�test_invalid_operationszIOTest.test_invalid_operations�s@���'�'��
�Y�Y�y�'�'��w�Y�
?�2����c�2�7�7�+����c�2�;�;�/�@��Y�Y�y�'�'��
.�"����c�2�7�7�+����c�2�;�;�/�/��Y�Y�y�'�'���Y�
;�r����c�2�7�7�+����c�2�;�;�/�<��Y�Y�y�'�'���Y�
;�r����c�2�8�8�W�5����c�2�=�=�9�+�>�<��Y�Y�y�'�'��
.�"����c�2�8�8�W�5����c�2�=�=�9�+�>�/��Y�Y�y�'�'��w�Y�
?�2����c�2�8�8�V�4����c�2�=�=�8�*�=����c�2�7�7�A�t�}�}�=����c�2�7�7�B��
�
�>�@�
?�@�
?��/�
.��<�
;��<�
;��/�
.��@�
?�sH�9J5�9K�39K�<K�:<K)� BK5�5J?�K�K�K&�)K2�5K>�%fstat() of a pipe fd is not supported�pipe�requires os.pipe()c�x���fd�}�fd�}�fd�}�fd�}�fd�}�fd�}�fd�}�fd�}|d	f|d
f|df|df|d
f|df|df|df�jd
f�jd
ff
}	|	D�]�\}
}�j|
�5|
�5}d|v}
�j|j	�|
�d|v}�j|j�|�t
|�j�rd}n6t
|�j�jf�rd}n�jd�d|vr|j�n �jt|j�|
r"|jd�|j�nA�jt|jd��jt|j�|r|j�n!�jt|j�t j"j%d�r|
||fvr	ddd�ddd����d|v}�j|j'�|�|r"|j)�|j+d�nA�jt|j(��jt|j*d�|r$|r"|j-�|j-d�nA�jt|j,��jt|j,d�ddd�ddd����y#1swY�xYw#1swY���xYw)Nc���tj�\}}tj|��j|d�S)Nr+)�osr!r��FileIO)r+rr;s  �r�pipe_readerz3IOTest.test_optional_abilities.<locals>.pipe_reader�s.����W�W�Y�F�Q���H�H�Q�K��;�;�q�#�&�&r c�:��tj�\}}�jtj|�t	j
tj|df��}|j��j|j��j|d�S)N�d��targetr�r)
r%r!�
addCleanupr�r��Threadrs�startr�r&)r+r�threadr;s   �r�pipe_writerz3IOTest.test_optional_abilities.<locals>.pipe_writer�sh����W�W�Y�F�Q���O�O�B�H�H�a�(��%�%�R�W�W�A�s�8�D�F��L�L�N��O�O�F�K�K�(��;�;�q�#�&�&r c�B���j�j��SrJ)�BufferedReaderr�r:s�r�buffered_readerz7IOTest.test_optional_abilities.<locals>.buffered_reader������&�&�t�'<�'<�'>�?�?r c�B���j�j��SrJ)�BufferedWriterr�r:s�r�buffered_writerz7IOTest.test_optional_abilities.<locals>.buffered_writer�r4r c�B���j�j��SrJ)�BufferedRandom�BytesIOr:s�r�buffered_randomz7IOTest.test_optional_abilities.<locals>.buffered_random�s����&�&�t�|�|�~�6�6r c�`���j�j��j��SrJ)�BufferedRWPairr�r:s�r�buffered_rw_pairz8IOTest.test_optional_abilities.<locals>.buffered_rw_pair�s-����&�&�t�'<�'<�'>��%�%�'�)�
)r c�`��G�fd�d�j�}�j|�d�S)Nc�j��eZdZW�jjZW�jj
Zy)�MIOTest.test_optional_abilities.<locals>.text_reader.<locals>.UnseekableReaderN)r#r$r%�BufferedIOBaserPrMr:s�r�UnseekableReaderrA�s%����.�.�7�7���+�+�1�1�r rC�ascii�r��
TextIOWrapper)rCr;s �r�text_readerz3IOTest.test_optional_abilities.<locals>.text_reader�s.���
2�4�#8�#8�
2��%�%�&6�&8�'�B�Br c�`��G�fd�d�j�}�j|�d�S)Nc�j��eZdZW�jjZW�jj
Zy)�MIOTest.test_optional_abilities.<locals>.text_writer.<locals>.UnseekableWriterN)r#r$r%rBrWrsr:s�r�UnseekableWriterrJ�s%����.�.�7�7���*�*�/�/�r rKrDrE)rKr;s �r�text_writerz3IOTest.test_optional_abilities.<locals>.text_writer�s.���
0�4�#8�#8�
0��%�%�&6�&8�'�B�Br �fr�fwr+r�rws�rw�3�3zUnknown base classr2r9�winr�r)r:�StringIO�subTestr�rWrP�
isinstance�
TextIOBaserB�	RawIOBase�failrUr�r�rsrM�sys�platform�
startswithrYr`r]rh)r;r'r0r3r7r;r>rGrL�tests�test�	abilitiesrrWrPrrYs`                r�test_optional_abilitieszIOTest.test_optional_abilities�s����	'�
	'�	@�	@�	7�	)�	C�	C��$��+�t�!4�
�c�"�_�c�$:�
�e�$�'7��&>�
�#���c� 2�
�\�\�5�!�D�M�M�5�#9�
��"'��T�9����d�#�T�V�s��)�+��� � ������:��)�+��� � ������:��c�4�?�?�3��D���d�&9�&9�4�>�>�%J�K��D��I�I�2�3��)�#��J�J�L��%�%�g�s�z�z�:���H�H�Q�K��H�H�J��%�%�g�s�x�x��;��%�%�g�s�x�x�8���I�I�d�O��%�%�g�s�y�y�$�?��<�<�*�*�5�1�d�#�[�?2�72��C&,�#�#�D�)�+��� � ������:���H�H�J��H�H�Q�K��%�%�g�s�x�x�8��%�%�g�s�x�x��;����L�L�N��L�L��O��%�%�g�s�|�|�<��%�%�g�s�|�|�Q�?�c&,�#�#�"'�%+�V��#�#�s2�8L/�F
L#�
L/�C0L#�L/�#L,�(L/�/L9	c�6�d}|jt|j|dd��t|d�}t	j
�5t	jdt�|jt|j|dd��ddd�y#1swYyxYw)Nzfoobarrrr-rD�ignore)r�r�r/r�warnings�catch_warnings�simplefilter�DeprecationWarning)r;�fn_with_NUL�bytes_fns   r�test_open_handles_NUL_charsz"IOTest.test_open_handles_NUL_chars2sv�� �����*�d�i�i��c�G��T���g�.��
�
$�
$�
&��!�!�(�,>�?����j�$�)�)�X�s�W��U�'�
&�
&�s�?B�Bc��|jtjdd��5}|j|j	�d�|j|j�d�|j|j
�d�|j|�ddd�|jtjdd��5}|j|j	�d�|j|j�d�|j|j
�d�|j|�ddd�y#1swY��xYw#1swYyxYw)NrrrFTr�	r/rr�r�rWrPrYr�rrs  r�test_raw_file_iozIOTest.test_raw_file_io;s���
�Y�Y�y�'�'���Y�
;�q����Q�Z�Z�\�5�1����Q�Z�Z�\�4�0����Q�Z�Z�\�4�0��N�N�1��	<�
�Y�Y�y�'�'���Y�
;�q����Q�Z�Z�\�4�0����Q�Z�Z�\�5�1����Q�Z�Z�\�4�0��M�M�!��	<�
;�<�
;��
<�
;�s�A2D:�?A2E�:E�Ec��|jtjd�5}|j|j	�d�|j|j�d�|j|j
�d�|j|�ddd�|jtjd�5}|j|j	�d�|j|j�d�|j|j
�d�|j|d�ddd�y#1swY��xYw#1swYyxYw)NrFTrrkrs  r�test_buffered_file_iozIOTest.test_buffered_file_ioGs���
�Y�Y�y�'�'��
.�!����Q�Z�Z�\�5�1����Q�Z�Z�\�4�0����Q�Z�Z�\�4�0��N�N�1��	/�
�Y�Y�y�'�'��
.�!����Q�Z�Z�\�4�0����Q�Z�Z�\�5�1����Q�Z�Z�\�4�0��M�M�!�T�"�	/�
.�/�
.��
/�
.�s�A2D7�;A3E�7E�Ec�v�|jtjd�5}|jd�ddd�|jtjd�5}|j	|j�d�|j	|jd�d�|j	|jd�d�|j	|jd	�d
�|j	|j�d�|j	|jd�d�|j
t|j
d
�ddd�|jtjdd��5}|j
t|j
d
�ddd�y#1swY��exYw#1swY�cxYw#1swYyxYw)Nrs"abc
def
xyzzy
foobar
another liner�abc
r�def
r}�xy�szzy
sfoobar
sanother lineg333333@r+rr-)r/rr�rMr�rr�r�rs  r�
test_readlinezIOTest.test_readlineSs=��
�Y�Y�y�'�'��
.�!�
�G�G�@�A�/�
�Y�Y�y�'�'��
.�!����Q�Z�Z�\�8�4����Q�Z�Z��^�X�6����Q�Z�Z��]�E�2����Q�Z�Z��]�H�5����Q�Z�Z�\�?�;����Q�Z�Z��-��?����i����S�9�/��Y�Y�y�'�'��w�Y�
?�1����i����S�9�@�
?�/�
.��
.�
.��@�
?�s$�F�C&F#�+"F/�F �#F,�/F8c�z�Gd�d|j�}|jttft|��y)Nc��eZdZd�Zy)�+IOTest.test_readline_nonsizeable.<locals>.Rc��yrJr&r:s rrz4IOTest.test_readline_nonsizeable.<locals>.R.readlinee���r N)r#r$r%rr&r r�Rrwd���
r rz)�IOBaser�r��
StopIteration�next�r;rzs  r�test_readline_nonsizeablez IOTest.test_readline_nonsizeableas-��	����	�	
���9�m�4�d�A�C�@r c�z�Gd�d|j�}|jt|�jd�y)Nc��eZdZd�Zy)�'IOTest.test_next_nonsizeable.<locals>.Rc��yrJr&r:s r�__next__z0IOTest.test_next_nonsizeable.<locals>.R.__next__mryr N)r#r$r%r�r&r rrzr�lr{r rzr9)r|r�r��	readlinesrs  r�test_next_nonsizeablezIOTest.test_next_nonsizeableis,��	����	�	
���)�Q�S�]�]�A�6r c���|j�}|j|�|j�}|j|d�|j|�}|j	|d�y)NrT)r:r��getvaluer�r)r;r2rs   r�test_raw_bytes_iozIOTest.test_raw_bytes_ioqsQ���L�L�N�����q���z�z�|������/�0��L�L�����
�
�a��r c��tjdddk(stjdk(r#tjdd|jz�|jtjdd�5}|j|�ddd�|jtjd�5}|j|�ddd�y#1swY�DxYw#1swYyxYw)NrrS�darwin�	largefilez-test requires %s bytes and a long time to run�w+br)	rZr[r�requiresrr/rr�rrs  r�test_large_file_opszIOTest.test_large_file_opsys����<�<����u�$�����(@�����?�$�*�*�L�
N��Y�Y�y�'�'���
2�a�����"�3�
�Y�Y�y�'�'��
/�1�����"�0�
/�3�
2��
/�
/�s�.C�(C�C�Cc���dD]�}|jtjd|�5}|jd�ddd�|j	j
d�	|jtjd|�5}ddzddd�|j
d���y#1swY�ixYw#1swY�)xYw#t$r|j	|j
d�Y��wxYw)N)rr)rr
Tr9rz1/0 didn't raise an exception)r/rr�rMr�r�rY�ZeroDivisionError)r;�bufsizer2s   r�test_with_openzIOTest.test_with_open�s����G����9�+�+�T�7�;�q������<����Q�X�X�t�,�
;��Y�Y�y�/�/��w�?�1��a�C�@�
�	�	�9�:� �;�;��@�?��$�
1�� � ����4�0�
1�s5�B!�!B9�?B-�B9�!B*	�-B6	�2B9�9%C!� C!c��|jtjd�5}|jd�ddd�|jtjdd��5}|j	|j�d�ddd�|jtjd�5}|j	|j�d�ddd�|jtjdd�	�5}|j
|j�d�ddd�y#1swY��xYw#1swY��xYw#1swY�mxYw#1swYyxYw)
Nrr
�abrrr�arr-)r/rr�rMr�r`�
assertGreaterrs  r�test_append_mode_tellzIOTest.test_append_mode_tell�s���
�Y�Y�y�'�'��
.�!�
�G�G�F�O�/�
�Y�Y�y�'�'���Y�
;�q����Q�V�V�X�q�)�<�
�Y�Y�y�'�'��
.�!����Q�V�V�X�q�)�/�
�Y�Y�y�'�'��w�Y�
?�1����q�v�v�x��+�@�
?�
/�
.��
;�
;��
.�
.��
?�
?�s/�D�!D'�&!D3�1!D?�D$�'D0�3D<�?Ec����g�G�fd�d|j�}tjdtf�5|tj
d�}|j
d�~tj�|j�gd��|jtj
d�5}|j|j�d�ddd�ddd�y#1swY�xYw#1swYyxYw)Nc�:���eZdZ��fd�Z��fd�Z��fd�Z�xZS)�(IOTest.test_destructor.<locals>.MyFileIOc�j���jd�	t�|�}|�y#t$rYywxYwr��rKr~�__del__�AttributeError�r;r2r�records  ��rr�z0IOTest.test_destructor.<locals>.MyFileIO.__del__��8����
�
�a� �����A��C��&������
&�	2�2c�D���jd�t�|�	�yr|�rKr~r��r;rr�s ��rr�z.IOTest.test_destructor.<locals>.MyFileIO.close������
�
�a� ���
�r c�D���jd�t�|�	�y�Nr�rKr~r�r�s ��rr�z.IOTest.test_destructor.<locals>.MyFileIO.flush�r�r �r#r$r%r�r�r�r��rr�s@�r�MyFileIOr������
�
 �
 �
 r r��rr
�r9r}rr)r&r�check_warnings�ResourceWarningrr�rMr�
gc_collectr�r/rs)r;r�r2r�s   @r�test_destructorzIOTest.test_destructor�s������	 �t�{�{�	 ��
+�
+�R��,A�
B���)�)�4�0�A�
�G�G�F�O����� ����V�Y�/����9�+�+�T�2�a�� � �����6�2�3�
C�
B�3�2��
C�
B�s$�A2C&�(!C�	C&�C#	�C&�&C/c���g�G�fd�d|�}|�}~tj�|j�gd��y)Nc�@���eZdZd�Z��fd�Z��fd�Z��fd�Z�xZS)�+IOTest._check_base_destructor.<locals>.MyIOc�.�d|_d|_d|_y)Nr9r}r)�on_del�on_close�on_flushr:s rrHz4IOTest._check_base_destructor.<locals>.MyIO.__init__�s��
 ��� !��
� !��
r c�~���j|j�	t�|�}|�y#t$rYywxYwrJ)rKr�r~r�r�r�s  ��rr�z3IOTest._check_base_destructor.<locals>.MyIO.__del__�s<����
�
�d�k�k�*�����A��C��&����s�
0�	<�<c�X���j|j�t�|�
�yrJ)rKr�r~r�r�s ��rr�z1IOTest._check_base_destructor.<locals>.MyIO.close������
�
�d�m�m�,���
�r c�X���j|j�t�|�
�yrJ)rKr�r~r�r�s ��rr�z1IOTest._check_base_destructor.<locals>.MyIO.flush�r�r )r#r$r%rHr�r�r�r�r�s@�r�MyIOr��s���
"�
�
 �
 �
 r r�r�)rr�r�)r;�baser�r2r�s    @r�_check_base_destructorzIOTest._check_base_destructor�s<�����	 �4�	 �.
�F��
����������+r c�:�|j|j�yrJ)r�r|r:s r�test_IOBase_destructorzIOTest.test_IOBase_destructor�s���#�#�D�K�K�0r c�:�|j|j�yrJ)r�rXr:s r�test_RawIOBase_destructorz IOTest.test_RawIOBase_destructor�s���#�#�D�N�N�3r c�:�|j|j�yrJ)r�rBr:s r�test_BufferedIOBase_destructorz%IOTest.test_BufferedIOBase_destructor�s���#�#�D�$7�$7�8r c�:�|j|j�yrJ)r�rWr:s r�test_TextIOBase_destructorz!IOTest.test_TextIOBase_destructor�s���#�#�D�O�O�4r c�:�|jtjd�5}|jd�ddd�|jtjd�5}|j	|j�d�ddd�y#1swY�SxYw#1swYyxYw)Nrr
r�r/rr�rMr�rsrs  r�test_close_flusheszIOTest.test_close_flushes�sl��
�Y�Y�y�'�'��
.�!�
�G�G�F�O�/�
�Y�Y�y�'�'��
.�!����Q�V�V�X�v�.�/�
.�/�
.��
.�
.���B�!B�B�Bc�����tjdtd���t�j������fd�}|�j	��|�jtjd��|�j�j���|�j�j���|�j�j��j���y)N�irc���|5�j|j����|j�f�ddd�y#1swYyxYwrJ)r�rMr)r2r�rer;s ���r�checkz'IOTest.test_array_writes.<locals>.check�s6����� � ������Q�/����a�T�"����s�4A�A
r)r)�ranger�tobytesr:r&rr�r6ror9r=)r;r�r�res` @@r�test_array_writeszIOTest.test_array_writes�s�����K�K��U�2�Y�'����	�	����	#�	�d�l�l�n��
�d�k�k�)�*�*�C�0�1�
�d�!�!�$�.�.�"2�3�4�
�d�!�!�$�.�.�"2�3�4�
�d�!�!�$�.�.�"2�D�N�N�4D�E�Fr c�j�|jt|jtjddd��y)NrrF�r.�closefd�r�r�r/rr�r:s r�test_closefdzIOTest.test_closefd�s,�����*�d�i�i��1A�1A�3�#*�E�	�	;r c�t�|jtjdd��5}|jd�ddd�|jtjdd��5}|j|j	�ddd��}|j|j
�d�|jd�|j�|jt|j�ddd�|jtjd	�5}|j|j	�d	d�
�}|j|j
�ddd�|j�|jt|jtd
��ddd�y#1swY��bxYw#1swY��xYw#1swYyxYw)Nrrr-�egg
r+Fr�rr�r�rseggr9)
r/rr�rMrUr�rsr]r�r�r�rfr��r;r2�files   r�test_read_closedzIOTest.test_read_closed�s;��
�Y�Y�y�'�'��w�Y�
?�1�
�G�G�G��@�
�Y�Y�y�'�'��w�Y�
?�1��9�9�Q�X�X�Z��w��9�N�D����T�Y�Y�[�'�2��I�I�a�L��J�J�L����j�$�)�)�4�@��Y�Y�y�'�'��
.�!��9�9�Q�X�X�Z��u�9�=�D����T�Y�Y�[��!�_�f�5��J�J�L����j�$�-�-��1��F�	/�
.�@�
?��
?�
?��/�
.�s%�F�BF"�BF.�F�"F+�.F7c�j�|jt|jtjddd��y)Nr+rFr�r�r:s r�test_no_closefd_with_filenamez$IOTest.test_no_closefd_with_filenames,�����*�d�i�i��1A�1A�3�#*�E�	�	;r c��|jtjd�5}|jd�ddd�|jtjdd��5}|j	|j
jjd�|j|j�ddd��}|j	|j
jjd�ddd�y#1swY��xYw#1swYyxYw)	Nrsegg
r+rr-TFr�)	r/rr�rMr�r��rawr�rUr�s   r�test_closefd_attrzIOTest.test_closefd_attr
s���
�Y�Y�y�'�'��
.�!�
�G�G�H��/�
�Y�Y�y�'�'��w�Y�
?�1����Q�X�X�\�\�1�1�4�8��9�9�Q�X�X�Z��w��9�N�D����T�[�[�_�_�4�4�e�<�@�
?�/�
.��
?�
?�s�C*�BC6�*C3�6C?c��tjdtf�5|jtj
d�}|j
d�||_tj|�}~tj�ddd�|j�|�|jtj
d�5}|j|j�d�ddd�y#1swY�jxYw#1swYyxYw)Nr�rsabcxxxr)rr�r�r&rr�rMr2�weakref�refrr��assertIsNoner/r�rs)r;r2�wrs   r�test_garbage_collectionzIOTest.test_garbage_collections����
+�
+�R��,A�
B����I�,�,�d�3�A�
�G�G�I���A�C����Q��B����� �
C�	
���"�$��#�
�Y�Y�y�'�'��
.�!����Q�V�V�X�y�1�/�
.�C�
B��/�
.�s�A#C(�>!C4�(C1�4C=c���d}tjj|�s |jdj	|��t
jdkDr|jd�tjtjkr|jd�|j|dd��5}|jt|j�ddd�|j|d�5}|jt|j�ddd�|j|d	�5}|jt|j�ddd�y#1swY��xYw#1swY�QxYw#1swYyxYw)
Nz	/dev/zeroz{0} does not exist��z+test can only run in a 32-bit address spacez&test requires at least 2 GiB of memoryrrrr+)r%�path�existsr�formatrZ�maxsizer�real_max_memuse�_2Gr/r�r
rs)r;�zeror2s   r�test_unbounded_filezIOTest.test_unbounded_file#s�����w�w�~�~�d�#��M�M�.�5�5�d�;�<��;�;��#��M�M�G�H��"�"�W�[�[�0��M�M�B�C�
�Y�Y�t�T�Q�Y�
/�1����m�Q�V�V�4�0�
�Y�Y�t�T�
"�a����m�Q�V�V�4�#�
�Y�Y�t�S�
!�Q����m�Q�V�V�4�"�
!�	0�
/��
"�
"��
!�
!�s$�,!E�'!E�"!E$�E�E!�$E-c����|j|i|���g���fd�}|�_|jt�j�|j�j�|j��|j�d�d��_y)Nc�8���jg�ddt��rJr�)r�r2s��r�	bad_flushz4IOTest.check_flush_error_on_close.<locals>.bad_flush8s������
�F�1�I��)�Or rc��yrJr&r&r r�<lambda>z3IOTest.check_flush_error_on_close.<locals>.<lambda>@���$r )r/r�r�r�r��
assertTruer��assertFalse)r;r��kwargsr�r�r2s    @@r�check_flush_error_on_closez!IOTest.check_flush_error_on_close3sv���
�D�I�I�t�&�v�&����	�������'�1�7�7�+�������!������������#���r c�^�|jtjdd��tjtjtj
tjz�}|j|dd��tjtjtj
tjz�}|j|ddd��tj|�|jtjd�tjtjtj
tjz�}|j|d�tjtjtj
tjz�}|j|dd��tj|�|jtjdd�	�tjtjtj
tjz�}|j|dd�	�tjtjtj
tjz�}|j|ddd�
�tj|�y)NrrrF)rr�r�rrr-r�)rrr�r%r/�O_WRONLY�O_CREATr�)r;�fds  r�test_flush_error_on_closez IOTest.test_flush_error_on_closeBs���	
�'�'�	�(8�(8�$�!�'�L�
�W�W�Y�%�%�r�{�{�2�:�:�'=�
>���'�'��D�A�'�>�
�W�W�Y�%�%�r�{�{�2�:�:�'=�
>���'�'��D�A�u�'�M�
������'�'�	�(8�(8�$�?�
�W�W�Y�%�%�r�{�{�2�:�:�'=�
>���'�'��D�1�
�W�W�Y�%�%�r�{�{�2�:�:�'=�
>���'�'��D�%�'�@�
������'�'�	�(8�(8�#��'�P�
�W�W�Y�%�%�r�{�{�2�:�:�'=�
>���'�'��C�'�'�B�
�W�W�Y�%�%�r�{�{�2�:�:�'=�
>���'�'��C�'�5�'�Q�
����r c���|jtjdd��}|j�|j�|j�|j	t
|j�y)Nrrr)r/rr�r�r�r�r�rs  r�test_multi_closezIOTest.test_multi_closeZsK���I�I�i�&�&���I�:��	���	�	���	�	���	����*�a�g�g�.r c�6�|jd�}|j|jd�d�|j|jd�d�|j|jd�d�|j|jd�d�|j|jd�d�|j|jd�d�|j|jd�d�|j|jd�d�y)	N)�abc�dN�efgNr}�ab�cr
�ef�gr )r?r�rs�r;�rawios  r�test_RawIOBase_readzIOTest.test_RawIOBase_readas����)�)�*L�M��������A���.�������A���-�������A���-�������A���-�������A���.�������A���-�������A���-�������A���,r c���|j�|j�|j�|j�|j	�f}|D]}|jt
|d���y)N�__dict__)r|rXrWrTr:r��hasattr)r;r^rs   r�test_types_have_dictzIOTest.test_types_have_dictnsW���K�K�M��N�N���O�O���M�M�O��L�L�N�
���C��O�O�G�C��4�5�r c���|jtjdd��5}|jd�ddd�t	jtjtj
���fd�}|jddd|��5}|j
|j�d�ddd�y#1swY�xYw#1swYyxYw)	Nrrr-r�c����SrJr&)r��flagsrs  �r�openerz"IOTest.test_opener.<locals>.opener}s����Ir �non-existentr+)r.r)r/rr�rMr%�O_RDONLYr�rs)r;r2rrs   @r�test_openerzIOTest.test_openerys����
�Y�Y�y�'�'��w�Y�
?�1�
�G�G�G��@�
�W�W�Y�%�%�r�{�{�
3��	�
�Y�Y�~�s�W�V�Y�
L�PQ����Q�V�V�X�w�/�M�
L�@�
?��
M�
L�s�B4�
!C�4B=�C	c���d�}|jt�5}tdd|��ddd�|jt	j
�d�y#1swY�/xYw)Nc��y�Nr�r&��fnamers  r�	badopenerz4IOTest.test_bad_opener_negative_1.<locals>.badopener����r rr+�rzopener returned -1�r�r�r/r��str�	exception�r;r#�cms   r�test_bad_opener_negative_1z!IOTest.test_bad_opener_negative_1��K��	�
�
�
�z�
*�b����Y�7�+�����R�\�\�*�,@�A�+�
*���A�Ac���d�}|jt�5}tdd|��ddd�|jt	j
�d�y#1swY�/xYw)Nc��y)N���r&r!s  rr#z8IOTest.test_bad_opener_other_negative.<locals>.badopener�r$r rr+r%zopener returned -2r&r)s   r�test_bad_opener_other_negativez%IOTest.test_bad_opener_other_negative�r,r-c���tj��|jt�5}|j	d�fd���ddd�|jjjtj�y#1swY�>xYw)N�fooc����SrJr&)�namerrs  �rr�z/IOTest.test_opener_invalid_fd.<locals>.<lambda>�s���r r%)	r�make_bad_fdr�r�r/r�r(�errno�EBADF)r;r*rs  @r�test_opener_invalid_fdzIOTest.test_opener_invalid_fd�s`����
"�
"�
$��
�
�
�w�
'�2��I�I�e�$:�I�;�(�������+�+�U�[�[�9�(�
'�s�A?�?Bc��|jtd�5}|jtd�5}|j|j�d��}|j	|j�d��|j�|j
�|j�ddd�ddd�y#1swY�xYw#1swYyxYw)NrFr�)r/r0r&rUrHrr�)r;�f1�f2�fileios    r�test_fileio_closefdzIOTest.test_fileio_closefd�s���
�Y�Y�x��
&�"�
�Y�Y�x��
&�"��[�[�����e�[�<�F��O�O�B�I�I�K��O�7��K�K�M��L�L�N��K�K�M�'�'�
&�
&�
&��'�
&�s#�B>�A3B2�!B>�2B;	�7B>�>Cc���tj|�5|jt�5|j	t
jddd��ddd�ddd�y#1swY�xYw#1swYyxYw)Nrrr�r.r�r�check_no_resource_warningr�r�r/rr�r:s r�test_nonbuffered_textiozIOTest.test_nonbuffered_textio�sU��
�
6�
6�t�
<��"�"�:�.��	�	�)�*�*�C�'�Q�	�O�/�=�
<�.�.��=�
<��"�A-�$A!�A-�!A*	�&A-�-A6c���tj|�5|jt�5|j	t
jddd��ddd�ddd�y#1swY�xYw#1swYyxYw)Nrr�invalid�r.�newlinerAr:s r�test_invalid_newlinezIOTest.test_invalid_newline�sU��
�
6�
6�t�
<��"�"�:�.��	�	�)�*�*�C�'�9�	�U�/�=�
<�.�.��=�
<�rDc	�&�Gd�d|j�}|�}dD]d}|j|�5td�}|jt	||�|�d�|jt|�d�ddd��fy#1swY�qxYw)Nc��eZdZd�ZeZy)�3IOTest.test_buffered_readinto_mixin.<locals>.Streamc��y)N�12345r&�r;�sizes  rrsz8IOTest.test_buffered_readinto_mixin.<locals>.Stream.read�s��r N)r#r$r%rs�read1r&r r�StreamrL�s��
 ��Er rR�rfrr�rN)rBrUrr��getattrr)r;rR�stream�methodr�s     r�test_buffered_readinto_mixinz#IOTest.test_buffered_readinto_mixin�s~��	�T�(�(�	����/�F����f�%�"�1���� � �!8����!8��!@�!�D�� � ��v���9�&�%�0�%�%�s�A	B�B	c����fd�}|ttj��|ttjtj����jtjdd��5}t|j
��}�jt�5�j|dd��ddd�ddd�td�}�jt�5�j|dd��ddd�tt�}�jt�5�j|dd��ddd��jtd�5�jttj�dd��ddd�y#1swY��xYw#1swY��xYw#1swY��xYw#1swY�xxYw#1swYyxYw)Nc����j|dd��5}|jd�ddd��j|dd��5}�j|j�d�ddd�y#1swY�GxYw#1swYyxYw)Nrrr-r�r+)r/rMr�rs)r�r2r;s  �r�check_path_succeedsz7IOTest.test_fspath_support.<locals>.check_path_succeeds�sn������4��w��7�1����� �8����4��w��7�1�� � �����7�3�8�7�8�7��8�7�s�A.�!A:�.A7�:Brrr-zread/write/append mode�rwxa)rrr�r%�fsencoder/rUr�r��FloatingPointError�assertRaisesRegexr�)r;rZr2�bad_paths`   r�test_fspath_supportzIOTest.test_fspath_support�sY���	4�	�H�Y�%5�%5�6�7��H�R�[�[��1A�1A�%B�C�D�
�Y�Y�y�'�'��w�Y�
?�1�����
�+�H��"�"�9�-��	�	�(�C�'�	�:�.�@�
�D�>��
�
�
�y�
)��I�I�h��g�I�6�*��.�/��
�
�
�1�
2��I�I�h��g�I�6�3��
#�
#�J�0H�
I��I�I�h�y�/�/�0�&�7�I�K�J�
I�.�-��@�
?��*�
)��3�
2��J�
I�sH�:/F#�)F�>F#�.F/�/F;�",G�F 	�F#�#F,�/F8�;G�Gc���|jd�}|j|j�d�|jd�}|j|j�d�y�N�r	r
r�abcdefg)r?r�rs�readallrs  r�test_RawIOBase_readallzIOTest.test_RawIOBase_readall�sR���)�)�*@�A���������z�2��)�)�*@�A���������*�5r c	�6�Gd�d|j�}d}d}|D]�}|j|�5|\}}}}|tt|���}	t	|f|z�}
t|	|�}|j
||
�|�|j
t|
�|�|j|
d|t|��|f||z
z}|j|
|d|�|j
t|	j�||z
�ddd���y#1swY��xYw)Nc��eZdZd�Zd�Zd�Zy)�3IOTest.test_BufferedIOBase_readinto.<locals>.Readerc��||_yrJ��avail)r;rls  rrHz<IOTest.test_BufferedIOBase_readinto.<locals>.Reader.__init__�s	��"��
r c�L�|jd|}|j|d|_|SrJrk)r;rP�results   rrsz8IOTest.test_BufferedIOBase_readinto.<locals>.Reader.read�s)�����E�T�*��!�Z�Z���.��
��
r c�:�	|jt|d��Sr�)rs�minrOs  rrQz9IOTest.test_BufferedIOBase_readinto.<locals>.Reader.read1�s��:��y�y��T�1��.�.r N)r#r$r%rHrsrQr&r r�Readerri�s��
#�
�
/r rq)
)rfrr�r�)rfrr�r�)rfr�r�r�)rfr��r�)rfrrr)rrr�r�)rrr�r�)rr�r�r�)rr�rrr�)rrrr�)
rBrUrr�r�rTr�r�assertSequenceEqualrl)r;rqr]�UNUSED_BYTEr^rVrl�requestrn�readerr��unuseds            r�test_BufferedIOBase_readintoz#IOTest.test_BufferedIOBase_readinto�s��		/�T�(�(�		/�

�����D����d�#�15�.���w����e�E�l� 3�4��"�K�>�G�#;�<�� ���0��� � �����8�� � ��V��g�6��(�(�����%��-�H�%��7�V�+;�<���(�(�����&�A�� � ��V�\�\�!2�E�F�N�C�$�#��#�#�s�CD�D	c��Gd�d|j�}|�}|jt|j�d�|_y)Nc��eZdZd�Zd�Zy)�#IOTest.test_close_assert.<locals>.Rc��yrJr&)r;r5�values   r�__setattr__z/IOTest.test_close_assert.<locals>.R.__setattr__���r c��t��rJ�r�r:s rr�z)IOTest.test_close_assert.<locals>.R.flushs	���i�r N)r#r$r%rr�r&r rrzr|s��
�
 r rzc��yrJr&r:s rr�z*IOTest.test_close_assert.<locals>.<lambda>���tr )r|r�r�r�r�)r;rzr2s   r�test_close_assertzIOTest.test_close_assert
s8��	 ����	 �

�C�����'�1�7�7�+�$��r N�F);r#r$r%r�r�r�rrrr�unittest�skipIfr�
is_emscripten�
skipUnlessrr%r`rirlrnrtr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrr+r1r9r>rCrIrWr`rfryr�r&r rr�r�VsR��+�+�2�04�B
�E�*�(?�2�X�_�_����F���X�����V�,�.B�C�f@�D��f@�PV�
�
#�:�A�7��#�;�,�3�4,�<1�4�9�5�/�G�;�
G�;�
=�2�5� 
��0/�-�	6�0�B�B�:�
�P�
V�
:�L�86�'D�R$r r�c��eZdZd�Zy)�CIOTestc���Gd�d|j�}|�|�}||_tj|�}~~t	j
�|j
|�|�y)Nc��eZdZd�Zy)�*CIOTest.test_IOBase_finalize.<locals>.MyIOc��yrJr&r:s rr�z0CIOTest.test_IOBase_finalize.<locals>.MyIO.closer�r N�r#r$r%r�r&r rr�r�s��
r r�)r|rr�r�rr�r�)r;r�rr�s    r�test_IOBase_finalizezCIOTest.test_IOBase_finalizesY��	�4�;�;�	�
	
���f�����
�[�[��
�����������"�$��#r N)r#r$r%r�r&r rr�r�s��$r r�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�TestIOCTypesc���tjd�}|j|j|j|j
|j|j|j|j|j|j|j|j|j|jg|_t"j$dk(r%|j j'|j(�||_y)N�_io�win32)r�
import_moduler=r9r2r6r:r&�IncrementalNewlineDecoderrTrF�_BufferedIOBase�_BytesIOBuffer�_IOBase�
_RawIOBase�_TextIOBase�typesrZr[rK�_WindowsConsoleIOr��r;r�s  rr�zTestIOCTypes.setUp.s����)�)�%�0���������������K�K��J�J��)�)��L�L�����������K�K��N�N��O�O�
��
� �<�<�7�"��J�J���c�3�3�4���r c���|jD]C}|j|��5|jtd�5d|_ddd�ddd��Ey#1swY�xYw#1swY�\xYw)N)�tp�	immutable�bar)r�rUr^r�r3)r;r�s  r�test_immutable_typesz!TestIOCTypes.test_immutable_typesDsS���*�*�B������$��+�+�I�{�C�"�B�F�D�%�$��C�C��%�$�s"�A �A�A �A�A � A)	c�������fd�����fd���j}|j|j|j|j|j
|j|jh|j|jh|j|j|jhii}tjdk(r5||j|jj|j ��|�y)Nc���|D]9}�j||��5�jt||��ddd��;y#1swY�FxYw)N)r�r�)rUr��
issubclass)r�r�r�r;s   �r�
check_subsz5TestIOCTypes.test_class_hierarchy.<locals>.check_subsKs?������\�\�R�d�\�3��O�O�J�r�4�$8�9�4�3��3�3�s�A�A
	c���|j�D]I\}}t|t�r	�|��t|t�r
�||��9�j	d��Ky)Nzcorrupt test dataset)�itemsrV�dictr�rY)�d�k�vr��recursive_checkr;s   ���rr�z:TestIOCTypes.test_class_hierarchy.<locals>.recursive_checkPsJ������	���1��a��&�#�A�&���3�'��q�!�$��I�I�4�5�
"r r�)r�r�r�r=r9r2r6r:r�r&r�rTrFrZr[�addr�)r;r��	hierarchyr�r�s`  @@r�test_class_hierarchyz!TestIOCTypes.test_class_hierarchyJs����	:�
	6��h�h���K�K��#�#��&�&��&�&��&�&��&�&��K�K�&�����J�J�!�����L�L��%�%�"��
�	�$�<�<�7�"��c�k�k�"�3�>�>�2�6�6�s�7L�7L�M��	�"r c��|j}|jD�cic]}|d��}}d||j<|j�D]q\}}|j	||��5|j
�d�}|f}|rt
||i�}n.d}	|jt|	�5t
||i�}ddd�ddd��sycc}w#1swY�xYw#1swY��xYw)NTF)r��is_basetype�	_subclassznot an acceptable base type)	r�r�r�r�rUr#�typer^r�)
r;r�r��datasetr�r�r5�bases�_�msgs
          r�test_subclassingzTestIOCTypes.test_subclassingqs����h�h��$(�J�J�/�J�q�1�d�7�J��/�&+���"�"�#�&�}�}��O�B��������=��+�+��i�0�������T�5�"�-�A�7�C��/�/�	�3�?� ��u�b�1��@�>�=� /��0�@�?��>�=�s)�
B;�;C�C�(C�C	�C�C	c�\�|j}tj||j�yrJ)r�r�check_disallow_instantiationr�r�s  r�test_disallow_instantiationz(TestIOCTypes.test_disallow_instantiation�s!���h�h���,�,�T�3�3E�3E�Fr N)r#r$r%r�r�r�r�r�r&r rr�r�,s���,#�%#�N2� Gr r�c��eZdZy)�PyIOTestNr"r&r rr�r��rkr r�c��eZdZd�Zd�Zy)�APIMismatchTestc��	tjtjtjd��}|j|t
�d��y)N)�__weakref__)rbz6Python RawIOBase does not have all C RawIOBase methods�r�)r�detect_api_mismatchr�rXr�r�r��r;�mismatchs  r�test_RawIOBase_io_in_pyio_matchz/APIMismatchTest.test_RawIOBase_io_in_pyio_match�s=��H��.�.�t�~�~�r�|�|�6F�H������3�5�.f��gr c��	tjtjtj�}|j|t
�d��y)Nz6C RawIOBase does not have all Python RawIOBase methodsr�)rr�r�rXr�r�r�r�s  r�test_RawIOBase_pyio_in_io_matchz/APIMismatchTest.test_RawIOBase_pyio_in_io_match�s7��H��.�.�r�|�|�T�^�^�L������3�5�.f��gr N)r#r$r%r�r�r&r rr�r��s��h�hr r�c�`�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zy)�CommonBufferedTestsc���|j�}|j|�}|j|j�|�|j	t
|j�t
|�yrJ)ror��assertIs�detachr�r��repr�r;r�rcs   r�test_detachzCommonBufferedTests.test_detach�sJ���n�n����g�g�c�l���
�
�c�j�j�l�C�(����*�c�j�j�1��S�	r c��|j�}|j|�}|jd|j��yrS)ror�r�rU�r;r�bufios   r�test_filenozCommonBufferedTests.test_fileno�s1����� ������������U�\�\�^�,r c���|j�}|j|�}|jt|jdd�|jt|jdd�y)Nrr�r�)ror�r�r�r]r�s   r�test_invalid_argsz%CommonBufferedTests.test_invalid_args�sK����� �����������*�e�j�j�!�R�8����*�e�j�j�!�Q�7r c���|j}g�G�fd�d|�}|j�}||�}~tj�|j	�gd��y)Nc�:���eZdZ��fd�Z��fd�Z��fd�Z�xZS)�BCommonBufferedTests.test_override_destructor.<locals>.MyBufferedIOc�j���jd�	t�|�}|�y#t$rYywxYwr�r�r�s  ��rr�zJCommonBufferedTests.test_override_destructor.<locals>.MyBufferedIO.__del__�r�r�c�D���jd�t�|�	�yr|r�r�s ��rr�zHCommonBufferedTests.test_override_destructor.<locals>.MyBufferedIO.close�r�r c�D���jd�t�|�	�yr�r�r�s ��rr�zHCommonBufferedTests.test_override_destructor.<locals>.MyBufferedIO.flush�r�r r�r�s@�r�MyBufferedIOr��r�r r�r�)r�rorr�r�)r;r�r�rr�r�s     @r�test_override_destructorz,CommonBufferedTests.test_override_destructor�sT���
�W�W����	 �2�	 ���� ���U�#������������+r c���|j�}|j|���fd�}|�|jt|�y)Nc�6���5	ddd�y#1swYyxYwrJr&�r�s�r�_withz7CommonBufferedTests.test_context_manager.<locals>._with�s��������s��)ror�r�r�)r;rr�r�s   @r�test_context_managerz(CommonBufferedTests.test_context_manager�s:������ ��������	�	��	
���*�e�,r c��|j�}tj�5}|jt�5|j|�jddd�ts|j|j�n6|j�*|j|jjt�ddd�y#1swY�jxYw#1swYyxYwrJ)
r�r�catch_unraisable_exceptionr�r�r��xyzzy�IOBASE_EMITS_UNRAISABLEr��
unraisabler��exc_typer��r;rr*s   r�test_error_through_destructorz1CommonBufferedTests.test_error_through_destructor�s����#�#�%��
�
/�
/�
1�R��"�"�>�2������$�$�3�+��!�!�"�-�-�0����*�� � ����!7�!7��A�2�
1�2�2��2�
1�s#�C�C�A C�C		�C�Cc�v�|j�}|j|�}d|jj�d|jj��}|j	t|�d|z�d|_|j	t|�d|z�d|_|j	t|�d|z�y)N�(z\.)?z<%s>�dummyz<%s name='dummy'>�dummyz<%s name=b'dummy'>)ror�r$r%�assertRegexr�r5)r;r�r(�clsnames    r�	test_reprzCommonBufferedTests.test_repr�s����n�n����G�G�C�L��"&�'�'�"4�"4�d�g�g�6J�6J�K������a��&�7�"2�3��������a��"5��"?�@��������a��"6��"@�Ar c���|j�}|j|�}tj|d|�5	t	|�ddd�y#t
$rY�wxYw#1swYyxYw)Nr5)ror�r�	swap_attrr��RuntimeError�r;r�r(s   r�test_recursive_reprz'CommonBufferedTests.test_recursive_repr�s^���n�n����G�G�C�L��
�
�
�s�F�A�
.�
��Q��/�
.�� �
��
��/�
.�s(�A�A�	A�A�A�A�A'c�����|j��g����fd�}|�_|j���|jt�j
�|j
�j�|j
�j�|j
��|j�d�|j�d�d��_y)Nc�N���j�jg�ddt��rJr�)r(r�r�s���rr�z@CommonBufferedTests.test_flush_error_on_close.<locals>.bad_flush�s ������3�:�:�.�F�1�I��)�Or rr9c��yrJr&r&r rr�z?CommonBufferedTests.test_flush_error_on_close.<locals>.<lambda>���Dr )	ror�r�r�r�r�r�r�r�)r;r�r(r�r�s  @@@rrz-CommonBufferedTests.test_flush_error_on_close�s�����n�n�����	���	��G�G�C�L�����'�1�7�7�+�������!�����
�
�#������������#�������#� ��	r c�8�|j�}d�}d�}||_|j|�}||_|j	t
�5}|j�ddd�|j
jjd�|j|jjt
�|j
|jjjd�|j|j�d�|_d�|_y#1swY��xYw)Nc��td���Nr�r�r&r rr�z@CommonBufferedTests.test_close_error_on_close.<locals>.bad_flush	�
���'�"�"r c��td���Nr�r�r&r r�	bad_closez@CommonBufferedTests.test_close_error_on_close.<locals>.bad_closerr �r��r�c��yrJr&r&r rr�z?CommonBufferedTests.test_close_error_on_close.<locals>.<lambda>rr c��yrJr&r&r rr�z?CommonBufferedTests.test_close_error_on_close.<locals>.<lambda>r�r )
ror�r�r�r�r�r�r(r��assertIsInstance�__context__r�r��r;r�r�rr(�errs      r�test_close_error_on_closez-CommonBufferedTests.test_close_error_on_closes����n�n���	#�	#���	��G�G�C�L�����
�
�
�w�
'�3�
�G�G�I�(�������+�+�Z�8����c�m�m�7�7��A�������2�2�7�7��D�������"�!��	����(�
'�s�D�Dc�4�|j�}d�}d�}||_|j|�}||_|j	t
�5}|j�ddd�|j
dtj��|j|jjt
�|j
dt|jj��|j|j�d�|_d�|_y#1swY��xYw)Nc��t�rJ��non_existing_flushr&r rr�zNCommonBufferedTests.test_nonnormalized_close_error_on_close.<locals>.bad_flush���$�$r c��t�rJ��non_existing_closer&r rrzNCommonBufferedTests.test_nonnormalized_close_error_on_close.<locals>.bad_close rr rrc��yrJr&r&r rr�zMCommonBufferedTests.test_nonnormalized_close_error_on_close.<locals>.<lambda>-r�r c��yrJr&r&r rr�zMCommonBufferedTests.test_nonnormalized_close_error_on_close.<locals>.<lambda>.rr )
ror�r�r�r��	NameError�assertInr'r(rr
r�r�rs      r�'test_nonnormalized_close_error_on_closez;CommonBufferedTests.test_nonnormalized_close_error_on_closes����n�n���	%�	%���	��G�G�C�L�����
�
�
�y�
)�S�
�G�G�I�*��
�
�*�C��
�
�,>�?����c�m�m�7�7��C��
�
�*�C��
�
�0I�0I�,J�K�������"���� ��	�*�
)�s�D�Dc���|j�}|j|�}|j�|j�|j�|jt|j
�yrJ)ror�r�r�r�r�r�s   rrz$CommonBufferedTests.test_multi_close0sJ���n�n����G�G�C�L��	���	�	���	�	���	����*�a�g�g�.r c���|j|jd��}|j|j|j�|j|j|j
d�y)N�
AAAAAAAAAAr)r�r�r�r�r`r]�r;r�s  r�test_unseekablez#CommonBufferedTests.test_unseekable8sQ������-�-�i�8�9�����$�3�3�U�Z�Z�@����$�3�3�U�Z�Z��Cr c���|j�}|j|�}|j�}|jt�5||_ddd�y#1swYyxYwrJ)ror�r�r�r�)r;r�rc�xs    r�test_readonly_attributesz,CommonBufferedTests.test_readonly_attributes=sH���n�n����g�g�c�l���N�N���
�
�
�~�
.��C�G�/�
.�
.�s�A�A!N)r#r$r%r�r�r�r�r�r�r�r�rrrrr"r%r&r rr�r��sK���-�8�,�0
-�B�B��!�$�(!�*/�D�
r r�c�T�eZdZejd��Zejd��Zy)�
SizeofTestc��d}d}|j�}|j||��}tj|�|z
}|j�}|j||��}|j	tj|�||z�y)N�� ��buffer_size)ror�rZ�	getsizeofr�)r;�bufsize1�bufsize2rr�rPs      r�test_sizeofzSizeofTest.test_sizeofGsx��������� ������8��4���}�}�U�#�h�.����� ������8��4��������u�-�t�h��?r c���d}|j�}|j||��}tj|�|z
}|j	�|jtj|�|�y)Nr)r+)ror�rZr-r�r�)r;r�rr�rPs     r�test_buffer_freeingzSizeofTest.test_buffer_freeingRsZ������� ������7��3���}�}�U�#�g�-��
���
�������u�-�t�4r N)r#r$r%r�cpython_onlyr0r2r&r rr'r'Es6�����@��@�
���5��5r r'c���eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zej&�ej*d�d���Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�BufferedReaderTestrc�P�|jdg�}|j|�}|j|�|j|d��|j|d��|jd|j	��|jt|j|d��|jt|j|d��|jt|j|d��|jdg�}|j|�|jd|j	��y)Nr	�r+�r��r�)ror�rHr�rsr�r�r�s   r�test_constructorz#BufferedReaderTest.test_constructor^s�������x�(��������
���u��
���u�$��/�
���u�"��-���������.����*�e�n�n�e���K����*�e�n�n�e���M����*�e�n�n�e���L�����x�(��
���u����������.r c�j�|jj|j�}~|jj|j�}|jttfd|j
d�|j
|j��|j|jd�d�y�N�uninitialized|has no attributerr )	r��__new__r^r�r�rsrHror�r!s  r�test_uninitializedz%BufferedReaderTest.test_uninitializedls����������(�����������(�����
�N�;�?�$�z�z�1�	.�	���t�~�~�'�(�������A���,r c���dD]E}|jd�}|j|�}|jd|j|���G|j	t
jd�y)N)Nrrrcrdr0)ror�r�rsr�r�)r;�argrr�s    r�	test_readzBufferedReaderTest.test_readvsX���C��N�N�#9�:�E��G�G�E�N�E����Z����C��9��
	
���*�e�j�j�"�5r c�.�|jd�}|j|�}|jd|jd��|jd|j	d��|j|j
d�|jd|j	d��|jd|j	d��|j|j
d�|jd	|j	d��|j|j
d
�|jd|j	d��|j|j
d�|jd|j	d��|j|j
d
�y)Nrc�ar9�br rr
r)r
r}rrrs�ror�r�rsrQrEr�s   r�
test_read1zBufferedReaderTest.test_read1~s.�����5�6������������u�z�z�!�}�-�����u�{�{�1�~�.�������q�)�����e�k�k�!�n�-�����u�{�{�3�/�0�������q�)�����u�{�{�3�/�0�������q�)��������S�!1�2�������q�)�����e�k�k�#�.�/�������q�)r c��|jd�}|j|�}|jd|jd��|jd|j	��|jd|j	��|jd|j	d��|j|j
d�|jd	|j	��|j|j
d
�y)NrcrDr9sbcr
rr�rr rsrFr�s   r�test_read1_arbitraryz'BufferedReaderTest.test_read1_arbitrary�s������5�6������������u�z�z�!�}�-��������
�.�����u�{�{�}�-��������R��1�������q�)�����e�k�k�m�,�������q�)r c�l�|jd�}|j|�}td�}|j|j	|�d�|j|d�|j|j	|�d�|j|d�|j|j	|�d�|j|d�|j|j	|�d�|j|d�|j|j	|�d�|j|d�|jd	�}|j|�}|j|j	|�d�|j|d�|j|j	|�d�|j|d
�y)Nrcr}r�cdrr9sgfr)r	Nscb)ror�r�r�rf)r;rr�r(s    r�
test_readintoz BufferedReaderTest.test_readinto�sa�����5�6���������a�L���������*�A�.�����E�"��������*�A�.�����E�"��������*�A�.�����E�"��������*�A�.�����E�"��������*�A�.�����E�"����~�.���������������*�A�.�����E�"��������*�A�.�����E�"r c��d}|jd�}|j||��}td�}|j|j	d�d�|j|j
d�|j|j
|�d�|j|d�|j|j
d�|j|j
|�d�|j|ddd	�|j|j
d�|j|j
|�d�|j|d
�|j|j
d�td|z�}|j|j	d�d�|j|j
d�|j|j
|�d�|j|ddd
�|j|j
d�y)Nr)r	�de�fghsjklr+r}rr	r9rr
rNrOr�sfghjklrs)ror�r�r��peekrEr)r;r,rr�r(s     r�test_readinto1z!BufferedReaderTest.test_readinto1�s��������>�?������;��7���a�L��������A���/�������q�)��������+�Q�/�����E�"�������q�)��������+�Q�/�����2�A���%�������q�)��������+�Q�/�����E�"�������q�)��a��m�$��������A���/�������q�)��������+�Q�/�����2�A��	�*�������q�)r c	��d}d}|j|f�}|j||��}tjdd�}|j|�}|j	|t|��t
|�jd�}|j|t|��|j|d||d|�|j||ddt||d�z�y�N�<saaaaaaaaaaaaaaaaaaaaaaaaaar+r�s xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrr)
ror�r)rfr�rrr�
assertLessr��r;r,rrr�r(re�bms        r�test_readinto_arrayz&BufferedReaderTest.test_readinto_array�s�����������w�'������;��7��
�K�K��Y�'��

�N�N�1������1�c�!�f�%���]�
�
��
$������3�r�7�#�����B�Q���b�q��*�����A�B����R���V��!5�6r c	��d}d}|j|f�}|j||��}tjdd�}|j|�}|j	|t|��t
|�jd�}|j|t|��|j|d||d|�|j||ddt||d�z�yrS)
ror�r)rr�rrrrUr�rVs        r�test_readinto1_arrayz'BufferedReaderTest.test_readinto1_array�s�����������w�'������;��7��
�K�K��Y�'��

�O�O�A������1�c�!�f�%���]�
�
��
$������3�r�7�#�����B�Q���b�q��*�����A�B����R���V��!5�6r c����fd�}�j|�j�gd���j|�jd�ddg��j|�jd�gd��y)Nc�H���jd�}�j|�S)N�rprr)ror�)rr;s �rr�z0BufferedReaderTest.test_readlines.<locals>.bufio�s ����N�N�#<�=�E��7�7�5�>�!r r]r�rpr�r�r�r!s` r�test_readlinesz!BufferedReaderTest.test_readlines�sf���	"�	
�����*�*�,�.G�H������*�*�1�-��&�/A�B������*�*�4�0�2K�Lr c	�P�d}t|�}dgd�|dggdgd�|ggdgd�gd�gg}|D]{\}}}|j|�}|j||�	�}d}	|D].}
|j|j	|
�||	|	|
z�|	|
z
}	�0|j|j
|��}y)
N�	abcdefghir))rr9rs�r)rrrrs)r9r}rsr})rsrsr9r+)rr�r�r�rsr�)r;r�dlenr]r��buf_read_sizes�raw_read_sizesrr�r�nbytess           r�test_bufferingz!BufferedReaderTest.test_buffering�s������4�y���>�T�1�;�0��:�T�8�0��>�;�0�
��8=�3�G�^�^��O�O�D�)�E��G�G�E�w�G�7�E��C�(��� � ����F�!3�T�#�c�&�j�5I�J��v�
��)�
���U�/�/��@�8=r c�l�|jd�}|j|�}|jd|jd��|jd|jd��|jd|j��|jd|j	d��|j|j��|jd|j��|jd�}|jd	|j
��|j|j
��y)
N)r	r
NrNNN�abcdr��er9sfgr )rDNNrD)ror�r�rsrPr�rer�s   r�test_read_non_blockingz)BufferedReaderTest.test_read_non_blockings������M�N������������%�*�*�Q�-�0�����u�z�z�!�}�-������
�
��-�����e�j�j��m�,����%�*�*�,�'�����e�j�j�l�+����1�2������u�}�}��/����%�-�-�/�*r c��|jd�}|j|�}|jd|jd��y)Nrcrdi(#�ror�r�rsr�s   r�test_read_past_eofz%BufferedReaderTest.test_read_past_eofs7�����5�6������������U�Z�Z��%5�6r c��|jd�}|j|�}|jd|j��yrbrmr�s   r�
test_read_allz BufferedReaderTest.test_read_all s4�����5�6������������U�Z�Z�\�2r �cpuc�*�
���	d}ttd��|z}tj|�t	t|��}|j
tjd�5}|j|�ddd�|j
tj|jd��5}|j|d��
g�g��
��fd�}td�D�cgc]}tj|�	���}}tj|�5t!j"d
�ddd�|j%�d�z�dj'��}td�D]8}t	t|g��}	|j)|j+|	�|��:	ddd�tj,tj�y#1swY��LxYwcc}w#1swY��xYw#1swY�KxYw#tj,tj�wxYw)
N���rrrrbc���	tddg�D](}�j|�}|sy�j|��*y#t$r}�j|��d}~wwxYw)Nr9�)rrsrK�	Exception)rer��er��errors�resultss   ���rr2z*BufferedReaderTest.test_threads.<locals>.f7sZ���
�!&��2�w��A� %�
�
�1�
�A�#$� %�#�N�N�1�-�"0��%���
�
�a�(����s�$<�<�	A�A�Ar�r+�{�G�z�?�(the following exceptions were caught: %rr )rBr��random�shufflerr�r/rr�rM�	read_moder�r�r-r
�
start_threadsr�r�r�r�r�rr�)
r;�N�lr�r2r�r$�threadsr��cr�ryrzs
          @@@r�test_threadszBufferedReaderTest.test_threads&s����$	/��A��U�3�Z� �1�$�A��N�N�1���i��l�#�A����9�+�+�T�2�a�����
�3����9�+�+�T�^�^�q��I�S�����Q��������@E�R�y�I�y�!�9�+�+�1�5�y��I�%�3�3�G�<��J�J�t�$�=�� � ��>��G�I��H�H�W�%���s��A��i���n�-�A��$�$�Q�W�W�Q�Z��3�$�-J�4
���Y�-�-�.�93�2��$J�<�<��#J�I��4
���Y�-�-�.�sg�A"G-�'G�94G-�-+G!�G�5G!�G�"A4G!�G-�G
�G-�G!�G	�G!�!G*�&G-�-%Hc��|j|jd��}|j|j|j�|j|j|j
d�|j
d�|j|j|j
d�|j|j|j�y)Nr rr9)r�r�r�r�r`r]rsr!s  rr"z"BufferedReaderTest.test_unseekableOs�������-�-�i�8�9�����$�3�3�U�Z�Z�@����$�3�3�U�Z�Z��C�
�
�
�1�
����$�3�3�U�Z�Z��C����$�3�3�U�Z�Z�@r c���|jd�}|j|�}|jt|jd�|jt|j
�d�|_y)Nrcrc��yrJr&r&r rr�z7BufferedReaderTest.test_misbehaved_io.<locals>.<lambda>^���dr )rzr�r�r�r]r`r�r�s   r�test_misbehaved_ioz%BufferedReaderTest.test_misbehaved_ioWsS���$�$�%;�<�����������'�5�:�:�q�1����'�5�:�:�.�#��r c	�F�d}d|dz
||dz|dzfD�]}|jd|zg�}|j||�}|j|j|�d|z�|j|jddj||j��|jd|dz
zdg�}|j||�}|j|j|�d|z�|j|jddj||j����y)Nr8r}r9rrzfailed for {}: {} != 0)ror�r�rsrFr�)r;r�rerr�s     r�test_no_extraneous_readz*BufferedReaderTest.test_no_extraneous_read`s�����W�q�[�'�7�Q�;��!��D�A��N�N�D�1�H�:�.�E��G�G�E�7�+�E����U�Z�Z��]�D�1�H�5����U�4�4�a�5�<�<�Q��@W�@W�X�
Z��N�N�D�A��E�N�D�#9�:�E��G�G�E�7�+�E����U�Z�Z��]�D�1�H�5����U�4�4�a�5�<�<�Q��@W�@W�X�
Z�Er c��|j|jd��}|jd�|j�|j	d�5|jt|j�ddd�|j	d�5|jt|jd�ddd�|j	d�5|jt|j�ddd�|j	d�5|jt|jt��ddd�|j	d�5|jt|jt��ddd�|j	d�5|jt|j�ddd�|j	d	�5|jt|j�ddd�|j	d
�5|jt|jd�ddd�y#1swY���xYw#1swY���xYw#1swY��ZxYw#1swY��$xYw#1swY��xYw#1swY��xYw#1swY��xYw#1swYyxYw)N�12r9rPrQrsrfrr�rhr]r)r2r:rsr�rUr�r�rPrQrfr�rr�rhr]rLs  r�test_read_on_closedz&BufferedReaderTest.test_read_on_closedts���������U� 3�4��	���q�	�	���	�
�\�\�&�
!����j�!�&�&�1�"�
�\�\�'�
"����j�!�'�'�1�5�#�
�\�\�&�
!����j�!�&�&�1�"�
�\�\�*�
%����j�!�*�*�i�k�B�&�
�\�\�+�
&����j�!�+�+�y�{�C�'�
�\�\�'�
"����j�!�'�'�2�#�
�\�\�*�
%����j�!�*�*�5�&�
�\�\�&�
!����j�!�&�&�!�4�"�
!�"�
!��
"�
"��
!�
!��
%�
%��
&�
&��
"�
"��
%�
%��
!�
!�s`�!H'�
"H4�!I�*I�*I�!I'�!I3�<"I?�'H1�4H>�I�I�I$�'I0�3I<�?Jc� �|jd�}|j|�}|j|j��|j	|j
|j�|j	|j
|jd�y)Nr	r)r�r�r�rPr�r�rhr�s   r�test_truncate_on_read_onlyz-BufferedReaderTest.test_truncate_on_read_only�sh������'��������������)�*����$�3�3�U�^�^�D����$�3�3�U�^�^�Q�Gr c�
�|jd�}|j|�}|j|j�d�|j|j	d�d�|j|j�d�y�Nr�rr9�1)r�r�r�r`rsr�s   r�test_tell_character_device_filez2BufferedReaderTest.test_tell_character_device_file�se���*�*�5�1���g�g�c�l���������Q�'�������!��d�+��������Q�'r c�J�|jd�}|j|�}|j|jdtj
�d�|j|jdtj�d�|j|jdtj
�d�|j|jd�d�|j|j�d�|j|jdtj
�d�yr�)	r�r�r�r]r�r�SEEK_SETrsr`r�s   r�test_seek_character_device_filez2BufferedReaderTest.test_seek_character_device_file�s����*�*�5�1���g�g�c�l��������!�R�[�[�1�1�5�������!�R�[�[�1�1�5�������!�R�[�[�1�1�5�������!��d�+�
	
�������Q�'�������!�R�[�[�1�1�5r N)r#r$r%r�r:r?rBrGrIrLrQrXrZr_rgrkrnrpr
�requires_working_threadingr�requires_resourcer�r"r�r�r�r�r�r�r&r rr5r5[s����I�/�-�6�*� 	*�#�**�.7�*7�*M�A�(
+�7�3�1��0�0�2��W���u�%�%/�&�3�%/�NA�#�Z�(5�,H�(�6r r5c�l�eZdZejZedddd��d��Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
y)�CBufferedReaderTestT�Lsanitizer defaults to crashing instead of returning NULL for malloc failure.��memory�addressr/�reasonc��tj|�tjdkDr]|j	�}|j|�}|j
tttf|j|tj�yy�Nr�)r5r:rZr�ror�r�r
�MemoryErrorr�rHr�s   rr:z$CBufferedReaderTest.test_constructor��d��	�+�+�D�1��;�;��#��N�N�$�E��G�G�E�N�E����}�k�:�F�����s�{�{�
4�$r c���|jdg�}|j|�}|jt|j|d��|jt|j
�|jt|j|d��|jt|j
�|jt|j|d��|jt|j
�y)Nr	rr+r9r�)ror�r�r�rHrsr�s   r�test_initializationz'CBufferedReaderTest.test_initialization�s�������x�(�����������*�e�n�n�e���K����*�e�j�j�1����*�e�n�n�e���M����*�e�j�j�1����*�e�n�n�e���L����*�e�j�j�1r c��|jd�}|j|�}|jt|jd�y)Nrcr)rzr�r�r�rsr�s   r�test_misbehaved_io_readz+CBufferedReaderTest.test_misbehaved_io_read�s8���$�$�%;�<��������	
���'�5�:�:�r�2r c��|jtjtj�t	j
dtf�5|jtjd�}|j|�}||_	tj|�}~tj�ddd�|j�|�y#1swY�!xYw)Nr�r�)r,rr�r�rr�r�r&r�r2r�r�rr�r��r;rr2r�s    rr�z+CBufferedReaderTest.test_garbage_collection�s���	
���	�(�(�)�*:�*:�;�
�
+�
+�R��,A�
B��K�K�	� 0� 0�%�8�E������A��A�C����Q��B����� �
C�	
���"�$��#�C�
B�s
�
A#C
�
Cc��|jtd�5|j|j�ddd�ddd�y#1swYyxYw)Nr2r7�r^r�r�r:r:s r�test_args_errorz#CBufferedReaderTest.test_args_error��8��
�
#�
#�I�/?�
@��G�G�D�L�L�N�D�$��5�A�
@�
@���#A�Ac�4�|j|jd��}d�|_|j|�}|jt�5}|j�ddd�|j
jj�y#1swY�/xYw)Nr�c��yr r&�rcs rr�z=CBufferedReaderTest.test_bad_readinto_value.<locals>.<lambda>�s��Rr )	r�r:rfr�r�rr�r(�	__cause__�r;rr�r*s    r�test_bad_readinto_valuez+CBufferedReaderTest.test_bad_readinto_value�sm��������U�+�,��'���������
�
�
�w�
'�2��N�N��(����"�,�,�0�0�1�(�
'�s�B�Bc�>�|j|jd��}d�|_|j|�}|jt�5}|j�ddd�|j
jjt�y#1swY�4xYw)Nr�c��yr�r&r�s rr�z<CBufferedReaderTest.test_bad_readinto_type.<locals>.<lambda>�s��Sr )
r�r:rfr�r�rrr(r�r�r�s    r�test_bad_readinto_typez*CBufferedReaderTest.test_bad_readinto_type�so��������U�+�,��(���������
�
�
�w�
'�2��N�N��(����b�l�l�4�4�i�@�(�
'�s�B�BN)r#r$r%r�r2r�rr:r�r�r�r�r�r�r&r rr�r��sQ��	�	�	�B��d�D��G�H�4�H�4�2�3�$�6�
2�Ar r�c�$�eZdZejZy)�PyBufferedReaderTestN)r#r$r%r�r2r�r&r rr�r���
��	
�	�	�Br r�c��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zej0�ej4d�d���Zd�Zd�Zd�Zej0�d��Zy)�BufferedWriterTestrc���|j�}|j|�}|j|�|j|d��|j|d��|jd|j	d��|j�|j
t|j|d��|j
t|j|d��|j
t|j|d��|j|�|jd|j	d	��|j�|jd
j|j�d�y)Nr7r+r8rr	rr9r��ghir sabcghi)
ror�rHr�rMr�r�r�r�rDr�s   rr:z#BufferedWriterTest.test_constructor�s����� ��������
���u��
���u�$��/�
���u�"��-�����E�K�K��/�0�
���
����*�e�n�n�e���K����*�e�n�n�e���M����*�e�n�n�e���L�
���u������E�K�K��/�0�
���
�������%�"4�"4�5�y�Ar c�j�|jj|j�}~|jj|j�}|jttfd|j
d�|j
|j��|j|jd�d�y)Nr=r r)	r�r>r^r�r�rMrHror�r!s  rr?z%BufferedWriterTest.test_uninitializeds�����������(�����������(�����
�N�;�?�$�{�{�C�	1�	���t�~�~�'�(�������S�)�1�-r c��|j�}|j|�}|jd�|j|j�|j�|j
|jdg�y)Nshowdy!)ror�rMr�rDr�r�r�s   r�test_detach_flushz$BufferedWriterTest.test_detach_flushs\���n�n����g�g�c�l���	�	�)������)�)�*��
�
������)�)�I�;�7r c�X�|j�}|j|d�}|jd�|j|j�td�}|j|�d|dd|j
�|jdj|j�d�y)Nrbr	�def�***r �abcdef)	ror�rMr�rDr�r�r�r�)r;�writerr�r�s    r�
test_writezBufferedWriterTest.test_writes������!�������"��
���F������,�,�-��6�"��
���F����q�	�
���
�������&�"5�"5�6�	�Br c�.�|j�}|j|d�}d}tdt|�d�D]}|j	|||dz��dj|j�}|j|j|dd�|�y)Nrbsabcdefghijklmnoprrr i����)	ror�r�rrMr�rDr�r\)r;r�r��contentsre�flusheds      r�test_write_overflowz&BufferedWriterTest.test_write_overflow#s������!�������"��&���q�#�h�-��+�A��K�K���1�Q�3��(�,��(�(�6�.�.�/��	
����*�*�8�C�R�=�9�7�Cr c���ttd��dz}d}|j�}|j|d�}d�}|�}|t	|�krdtt
|�t	|�|z
�}|j|j||||z�|�||�||z
}|t	|�kr�d|j�|j|dj|j��y)Nrtrsrr�c3�TK�td�D]}td�D]}|����y�w)Nr9�)rr�)rPr�s  r�	gen_sizesz2BufferedWriterTest.check_writes.<locals>.gen_sizes5s'�����a����r��A��J�#�!�s�&(r )rr�ror�rrpr~r�rMr�r�rD)	r;�intermediate_funcr�rer�r�r��sizesrPs	         r�check_writeszBufferedWriterTest.check_writes.s�����s��$�t�+��
�����!�������#��	�����#�h�-���t�E�{�C��M�A�$5�6�D����U�[�[��!�A�d�F�);�<�d�C��e�$�
��I�A�	�#�h�-��
	���
�����3�8�8�F�,?�,?�#@�Ar c�(�|jd��y)Nc��yrJr&r�s rr�z0BufferedWriterTest.test_writes.<locals>.<lambda>Cs��r �r�r:s r�test_writeszBufferedWriterTest.test_writesBs�����,�-r c�(�|jd��y)Nc�"�|j�SrJr	r�s rr�z<BufferedWriterTest.test_writes_and_flushes.<locals>.<lambda>Fs
�����
r r�r:s r�test_writes_and_flushesz*BufferedWriterTest.test_writes_and_flushesEs�����5�6r c�T�d�}|j|�d�}|j|�y)Nc��|j�}|j|dzd�|j|dz
d�|j|d�yr8)r`r]�r�rs  r�_seekabsz:BufferedWriterTest.test_writes_and_seeks.<locals>._seekabsIs?���*�*�,�C��J�J�s�Q�w��"��J�J�s�Q�w��"��J�J�s�A�r c��|jdd�}|jdd�|jdd�|j|d�y)Nrr9r�)r]r�s  r�_seekrelz:BufferedWriterTest.test_writes_and_seeks.<locals>._seekrelOs<���*�*�Q��"�C��J�J�r�1���J�J�r�1���J�J�s�A�r r�)r;r�r�s   r�test_writes_and_seeksz(BufferedWriterTest.test_writes_and_seeksHs,��	�
	
���(�#�	�
	
���(�#r c�(�|jd��y)Nc�@�|j|j��SrJ)rhr`r�s rr�z>BufferedWriterTest.test_writes_and_truncates.<locals>.<lambda>Ws�����u�z�z�|�(Dr r�r:s r�test_writes_and_truncatesz,BufferedWriterTest.test_writes_and_truncatesVs�����D�Er c���|j�}|j|d�}|j|jd�d�|j|jd�d�|j	d�|j|jd�d�|j	d�	|jd	�|jd
�|jd�|j|j�d�|j|jd
�d�|j�}|j|jd�|�y#|j$r}|j}Yd}~��d}~wwxYw)Nrbrirssefghir��ksjklmn�0sopqrwxyz0123456789z'BlockingIOError should have been raisedr8sabcdefghijklmnopqrwxyzs	ABCDEFGHIr�s	01234567A)r�r�r�rMr�rYr��characters_writtenr�r�r\)r;r�r�rx�writtenr�s      r�test_write_non_blockingz*BufferedWriterTest.test_write_non_blockingYs1���'�'�)������Q���������W�-�q�1�������X�.��2����T��������X�.��2�	���T��	A��K�K�-�.�
�I�I�?�@�����"�%�������*�%�	'�	
������\�2�A�6��O�O���������\�2�A�6���#�#�	+��*�*�G��	+�s�)E�E5�E0�0E5c�6�|j�}|j|d�}|j|jd�d�|j|j	�d�|jdd�|j|jd�d�|jdd�|j|j
�d�|j|jd�d�|j�|j|j
�d	�y)
Nrsr�r�rsXYr}sXYcdefs123456sXYcdef123456)r:r�r�rMr`r]r�r��r;r�r�s   r�test_write_and_rewindz(BufferedWriterTest.test_write_and_rewindts����l�l�n������Q���������Y�/��3��������q�)�
�
�
�1�a��������U�+�Q�/�
�
�
�1�a����������3�������Y�/��3�
���
���������9r c���|j�}|j|d�}|jd�|j�|j	d|j
d�y�Nrbr	r)ror�rMr�r�rD�r;r�r�s   r�
test_flushzBufferedWriterTest.test_flush�sN�����!�������"��
���F��
���
������!4�!4�Q�!7�8r c���gd�}|j�}|j|d�}|j|�|j�|j	dj|j�d�y�N)rrKrrbr r�)ror�rr�r�r�rD�r;r�r�r�s    r�test_writelinesz"BufferedWriterTest.test_writelines�sY��!�����!�������"��
�����
���
�������&�"5�"5�6�	�Br c��tgd��}|j�}|j|d�}|j|�|j	�|jdj
|j�d�yr�)rror�rr�r�r�rDr�s    r�test_writelines_userlistz+BufferedWriterTest.test_writelines_userlist�s_���*�+�����!�������"��
�����
���
�������&�"5�"5�6�	�Br c��|j�}|j|d�}|jt|jgd��|jt|jd�|jt|jd�y)Nrbr��abc)ror�r�r�rr�s   r�test_writelines_errorz(BufferedWriterTest.test_writelines_error�sf�����!�������"�����)�U�%5�%5�y�A����)�U�%5�%5�t�<����)�U�%5�%5�u�=r c���|j�}|j|d�}|jd�~tj�|jd|jd�yr�)ror�rMrr�r�rDr�s   rr�z"BufferedWriterTest.test_destructor�sT�����!�������"��
���F������������!4�!4�Q�!7�8r c�X�|jtjtj�|j	tj|j
d��5}|j
|d�}|jd�|j|jd�d�|j|j�d�ddd�|j	tjdd��5}|j|j�d�ddd�y#1swY�UxYw#1swYyxYw)	Nrrrbr�rr�rr	)r,rr�r�r/�
write_moder�rMr�rhr`rs)r;r�r�r2s    r�
test_truncatez BufferedWriterTest.test_truncate�s������	�(�(�)�*:�*:�;�
�Y�Y�y�'�'����A�Y�
F�#��G�G�C��O�E��K�K�	�"����U�^�^�A�.��2����U�Z�Z�\�1�-�	G�
�Y�Y�y�'�'���Y�
;�q����Q�V�V�X�v�.�<�
;�G�
F��
<�
;�s�A%D�*!D �D� D)c�,�|jtjtj�|j	tjd�5}|jddz�ddd�gd�}|D]�}|j	tjd|��5}|jd|dzz�|j
d�|j�|j|j�|dz�ddd���y#1swY��xYw#1swY��xYw)	Nr�i')r*r)��zr+brr9r})
r,rr�r�r/rMrsrhr�r`)r;r2�buffer_sizesr,s    r�test_truncate_after_writez,BufferedWriterTest.test_truncate_after_write�s���	
���	�(�(�)�*:�*:�;�
�Y�Y�y�'�'��
.�!�
�G�G�G�e�O�$�/�)��'�K����9�+�+�U�k��J�a�����;��?�3�4����q�	��
�
��� � �����;��?�;�
K�J�(�	/�
.��
K�J�s�C>�AD
�>D�
D	rqc�t��
��	d}ttd��|z}tddg�}d}t��|t	|�kr6t|�}�j
||||z�||z
}|t	|�kr�6~|jtj|jd��5}|j|d��g�
��
�fd�}td	�D�cgc]}tj|�
���}	}tj|	�5t!j"d�ddd�|j%�
d�
z��j'�ddd�|jtjd
�5}|j)�}
ddd�td�D]-}|j+
j-t|g��|��/	tj.tj�ycc}w#1swY��xYw#1swY��xYw#1swY��xYw#tj.tj�wxYw)Nrsrtr9rvrrrbc���			�j�}�j|��##t$rYywxYw#t$r}�j	|��d}~wwxYwrJ)�popleftrbrMrwrK)r�rxr�ry�queues  ���rr2z*BufferedWriterTest.test_threads.<locals>.f�sa���	�"�'�$)�M�M�O��"�K�K��N�#��$.�'� &�'��%���
�
�a�(����s,�6�'�6�	3�6�3�6�	A�A�Arr{r|r}r)rr�rrrr~rKr/rr�r�r�r�r-r
r�r�r�r�r�rsr�rr�)r;r�r�r�rerPr�r2r$r�r�r�r�ryr	s            @@@rr�zBufferedWriterTest.test_threads�s����+	/��A��U�3�Z�(�1�,�H��1�b�'�N�E��A��G�E��c�(�m�#��E�{�����X�a��$��/�0��T�	���c�(�m�#�����9�+�+�T�_�_���J�c�����Q�����
�@E�R�y�I�y�!�9�+�+�1�5�y��I�%�3�3�G�<��J�J�t�$�=�� � ��>��G�I����
�'K�(���9�+�+�T�2�a��F�F�H��3��3�Z��� � ������s��!4�a�8� �
���Y�-�-�.��J�<�<��K�J��(3�2��

���Y�-�-�.�sm�A5H�;-H�()G:�G)�.G:�G.�-G:�(H�0H�AH�)G:�.G7	�3G:�:H�?H�H�H�%H7c��|j�}|j|d�}|jt|jd�|jt|j
�|jt|jd�d�|_y)Nr�rr�c��yrJr&r&r rr�z7BufferedWriterTest.test_misbehaved_io.<locals>.<lambda>�r�r )rzr�r�r�r]r`rMr�r�s   rr�z%BufferedWriterTest.test_misbehaved_io�si���$�$�&������q�!�����'�5�:�:�q�1����'�5�:�:�.����'�5�;�;�	�:�#��r c��|jt�5|j|j�dd�ddd�y#1swYyxYw�Nrbr��r�r�r�ror:s r�test_max_buffer_size_removalz/BufferedWriterTest.test_max_buffer_size_removal�s3��
�
�
�y�
)��G�G�D�N�N�$�a��,�*�
)�
)�s�"A�A
c���|j�}d�}||_|j|�}|jd�|jt|j
�|j
|j�y)Nc��t��rJr�)r(s r�	bad_writez?BufferedWriterTest.test_write_error_on_close.<locals>.bad_writes	���)�Or �spam)rorMr�r�r�r�r�r�)r;r�rr(s    r�test_write_error_on_closez,BufferedWriterTest.test_write_error_on_closesW���n�n���	���	��G�G�C�L��	��������'�1�7�7�+�������!r c�t�|j�}|j|d�}tj|j��}|j�|jj�|jt|jd�|j|j�|j�y)Nrbr{r)r�r�r�r-r�r.r��waitr�r�rMr�r�r�)r;rr��ts    r�test_slow_close_from_threadz.BufferedWriterTest.test_slow_close_from_threads~���#�#�%������q�!�����E�K�K�0��	���	�
���������*�e�k�k�7�;�������%�	���r N) r#r$r%r�r:r?r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
r�rr�r�r�rrrr&r rr�r��s����J�B� .�8�
C�	D�B�(.�7�$�F�7�6:�9�C�C�>�9�	/�<�$1��0�0�2��W���u�%�,/�&�3�,/�\#�-�"�1��0�0�2�	�3�	r r�c�Z�eZdZejZedddd��d��Zd�Zd�Z	d�Z
y)	�CBufferedWriterTestTr�r�c��tj|�tjdkDr]|j	�}|j|�}|j
tttf|j|tj�yyr�)r�r:rZr�ror�r�r
r�r�rHr�s   rr:z$CBufferedWriterTest.test_constructorr�r c���|j�}|j|�}|jt|j|d��|jt|j
d�|jt|j|d��|jt|j
d�|jt|j|d��|jt|j
d�y)Nrr+r�r9r�)ror�r�r�rHrMr�s   rr�z'CBufferedWriterTest.test_initialization*s������ �����������*�e�n�n�e���K����*�e�k�k�6�:����*�e�n�n�e���M����*�e�k�k�6�:����*�e�n�n�e���L����*�e�k�k�6�:r c�~�|jtjtj�t	j
dtf�5|jtjd�}|j|�}|jd�||_
tj|�}~tj�ddd�|j�|�|j!tjd�5}|j#|j%�d�ddd�y#1swY�jxYw#1swYyxYw)Nr�r�s123xxxr)r,rr�r�rr�r�r&r�rMr$r�r�rr�r�r/r�rsr�s    rr�z+CBufferedWriterTest.test_garbage_collection4s���	
���	�(�(�)�*:�*:�;�
�
+�
+�R��,A�
B��K�K�	� 0� 0�%�8�E������A�
�G�G�I���A�C����Q��B����� �C�	
���"�$��#�
�Y�Y�y�'�'��
.�!����Q�V�V�X�y�1�/�
.�C�
B��/�
.�s�
A4D'�=!D3�'D0�3D<c��|jtd�5|j|j�ddd�ddd�y#1swYyxYw)Nr6r7r�r:s rr�z#CBufferedWriterTest.test_args_errorEr�r�N)r#r$r%r�r6r�rr:r�r�r�r&r rrrsA��	�	�	�B��d�D��G�H�4�H�4�;�2�"6r rc�$�eZdZejZy)�PyBufferedWriterTestN)r#r$r%r�r6r�r&r rr r Kr�r r c��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�BufferedRWPairTestc��|j|j�|j��}|j|j�yrJ)r�ror�r��r;�pairs  rr:z#BufferedRWPairTest.test_constructorPs2���w�w�t�~�~�'����)9�:��������%r c��|jj|j�}~|jj|j�}|jttfd|j
d�|jttfd|jd�|j|j�|j��|j|jd�d�|j|j
d�d�yr<)
r�r>r^r�r�rsrMrHror�r$s  rr?z%BufferedRWPairTest.test_uninitializedTs����w�w���t�w�w�'����w�w���t�w�w�'�����
�N�;�?�#�y�y�!�	-�	
���
�N�;�?�#�z�z�3�	0�	
�
�
�d�n�n�&����(8�9�������1��s�+�������C��!�,r c��|j|j�|j��}|j|j|j�yrJ)r�ror�r�r�r$s  rr�zBufferedRWPairTest.test_detachbs:���w�w�t�~�~�'����)9�:�����$�3�3�T�[�[�Ar c��|jt�5|j|j�|j�dd�ddd�y#1swYyxYwr
rr:s r�(test_constructor_max_buffer_size_removalz;BufferedRWPairTest.test_constructor_max_buffer_size_removalfs<��
�
�
�y�
)��G�G�D�N�N�$�d�n�n�&6��2�>�*�
)�
)�s�1A�Ac��Gd�dt�}|jt|j|�|j��y)Nc��eZdZd�Zy)�JBufferedRWPairTest.test_constructor_with_not_readable.<locals>.NotReadablec��yr�r&r:s rrWzSBufferedRWPairTest.test_constructor_with_not_readable.<locals>.NotReadable.readablel���r N�r#r$r%rWr&r r�NotReadabler,k���
r r0�ror�r�r�)r;r0s  r�"test_constructor_with_not_readablez5BufferedRWPairTest.test_constructor_with_not_readablejs1��	�)�	�	
���'�4�7�7�K�M�4�>�>�;K�Lr c��Gd�dt�}|jt|j|j�|��y)Nc��eZdZd�Zy)�LBufferedRWPairTest.test_constructor_with_not_writeable.<locals>.NotWriteablec��yr�r&r:s rrPzUBufferedRWPairTest.test_constructor_with_not_writeable.<locals>.NotWriteable.writablesr.r N)r#r$r%rPr&r r�NotWriteabler6rr1r r8r2)r;r8s  r�#test_constructor_with_not_writeablez6BufferedRWPairTest.test_constructor_with_not_writeableqs1��	�9�	�	
���'�4�7�7�D�N�N�,<�l�n�Mr c���|j|jd�|j��}|j|j	d�d�|j|j	d�d�|j|j	�d�|j|jd�|j��}|j|j	d�d�y)Nr�rr	r9r
r)r�r:ror�rsr$s  rrBzBufferedRWPairTest.test_readxs����w�w�t�|�|�I�.����0@�A��������1��v�.�������1��t�,��������e�,��w�w�t�|�|�F�+�T�^�^�-=�>��������4��&�1r c����fd�}�j|�j�gd���j|�j�gd���j|�jd�ddg�y)Nc�b���j�jd��j��S)Ns	abc
def
h)r�r:ror:s�rr�z3BufferedRWPairTest.test_readlines.<locals>.<lambda>�s ���t�w�w�t�|�|�N�;�T�^�^�=M�Nr )rprqr�r�rprqr^r$s` rr_z!BufferedRWPairTest.test_readlines�sb���N�������)�)�+�-G�H������)�)�+�-G�H������)�)�!�,�x��.B�Cr c���|j|jd�|j��}|j|j	d�d�|j|j	�d�y)Nr�rr	r�)r�r:ror�rQr$s  rrGzBufferedRWPairTest.test_read1�sR���w�w�t�|�|�I�.����0@�A��������A���/��������v�.r c	�L�dD]�}|j|�5|j|jd�|j��}t	d�}|jt
||�|�d�|jt|�d�ddd���y#1swY��xYw)NrSr�sr�sabcde)rUr�r:rorr�rTr)r;rVr%rs    rrLz BufferedRWPairTest.test_readinto�s���/�F����f�%��w�w�t�|�|�I�6����8H�I�� ��+��� � �!6���v�!6�t�!<�a�@�� � ��t��h�7�&�%�0�%�%�s�A8B�B#	c�D�|j�}|j|j�|�}|jd�|j�t	d�}|j|�d|dd|j�|j|jddg�y)Nr	r�r�)ror�rMr�r�r�rD)r;rr%r�s    rr�zBufferedRWPairTest.test_write�s{���N�N����w�w�t�~�~�'��+���
�
�6���
�
���6�"���
�
�6����q�	��
�
��������&�&�)9�:r c��|j|jd�|j��}|j|j	d�jd��|j
|jd�d�y)Nr�rr	)r�r:ror�rPr\r�rsr$s  r�	test_peekzBufferedRWPairTest.test_peek�sY���w�w�t�|�|�I�.����0@�A������	�	�!��/�/��7�8�������1��v�.r c��|j|j�|j��}|j|j��yrJ)r�ror�rWr$s  r�
test_readablez BufferedRWPairTest.test_readable��2���w�w�t�~�~�'����)9�:������
�
��(r c��|j|j�|j��}|j|j��yrJ)r�ror�rPr$s  r�test_writeablez!BufferedRWPairTest.test_writeable�rDr c��|j|j�|j��}|j|j��yrJ)r�ror�rYr$s  r�
test_seekablez BufferedRWPairTest.test_seekable�s6���w�w�t�~�~�'����)9�:���������)r c���|j|j�|j��}|j|j�|j	�|j|j�yrJ)r�ror�r�r�r�r$s  r�test_close_and_closedz(BufferedRWPairTest.test_close_and_closed�sK���w�w�t�~�~�'����)9�:��������%��
�
��������$r c���d�}|j�}||_|j�}|j||�}|jt�5}|j�ddd�|jdt
j��|j|j�|j|j�|j|j�d�|_y#1swY��xYw)Nc��tyrJ��reader_non_existingr&r r�reader_closezIBufferedRWPairTest.test_reader_close_error_on_close.<locals>.reader_close����r rNc��yrJr&r&r rr�zEBufferedRWPairTest.test_reader_close_error_on_close.<locals>.<lambda>�r�r )ror�r�r�rrr'r(r�r�r�)r;rOrwr�r%rs      r� test_reader_close_error_on_closez3BufferedRWPairTest.test_reader_close_error_on_close�s���	 ����!��#������!���w�w�v�v�&��
�
�
�y�
)�S��J�J�L�*��
�
�+�S����-?�@�������$�������'�����
�
�&�$���*�
)�s�C*�*C3c���d�}|j�}|j�}||_|j||�}|jt�5}|j�ddd�|jdt
j��|j|j�|j|j�|j|j�d�|_d}tj�5tj�5d}tj�ddd�tj�ddd�y#1swY��xYw#1swY�2xYw#1swYyxYw)Nc��tyrJ��writer_non_existingr&r r�writer_closezIBufferedRWPairTest.test_writer_close_error_on_close.<locals>.writer_close�rPr rVc��yrJr&r&r rr�zEBufferedRWPairTest.test_writer_close_error_on_close.<locals>.<lambda>�r�r )ror�r�r�rrr'r(r�r�r�rr�r�)r;rWrwr�r%rs      r� test_writer_close_error_on_closez3BufferedRWPairTest.test_writer_close_error_on_close�s��	 ����!�����!��#����w�w�v�v�&��
�
�
�y�
)�S��J�J�L�*��
�
�+�S����-?�@�������%�����
�
�&�������'�$������
/�
/�
1��3�3�5����"�"�$�6�
��� �2�
1�*�
)��6�5��2�
1�s0�E�?E(�E�+E(�E�E%	�!E(�(E1c���d�}d�}|j�}||_|j�}||_|j||�}|jt�5}|j�ddd�|jdt
j��|j|jjt�|jdt
|jj��|j|j�|j|j�|j|j�d�|_d�|_y#1swY��xYw)Nc��tyrJrMr&r rrOzPBufferedRWPairTest.test_reader_writer_close_error_on_close.<locals>.reader_close�rPr c��tyrJrUr&r rrWzPBufferedRWPairTest.test_reader_writer_close_error_on_close.<locals>.writer_close�rPr rNrVc��yrJr&r&r rr�zLBufferedRWPairTest.test_reader_writer_close_error_on_close.<locals>.<lambda>	r�r c��yrJr&r&r rr�zLBufferedRWPairTest.test_reader_writer_close_error_on_close.<locals>.<lambda>	r�r )ror�r�r�rrr'r(rr
r�r�)r;rOrWrwr�r%rs       r�'test_reader_writer_close_error_on_closez:BufferedRWPairTest.test_reader_writer_close_error_on_close�s���	 �	 ����!��#������!��#����w�w�v�v�&��
�
�
�y�
)�S��J�J�L�*��
�
�+�S����-?�@����c�m�m�7�7��C��
�
�+�S����1J�1J�-K�L�������%�������'�������'�$���#���*�
)�s�E�Ec�
�Gd�dt�}|j|d�|d��}|j|j��|j|d�|d��}|j	|j��|j|d�|d��}|j	|j��|j|d�|d��}|j	|j��y)Nc��eZdZd�Zd�Zy)�8BufferedRWPairTest.test_isatty.<locals>.SelectableIsAttyc�<�tj|�||_yrJ)rorH�_isatty)r;�isattys  rrHzABufferedRWPairTest.test_isatty.<locals>.SelectableIsAtty.__init__	s���"�"�4�(�%��r c��|jSrJ)rdr:s rrez?BufferedRWPairTest.test_isatty.<locals>.SelectableIsAtty.isatty		s���|�|�#r N)r#r$r%rHrer&r r�SelectableIsAttyrb	s��
&�
$r rgFT)ror�r�rer�)r;rgr%s   r�test_isattyzBufferedRWPairTest.test_isatty	s���	$�y�	$��w�w�'��.�0@��0G�H���������'��w�w�'��-�/?��/F�G��������
�&��w�w�'��.�0@��0F�G��������
�&��w�w�'��-�/?��/E�F��������
�&r c��|j|j�|j��}tj|�}d}d}yrJ)r�ror�r�)r;�brwr�s   r�test_weakref_clearingz(BufferedRWPairTest.test_weakref_clearing	s8���g�g�d�n�n�&����(8�9���k�k�#������r N)r#r$r%r:r?r�r)r3r9rBr_rGrLr�rArCrFrHrJrRrYr_rhrkr&r rr"r"Nso��&�-�B�?�M�N�2�D�/�8�
;�/�)�)�*�%�$�"!�4$�.'�*r r"c�$�eZdZejZy)�CBufferedRWPairTestN)r#r$r%r�r=r�r&r rrmrm	s
��	�	�	�Br rmc�$�eZdZejZy)�PyBufferedRWPairTestN)r#r$r%r�r=r�r&r rroro!	r�r roc��eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdZdZy)�BufferedRandomTest�rb+zwb+c�X�tj|�tj|�yrJ)r5r:r�r:s rr:z#BufferedRandomTest.test_constructor)	s���+�+�D�1��+�+�D�1r c�X�tj|�tj|�yrJ)r5r?r�r:s rr?z%BufferedRandomTest.test_uninitialized-	����-�-�d�3��-�-�d�3r c��|jd�}|j|d�}|jd|jd��|j	d�|j	d�|j|j�|jd|j��|jd|jd	�y)
N)�asdf�ghjkrb�asr}sdddseeerxsdddeeer)ror�r�rsrMr�rD�r;r�rPs   r�test_read_and_writez&BufferedRandomTest.test_read_and_write1	s����n�n�/�0��
�W�W�S�!�_����������
�+�
�����
���������)�)�*�����"�'�'�)�,�����C�$4�$4�Q�$7�8r c��|jd�}|j|�}|jd|jd��|jd|j	��|jdd�|jd|jd��|j
d�|jdd�|jd|j��|jd	|j	��|jd
d�|jd|j	��|jdd�|jd
|j	��|jd|jd��|j�|jd|j��|jt|j
d�y)Ns	asdfghjklryr}rrwrss123fs	asdf123flr����r�r9rrsfl�r�)r:r�r�rsr`r]rMr�r�r�r�rzs   r�test_seek_and_tellz%BufferedRandomTest.test_seek_and_tell<	sH���l�l�<�(��
�W�W�S�\����������
�+�����B�G�G�I�&�
����1�
�����"�'�'�!�*�-�
�����
����1�
�����r�w�w�y�1�����B�G�G�I�&�
����A������B�G�G�I�&�
����1�
�����B�G�G�I�&����������,�
���
�����s�|�|�~�6����)�R�W�W�c�2r c�Z�|jd�}|j|�}|jd||d��|jd�|jd||d��|jd|j	��|j�|jd|j	��|jd||��|j
dd�|jd	�|j�|j
dd�|jd	||d
��y)Nrarr}r�rr�r�rsXYZr)r:r�r�rMr`r�r])r;�	read_funcr�r�s    r�check_flush_and_readz'BufferedRandomTest.check_flush_and_readS	s����l�l�<�(������������	�%�� 3�4�
���E������	�%�� 3�4�����E�J�J�L�)�
���
�����E�J�J�L�)������5�!1�2�����A���	�	�&��
���
�
�
�
�1�a�������5�!�!4�5r c�(�|jd��y)Nc� �|j|�SrJ)rs)r�r�s  rr�z8BufferedRandomTest.test_flush_and_read.<locals>.<lambda>f	s��z�u�z�z�4�7Hr �r�r:s r�test_flush_and_readz&BufferedRandomTest.test_flush_and_reade	s���!�!�"H�Ir c�.�dd�}|j|�y)Nc�d�t|dk\r|nd�}|j|�}t|d|�S)Nr�')r�rfr�r�rer(s   r�	_readintoz=BufferedRandomTest.test_flush_and_readinto.<locals>._readintoi	s2���q�A�v�!�4�0�A����q�!�A���2�A��<�r �r�r�)r;r�s  r�test_flush_and_readintoz*BufferedRandomTest.test_flush_and_readintoh	s��	 �	
�!�!�)�,r c�.�dd�}|j|�y)Nc�r�|j|�}|dk7r|d|}|jt|�d�|S�Nr�r9)rPr]rr�s   r�_peekz5BufferedRandomTest.test_flush_and_peek.<locals>._peekp	s:���
�
�1�
�A��B�w��b�q�E���J�J�s�1�v�q�!��Hr r�r��r;r�s  r�test_flush_and_peekz&BufferedRandomTest.test_flush_and_peeko	s��	�	
�!�!�%�(r c�p�|jd�}|j|�}|jd�|j�|jd�|j�|j	dd�|jd|j
��|jd|j��y)Nra�123s45rs	12345fghi)r:r�rMr�r]r�r�rsr�s   r�test_flush_and_writez'BufferedRandomTest.test_flush_and_writez	s����l�l�<�(��������
���F��
���
�
���E��
���
�
�
�
�1�a������s�|�|�~�6�����u�z�z�|�4r c�X�tj|�tj|�yrJ)r5r�r�r:s rr�zBufferedRandomTest.test_threads�	s���'�'��-��'�'��-r c�T�d�}|j|�d�}|j|�y)Nc�&�|jd�yr�)rPr�s rr�z6BufferedRandomTest.test_writes_and_peek.<locals>._peek�	s
���J�J�q�Mr c��|j�}|jdd�|jd�|j|d�y)Nr�r9r)r`r]rPr�s  rr�z6BufferedRandomTest.test_writes_and_peek.<locals>._peek�	s4���*�*�,�C��J�J�r�1���J�J�q�M��J�J�s�A�r r�r�s  r�test_writes_and_peekz'BufferedRandomTest.test_writes_and_peek�	s*��	����%� �	�
	
���%� r c�,�d�}|j|�y)Nc�J�|jdd�|jd�yr�)r]rsr�s r�_readz7BufferedRandomTest.test_writes_and_reads.<locals>._read�	s���J�J�r�1���J�J�q�Mr r��r;r�s  r�test_writes_and_readsz(BufferedRandomTest.test_writes_and_reads�	s��	�	
���%� r c�,�d�}|j|�y)Nc�J�|jdd�|jd�yr�)r]rQr�s r�_read1z9BufferedRandomTest.test_writes_and_read1s.<locals>._read1�	s���J�J�r�1���K�K��Nr r�)r;r�s  r�test_writes_and_read1sz)BufferedRandomTest.test_writes_and_read1s�	s��	�	
���&�!r c�,�d�}|j|�y)Nc�\�|jdd�|jtd��yr�)r]rfr�r�s rr�z;BufferedRandomTest.test_writes_and_readintos.<locals>._read�	s ���J�J�r�1���N�N�9�Q�<�(r r�r�s  r�test_writes_and_readintosz,BufferedRandomTest.test_writes_and_readintos�	s��	)�	
���%� r c��dD�]}|jd�}|j|d�}|j|jd�d�|j|j	�d�|jd|z�|j|j	�|dz�|j
�|j|j	�|dz�|j�}|j|dd|zzdd|z
zz���y)N)r9r�r rsr9�A�Br�)r:r�r�rsr`rMr�r�)r;�overwrite_sizer�r�r�s     r�test_write_after_readaheadz-BufferedRandomTest.test_write_after_readahead�	s���%�N��,�,�y�)�C��G�G�C��O�E����U�Z�Z��]�D�1����U�Z�Z�\�1�-��K�K��~�-�.����U�Z�Z�\�>�A�+=�>�
�K�K�M����U�Z�Z�\�>�A�+=�>�����A����Q��t�n�,�,�t�q�>�7I�/J�J�
L�%r c	�f�d�}d}tdt|��D]�}t|t|��D]z}|j|�}|j|d�}||||�|j	�t|�}d||<d||<|j
|j�|d||fz��|��y)Nc��|j|�|j||z
�|jd�|j|�|jd�y)N��)r]rsrM)r��pos1�pos2s   r�mutatez:BufferedRandomTest.test_write_rewind_write.<locals>.mutate�	sF��
�J�J�t���J�J�t�d�{�#��K�K�� �
�J�J�t���K�K�� r s�����rr)r}r9zfailed result for i=%d, j=%d)r�rr:r�r�r�r�r�)r;r�r(r��jr�r��expecteds        r�test_write_rewind_writez*BufferedRandomTest.test_write_rewind_write�	s���		!�
$���q�#�a�&�!�A��1�c�!�f�%���l�l�1�o������S�)���u�a��#����
�$�Q�<����������� � ������!?�1�a�&�!H�J�&�"r c�N�|jd�}|j|d�}|j|jd�d�|j|j	�d�|j|jd�d�|j|j	�d�y)Nr r)r}sAAsBBrs)r:r�r�rsrhrMr�s   r�!test_truncate_after_read_or_writez4BufferedRandomTest.test_truncate_after_read_or_write�	s���l�l�9�%������S�!��������A���.�������)�1�-�������U�+�Q�/�������)�1�-r c�X�tj|�tj|�yrJ)r5r�r�r:s rr�z%BufferedRandomTest.test_misbehaved_io�	rur c�H�|jd�5}|j|d�5}|jd�|j|j	d�d�|jd�|j|jd�d�|jd�t
d�}|j|�|j|d	�|jd
�|j|jd�d�|j�|j|j�d�ddd�ddd�|jd
�5}|j|d�5}|j|j	d�d�|jd�|j|j	d�d�|j�|j|j�d�ddd�ddd�y#1swY��xYw#1swY��xYw#1swY�*xYw#1swYyxYw)Nsabcdefghr)r�r9rE�2r
rR�f�4r�s1b2d3f4hr	rDr
sa2c)r:r�rMr�rsrQr�rfrPr�r�)r;r�r2rcs    r�test_interleaved_read_writez.BufferedRandomTest.test_interleaved_read_write�	s���
�\�\�+�
&�#�����c�"�a�����
�� � ������D�1�����
�� � ������T�2�����
���l���
�
�3��� � ��d�+�����
�� � ������D�1����	�� � ������=�#�'��\�\�&�
!�S�����c�"�a�� � ������D�1�����
�� � ������D�1����	�� � ������8�#�"�
!�#�"��'�
&�� #�"��"�
!�sH�H�DG4�+H�H�BH�#H�4G=	�9H�H	�H	�H�H!c�&�|jd�5}|j|d�5}|jd�|j|j	d�d�|j�|j|j
�d�ddd�ddd�|jd�5}|j|d�5}|jd�|j|j	�d�|j�|j|j
�d�ddd�ddd�|jd�5}|j|d�5}|jd�|j|j	d�ddd�|j�|j|j
�d�ddd�ddd�y#1swY��CxYw#1swY��HxYw#1swY��xYw#1swY��xYw#1swY�DxYw#1swYyxYw)	Nr�rr�r9rEs1bcdefsbcdr))r:r�rMr�rQr�r��r;r�r2s   r�test_read1_after_writez)BufferedRandomTest.test_read1_after_write�	s~��
�\�\�)�
$������a��A�����
�� � ������T�2����	�� � ������;�	!�%��\�\�)�
$������a��A�����
�� � �����F�3����	�� � ������;�	!�%��\�\�)�
$������a��A�����
�� � ������b�q�!1�6�:����	�� � ������;�
!�%�
$�!���%�
$��!���%�
$��!���%�
$�sm�G�A#G	�G�)G/�<A"G#�G/�?H�A&G;�8H�	G	�G�G �#G,	�(G/�/G8�;H	�H�Hc�"�|jd�5}|j|�5}|jd�|j|j	�d�|jd�|j|j	�d�|jd�|j|j	�d�|j�|j|j
�d�ddd�ddd�y#1swY�xYw#1swYyxYw)	Ns
ab
cdef
g
r�sb
r�rqrR�
s
1b
2def
3
)r:r�rMr�rr�r�r�s   r�test_interleaved_readline_writez2BufferedRandomTest.test_interleaved_readline_write
s���
�\�\�*�
+�s�����������
�� � �����v�6�����
�� � �����x�8�����
�� � �����u�5����	�� � �����1A�B��,�
+����,�
+�s#�D�CC9�(D�9D	�>D�DN)r#r$r%r�r�r:r?r{rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r"r�r&r rrqrq%	s����I��J�2�4�	9�3�.6�$J�-�	)�
5�.�	!�!�"�!�L�(J�4.�4�9�2<�,
C��O�"&�r rqc�T�eZdZejZedddd��d��Zd�Zd�Z	y)�CBufferedRandomTestTr�r�c��tj|�tjdkDr]|j	�}|j|�}|j
tttf|j|tj�yyr�)rqr:rZr�ror�r�r
r�r�rHr�s   rr:z$CBufferedRandomTest.test_constructor'
r�r c�X�tj|�tj|�yrJ)r�r�rr:s rr�z+CBufferedRandomTest.test_garbage_collection4
s���3�3�D�9��3�3�D�9r c��|jtd�5|j|j�ddd�ddd�y#1swYyxYw)Nr9r7r�r:s rr�z#CBufferedRandomTest.test_args_error8
r�r�N)
r#r$r%r�r9r�rr:r�r�r&r rr�r�$
s<��	�	�	�B��d�D��G�H�4�H�4�:�6r r�c�$�eZdZejZy)�PyBufferedRandomTestN)r#r$r%r�r9r�r&r rr�r�>
r�r r�c�@�eZdZ	d
d�Zd�Zd�Zd�Zd�Zdd�Zd�Z	dZ
y	)�StatefulIncrementalDecoderc�d�tjj||�|j�yrJ)�codecs�IncrementalDecoderrH�reset)r;rys  rrHz#StatefulIncrementalDecoder.__init___
s!���!�!�*�*�4��8��
�
�r c��dt|�zS)Nz<SID %x>)�idr:s r�__repr__z#StatefulIncrementalDecoder.__repr__c
s���B�t�H�$�$r c�>�d|_d|_t�|_yr�)r��or�r�r:s rr�z StatefulIncrementalDecoder.resetf
s���������k��r c�x�|jdz|jdz}}t|j�|dz|zfS)Nr9r))r�r�rr�)r;r�r�s   r�getstatez#StatefulIncrementalDecoder.getstatek
s7���v�v��z�4�6�6�A�:�1���T�[�[�!�1�S�5�1�9�,�,r c�v�|\}}t|�|_t|d�\}}|dz|dzc|_|_y)Nr)r9)r�r��divmodr�r�)r;�stater�r�r�r�s      r�setstatez#StatefulIncrementalDecoder.setstateo
s=���
�����'����b�#����1��Q���A������r Fc��d}|D]�}|jdk(rK|td�k(r!|js�-||j�z
}�A|jj	|��]|jj	|�t|j�|jk(s��||j�z
}��|r|jr||j�z
}|S)Nr�r�.)r��ordr��process_wordrKr)r;�input�final�outputr(s     r�decodez!StatefulIncrementalDecoder.decodeu
s������A��v�v��{���C��=��{�{��$�"3�"3�"5�5���K�K�&�&�q�)����"�"�1�%��t�{�{�#�t�v�v�-��d�/�/�1�1�F���T�[�[��d�'�'�)�)�F��
r c��d}|jdtd�k(r,tdt|jddxsd��|_n�|jdtd�k(r,tdt|jddxsd��|_ne|jj
d�}t|�|j
kr|d|j
zz
}|j
r|d|j
}|d	z
}t�|_|S)
Nr�rr��cr9r�rD�-r�)	r�r�rp�intr�r�r�rr�)r;r�s  rr�z'StatefulIncrementalDecoder.process_word�
s������;�;�q�>�S��X�%���S����Q�R��!5�A�6�7�D�F�
�[�[��^�s�3�x�
'���S����Q�R��!5�A�6�7�D�F��[�[�'�'��0�F��6�{�T�V�V�#��#�d�f�f�*�$���v�v���������c�M�F��k����
r N)�strictr�)r#r$r%rHr�r�r�r�r�r��codecEnabledr&r rr�r�M
s1���"�%�"�
-�&��"� �Lr r�c	��tjrE|dk(r?tjd�}tjd|j
ddddt��Syy)N�test_decoderr,)r5�encoder��incrementalencoder�streamreader�streamwriter�incrementaldecoder)r�r�r��lookup�	CodecInfor�)r5�latin1s  r�lookupTestDecoderr��
sR��!�.�.�4�>�3I����y�)�������
�
�d�#��D�9�	;�	;�4J�.r c��eZdZ	gd�Zd�Zy)�StatefulIncrementalDecoderTest))riFza.b.c.d.)�oiabcdT�abcd.)soi...abcd...Tr�)si.o6.x.xyz.toolongtofit.Fzx-----.xyz---.toolon.)s
i.i2.o6xyzTzxy----.z-----.)si.o3.i6.abcdefghijklmnopTzabc.ghi.mno.)s;i.o29.a.b.cde.o15.abcdefghijabcdefghij.i3.a.b.c.d.ei00k.l.mTz�a----------------------------.b----------------------------.cde--------------------------.abcdefghijabcde.a.b------------..c.------------.d.e------------.k--------------.l--------------.m--------------.c� �|jD]2\}}}t�}|j|j||�|��4t�}|j|jd�d�|j|jdd�d�y)Nr�r�r r9r�)�
test_casesr�r�r�)r;r��eofr�r�s     rr�z+StatefulIncrementalDecoderTest.test_decoder�
sx��"&�/�/��E�3��*�,�A����Q�X�X�e�S�1�6�:�#2�

'�(��������)�,�b�1�������#�q�)�7�3r N)r#r$r%r�r�r&r rr�r��
s����J�6	4r r�c�h�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Ze
jej j"d�d��Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d �Z&d!�Z'd"�Z(d#�Z)d$�Z*d%�Z+d&�Z,d'�Z-d(�Z.d)�Z/d*�Z0d+�Z1d,�Z2d-�Z3d.�Z4d/�Z5e6jne8jr�d0���Z:d1�Z;d2�Z<d3�Z=d4�Z>d5�Z?d6�Z@d7�ZAd8�ZBd9�ZCd:�ZDd;�ZEd<�ZFd=�ZGd>�ZHd?�ZId@�ZJdA�ZKdB�ZLdC�ZMdD�ZNdE�ZOdF�ZPdG�ZQdH�ZRdI�ZSdJ�ZTdK�ZUdL�ZVyM)N�TextIOWrapperTestc��d|_djd�|_tjtj
�t
jt�|jtjt�y)NsAAA
BBB
CCC
DDD
EEE
sAAA
BBB
CCC
DDD
EEE
rD)�testdatar��
normalizedrr�r�r��registerr�r,�
unregisterr:s rr�zTextIOWrapperTest.setUp�
sQ��:��
�6�=�=�g�F�������)�)�*����)�*�����)�)�+<�=r c�J�tjtj�yrJr�r:s rr�zTextIOWrapperTest.tearDown�
r�r c��|jd�}|j|d�}|j|d��}|j|dd��|j	|j
d�|j	|jd�|j|dd	�
�|j	|j
d�|j	|jd	�|j	d|j��|jrtnt}|j|�5|j|d��ddd�|jt�5|j|d
��ddd�|jt�5|j|d��ddd�|j|�5|j|dd��ddd�tjs&tj j"s|jr2|jt�5|j|dd
��ddd�tjs&tj j"s|jr2|jt�5|j|dd��ddd�|jt�5|j|dd��ddd�|jt�5|j|dd
��ddd�|jt�5|j|dd��ddd�|jt�5|j|dd��ddd�y#1swY��3xYw#1swY��xYw#1swY���xYw#1swY���xYw#1swY��oxYw#1swY��xYw#1swY��xYw#1swY��xYw#1swY��xYw#1swYyxYw)N�é

rsrr-r,�
rGFT)r.�line_buffering�é
rT��zutf-8�r.ryzreplace�
r�)r:r2rFrHr�r.rr�is_Cr�r�r��UnicodeEncodeErrorr�Py_DEBUGrZr�dev_mode)r;r+r(r�invalid_types     rr:z"TextIOWrapperTest.test_constructor�
s����L�L��)������4�(�����q�7��3��	�
�
�1�y�&�
�9�������Y�/�����)�)�5�1�	�
�
�1�w�t�
�<�������W�-�����)�)�4�0�����1�:�:�<�0�$(�I�I�y�:��
�
�
�|�
,�
�J�J�q�2�J�&�-�
�
�
�1�
2�
�J�J�q�8�J�,�3�
�
�
�z�
*�
�J�J�q�9�J�-�+�
�
�
�|�
,�
�J�J�q�7�2�J�6�-����s�y�y�1�1�T�Y�Y��"�"�#5�6��
�
�1�w�x�
�@�7����s�y�y�1�1�T�Y�Y��"�"�:�.��
�
�1�w�{�
�C�/�
�
�
�y�
)�
�J�J�q�7�B�J�7�*�
�
�
�z�
*�
�J�J�q�7�H�J�=�+�
�
�
�z�
*�
�J�J�q�7�F�J�;�+�
�
�
�z�
*�
�J�J�q�7�G�J�<�+�
*�)-�
,��
2�
2��
*�
*��
,�
,��7�6��/�.��
)�
)��
*�
*��
*�
*��
*�
*�sx�M�	M*�:M7�'N�N�7N�)N+�N7�
O�?O�M'�*M4�7N�N�N�N(�+N4�7O�O�Oc��|jj|j�}~|jj|j�}|jtt|�|jttfd|jd�|j|j�d��|j|jd�d�y)Nr=rrr-r�)rFr>r�rwr�r^r�r�rsrHror��r;rs  rr?z$TextIOWrapperTest.test_uninitialized�
s������&�&�t�'9�'9�:��
����&�&�t�'9�'9�:�����)�T�1�-����
�N�;�?� �v�v�q�	*�	
�
�
�4�>�>�#�g�
�6���������B�'r c���|j�}|j|�}|jtd�5|j	|d��ddd�y#1swYyxYw)Nzis not a text encoding�hexr-)r:r6r^�LookupErrorrF)r;r+r(s   r�*test_non_text_encoding_codecs_are_rejectedz<TextIOWrapperTest.test_non_text_encoding_codecs_are_rejected
sP��
�L�L�N������"��
�
#�
#�K�1I�
J����q�5��1�K�
J�
J�s�A�Ac���|j�}|j|�}|j|d��}|j|j	�|�|j|d��}|jd�|j
|j��|j	�|j|j�d�|jt|j�t|�|j|jd�|j|jd�|j
|j�|j
|j�y)NrDr-�howdyshowdyr�)r:r6rFr�r�rMr�r�r�r�r�r�r.ryr�
write_through�r;r+r(rs    rr�zTextIOWrapperTest.test_detachs���L�L�N������"�����q�7��3���
�
�a�h�h�j�!�$����q�7��3��	������������&�	���
��������x�0����*�a�h�h�/�	
�Q��������W�-�������8�,�����)�)�*�������)r c��|jdjd��}|j|�}|j|d��}|jj}|jt
|�d|z�d|_|jt
|�d|z�d|_|jt
|�d|z�d	|_|jt
|�d
|z�|jj�t
|�y)N�hellorr-z'<(%s\.)?TextIOWrapper encoding='utf-8'>r�z4<(%s\.)?TextIOWrapper name='dummy' encoding='utf-8'>r+z=<(%s\.)?TextIOWrapper name='dummy' mode='r' encoding='utf-8'>r�z><(%s\.)?TextIOWrapper name=b'dummy' mode='r' encoding='utf-8'>)r:r�r2rFr$r�r�r5�moder�r�)r;r�r(r�modnames     rr�zTextIOWrapperTest.test_repr's����l�l�7�>�>�'�2�3������$�����q�7��3���$�$�/�/������a��C�g�M�	O��������a��P�SZ�Z�	\��������a��Y�\c�c�	e��������a��Z�]d�d�	f�	
�������Q�r c���|j�}|j|d��}tj|d|�5	t	|�ddd�y#t
$rY�wxYw#1swYyxYw)Nrr-r5)r:rFrr�r�r��r;r�rs   rr�z%TextIOWrapperTest.test_recursive_repr;se���l�l�n�����s�W��5��
�
�
�s�F�A�
.�
��Q��/�
.�� �
��
��/�
.�s(�A �A�	A�A �A�A � A)c��|j�}|j|d�}|j|ddd��}|jd�|j	|j�d�|jd�|j	|j�d	�|jd
�|j	|j�d�y)Nrsr�
T�r.rHr�Xr zY
ZsXY
ZzA
BsXY
ZA
B)r:r6rFrMr�r�rs    r�test_line_bufferingz%TextIOWrapperTest.test_line_bufferingEs����L�L�N������4�(�����q�7�D�QU��V��	������������s�+�	������������x�0�	������������|�4r c���|j�}|j|d�}|j|ddd��}|jd�|j	|j�d�|j
d�	�|j	|j�d
�|jd�|j	|j�d�|jd
�|j	|j�d�|j
d�	�|j	|j�d�|jd�|j	|j�d�|j
�|j
d�	�|j	|jd�|j
d�	�|j
�|j
d�	�|j	|jd�y)Nrsrr#Fr$zAB
Cr T�rsAB
CzDEF
Gs	AB
CDEF
G�Hs
AB
CDEF
GH�IJ)r:r6rFrMr�r��reconfigurerrs    r�test_reconfigure_line_bufferingz1TextIOWrapperTest.test_reconfigure_line_bufferingPsq���L�L�N������4�(�����q�7�D�QV��W��	������������s�+�	�
�
�T�
�*��������x�0�	������������~�6�	������������~�6�	�
�
�U�
�+���������7�	����
���������7�	
�
�
��	�
�
�T�
�*�����)�)�5�1�	�
�
�T�
�*�	�
�
��	�
�
�T�
�*�����)�)�4�0r zutf-8 mode is enabledc��ttj�}	dD]&}|tjvs�tj|=�(tj�}|j�}t
j�5t
jdt�|j|�}ddd�|jj|�tjj�tjj|�y#1swY�cxYw#tjj�tjj|�wxYw)N)�LC_ALL�LANG�LC_CTYPErb)r�r%�environ�locale�getencodingr:rcrdre�EncodingWarningrFr�r.�clear�update)r;�old_environ�key�current_locale_encodingr(rs      r�test_default_encodingz'TextIOWrapperTest.test_default_encodingks����2�:�:�&��	+�6���"�*�*�$��
�
�3��6�'-�&8�&8�&:�#�����A��(�(�*��%�%�h��@��&�&�q�)��+�
���Q�Z�Z�)@�A��J�J�����J�J���k�*�
+�*��

�J�J�����J�J���k�*�s)�D�AD�>,D�*$D�D�D�?Ec��|j�}|j|d��}|j|jd�t	j
�5t	jdt�|j|�}ddd�|j|j�tj|j�y#1swY�DxYw)Nrr-rb)r:rFr�r.rcrdrer4�assertIsNotNoner�r��r;r(rs   r�
test_encodingzTextIOWrapperTest.test_encoding�s����L�L�N�����q�7��3��������W�-�
�
$�
$�
&��!�!�(�O�<��"�"�1�%�A�'�	
���Q�Z�Z�(��
�
�a�j�j�!�	'�
&�s�,C�Cc�*�|jd�}|j|d��}|jt|j�|jd�}|j|dd��}|jt|j�|jd�}|j|dd��}|j|j	�d�|jd�}|j|dd��}|j|j	�d	�y)
Nsabc
�
rDr-r�rrbzabc

�replaceuabc
�
)r:rFr��UnicodeErrorrsr�r=s   r�test_encoding_errors_readingz.TextIOWrapperTest.test_encoding_errors_reading�s����L�L��(�����q�7��3�����,����/��L�L��(�����q�7�8��D�����,����/��L�L��(�����q�7�8��D���������9�-��L�L��(�����q�7�9��E���������?�3r c��|j�}|j|d��}|jt|jd�|j�}|j|dd��}|jt|jd�|j�}|j|ddd��}|j	d	�|j�|j
|j�d
�|j�}|j|ddd��}|j	d	�|j�|j
|j�d�y)
NrDr-�ÿr�rrbr#)r.ryrHu	abcÿdef
sabcdef
r@sabc?def
)r:rFr�rArMr�r�r�r=s   r�test_encoding_errors_writingz.TextIOWrapperTest.test_encoding_errors_writing�s���L�L�N�����q�7��3�����,�����8��L�L�N�����q�7�8��D�����,�����8��L�L�N�����q�7�8�%)�
�
+��	�����	���	��������{�3��L�L�N�����q�7�9�%)�
�
+��	�����	���	��������|�4r c
��gd�}dgd�gd|gdgd�gdddggd	gd
�gg}d}|D�]4}tdj|�j|��}dD�]}td
d�D]�}|D]�\}}	|j	|j|�|�}
|j
|
||��}|rXg}	|jd�}
|
dk(rnI|jt|
�d�|j|
|j�z��Ut|�}t||	�D]\}}|j||��|jt|�t|	����������7y)N)�unix
�	windows
zos9
�last
�nonl)rGzwindows
zos9
rIrJr�r#)rGrHz	os9
last
rJrzunix
windows
z
os9
last
nonl�
)z
unix
windows
z
os9
z	last
nonl)rr,�utf-16�	utf-16-le�	utf-16-be�utf-32�	utf-32-le�	utf-32-be)FTr9r�rHr.r})rr�r�r�r2r:rFrsr�rrKrrB�zip)r;�input_linesr]�	encodingsr.r�do_readsr�rH�	exp_linesr��textio�	got_lines�c2�got_line�exp_lines                r�
test_newlineszTextIOWrapperTest.test_newlines�ss��L���H�J��+���F�H��+�->�@�B��B�D�
��
�	�"�H������-�4�4�X�>�?�D�)��$�Q��|�G�.3�*��� $� 3� 3�D�L�L��4F�� P��!%�!3�!3�E�7�;C�"4�"E��#�(*�I�"&�%+�[�[��^��#%��8�$)� $� 0� 0��R��!� <� )� 0� 0��f�o�o�6G�1G� H�#'�)-�V��I�25�i��2K�.�H�h� �,�,�X�x�@�3L��(�(��Y���Y��H�#/4� ,�*�"r c��d}|jdd�jdd�}d|jd�jd��fd|jd�jd��fd	gd
�fdgd�fd
gd�ffD]�\}}|j|�}|j	|d|��}|j|j
�|�|jd�|j|j�dj|����y)NsAAA
BBB
CCC
DDD
EEE
FFF
GGGs
r��
rDT)�keependsr�r#)zAAA
zBBB
z
CCC
DDD
EEE
�FFF
�GGGr)zAAA
BBB
CCC
DDD
EEE
rarbrK)z
AAA
BBB
CCC
zDDD
zEEE
z
FFF
z
GGGrGr)
r@r��
splitlinesr:rFr�r�r]rsr�)r;rrrHr�rc�txts       r�test_newlines_inputz%TextIOWrapperTest.test_newlines_input�s���?���%�%�g�u�5�=�=�e�U�K�
�
�:�$�$�W�-�8�8�$�8�G�H�
�����)�4�4�d�4�C�D�
�P�Q�
�J�K�
�Q�R�"��G�X��,�,�x�(�C��$�$�S�7�G�$�L�C����S�]�]�_�h�7��H�H�Q�K����S�X�X�Z�����):�;�"r c���ddddd�}d|tjfgt|j��z}|D]�\}}|j	�}|j|d|��}|j
d�|j
d�|j
d	�|j�|j|jd
�|j|j�|���y)NsAAA
BBB
CCC
X
Y
ZsAAA
BBB
CCC
X
Y

ZsAAA
BBB
CCC
X
Y

Z)r�r#rKrrDrGzAAA
BzBB
CCC
zX
Y
ZF)r%�linesep�sortedr�r:rFrMr�r�r�r�)r;�testdictr]rHr�rcrds       r�test_newlines_outputz&TextIOWrapperTest.test_newlines_output�s���+�-�-�7�	�������,�-�.�����8H�1I�I��!&��G�X��,�,�.�C��$�$�S�7�G�$�L�C��I�I�h���I�I�k�"��I�I�k�"��I�I�K����S�Z�Z��/����S�\�\�^�X�6�"'r c�����g�|j�G��fd�d��}|�}|j|d��}|jd�~tj�|jdg��y)Nc���eZdZ��fd�Zy)�4TextIOWrapperTest.test_destructor.<locals>.MyBytesIOc�f���j|j���j|�yrJ)rKr�r�)r;r�r�s ��rr�z:TextIOWrapperTest.test_destructor.<locals>.MyBytesIO.closes!����������)��
�
�4� r Nr�)r�r�s��r�	MyBytesIOrms���
!r rorDr-r�r	)r:rFrMrr�r�)r;ror(rr�r�s    @@rr�z!TextIOWrapperTest.test_destructorsg������|�|��	!��	!�
�K�����q�7��3��	�����
��������&��1�%r c���g�G�fd�d|j�}|j�}||d��}~tj�|j	�gd��y)Nc�:���eZdZ��fd�Z��fd�Z��fd�Z�xZS)�<TextIOWrapperTest.test_override_destructor.<locals>.MyTextIOc�j���jd�	t�|�}|�y#t$rYywxYwr�r�r�s  ��rr�zDTextIOWrapperTest.test_override_destructor.<locals>.MyTextIO.__del__r�r�c�D���jd�t�|�	�yr|r�r�s ��rr�zBTextIOWrapperTest.test_override_destructor.<locals>.MyTextIO.closer�r c�D���jd�t�|�	�yr�r�r�s ��rr�zBTextIOWrapperTest.test_override_destructor.<locals>.MyTextIO.flushr�r r�r�s@�r�MyTextIOrrr�r rvrDr-r�)rFr:rr�r�)r;rvr(rr�s    @rr�z*TextIOWrapperTest.test_override_destructorsR�����	 �t�)�)�	 �
�L�L�N���Q��)��
����������+r c��|j�}tj�5}|jt�5|j|d��jddd�ts|j|j�n6|j�*|j|jjt�ddd�y#1swY�jxYw#1swYyxYw)Nrr-)
r�rr�r�r�rFr�r�r�r�r�r�r�r�s   rr�z/TextIOWrapperTest.test_error_through_destructor&s����#�#�%��
�
/�
/�
1�R��"�"�>�2��"�"�5�7�"�;�A�A�3�+��!�!�"�-�-�0����*�� � ����!7�!7��A�2�
1�2�2��2�
1�s#�C�C�A C�C	�C�Cc�j�dD�]�}dD�]�}|jtjd|��}||_|j	|jd�d�|j
�|jtjd|��}||_|j	|j�d�|j	|j�d�|j�}|j	|jd�d�|j	|jd�d�|jd�|j	|jd	�d
�|j	|jd�d�|j	|jd�d
�|j	|j�d
�|j	|j�|�|j	|jd�d�|j	|jdd	�|�|j	|jd�d�|j	|j|�|�|j	|j�d�|jd�r|j||�|j
�������y)N)r9r}rrsr�r�r8��� �!�?�@�A)rDr,r�w+r-r�r�r+rr}r�r9r�r��def�utf)r/rr�r1r�rMr�r`rsr]r\�multi_line_test)r;�	chunksize�encr2�cookies     r�
test_basic_iozTextIOWrapperTest.test_basic_io5s���L�I�2���I�I�i�.�.��s�I�C�� )��
�� � �������3����	��I�I�i�.�.��s�I�C�� )��
�� � �����1�-�� � �����5�1������� � ������A�.�� � ������u�5����q�	�� � ������D�1�� � ������C�0�� � ������B�/�� � �����2�.�� � �����6�2�� � ������A�.�� � �����1��v�6�� � �������3�� � �������8�� � �����5�1��>�>�%�(��(�(��C�0����	�33�Mr c	��|jd�|j�d}g}dD]z}g}t|�D]"}|j||t	|�z��$dj|�dz}|j|j
�|f�|j|��||jd�g}		|j
�}
|j�}|sn|	j|
|f��7|j|	|�y)Nru	sÿ࿿￿)rr9r}rrsr��rzr{r|�>r}r~rrsr�r#)
r]rhr�rKrr�r`rMrr�)r;r2r��sample�wlinesrP�charsr��line�rlinesrs           rr�z!TextIOWrapperTest.multi_line_testRs���	���q�	�	�
�
��$����L�D��E��4�[�����V�A��F��O�4�5�!��7�7�5�>�D�(�D��M�M�1�6�6�8�T�*�+�
�G�G�D�M�
M�	
���q�	�����&�&�(�C��:�:�<�D����M�M�3��+�&��	
�����(r c�B�|jtjdd��}|j�}|j	d�|j�}|j	d�|j�}|jd�|j
|j�|�|j
|j�d�|j
|j�|�|j
|j�d�|j
|j�|�|jd�|D]4}|j
|d�|jt|j��6|j
|j�|�|j�y)Nr�rr-uÿ
r)r/rr�r`rMr]r�rr�r�r�)r;r2�p0�p1�p2r�s      r�test_tellingzTextIOWrapperTest.test_tellinghs(���I�I�i�&�&��w�I�?��
�V�V�X��	�����
�V�V�X��	�����
�V�V�X��	���q�	��������2�&��������x�0��������2�&��������x�0��������2�&�	���q�	��D����T�8�,����g�q�v�v�.��	
�������2�&�	���	r c���t�}|dz
}d|z}t|jd��}|jt	|�t	|��d}t|jd��}||z}|jtjd�5}|j|dz�ddd�|jtjdd��5}|j|�}	|j|	t|d��|j|j�|�|j|j�|�ddd�y#1swY��xYw#1swYyxYw)	Nr}r�r�袈
rr+r-rD)
r3rr�r�rr/rr�rMrsr'r`r)
r;�
chunk_size�prefix_size�u_prefix�prefix�u_suffix�suffixr�r2r�s
          r�test_seekingzTextIOWrapperTest.test_seeking|s��(�*�
� �1�n����$���x���w�/�0������X���F��4����x���w�/�0������
�Y�Y�y�'�'��
.�!�
�G�G�D��F�O�/�
�Y�Y�y�'�'��w�Y�
?�1����{�#�A����Q��F�G� 4�5����Q�V�V�X�{�3����Q�Z�Z�\�8�4�	@�
?�/�
.��
?�
?�s�E
�A.E�
E�Ec�h�d}|jtjd�5}|j|�ddd�|jtjdd��5}|jd|_|j�|j
�ddd�y#1swY�hxYw#1swYyxYw)Ns࿿
rr+rr-r})r/rr�rMr1rr`)r;rr2s   r�test_seeking_tooz"TextIOWrapperTest.test_seeking_too�s��� ��
�Y�Y�y�'�'��
.�!�
�G�G�D�M�/�
�Y�Y�y�'�'��w�Y�
?�1�
�M�M��A�M�
�J�J�L�
�F�F�H�	@�
?�/�
.��
?�
?�s�B�4B(�B%�(B1c�,���d�d��fd�	}dt_	tjD]\}}}||��tjD]-\}}}�t	|�dzz
}d|z}|dz}|||z|��/	dt_y#dt_wxYw)N�rc	���	�jtjd�}|j|�|j	��jtjd��}�|_|j
�}|j	�t|t|�dz�D]�}ddt|�|z
fD]�}�jtjd��}�j|j
|�|d|�|j�}�j|j
|�||||z�|j|��j|j
�||d�|j	�����y)Nrr�r-r9r�)r/rr�rMr�r1rsr�rr�r`r])	r�min_posr2�decodedr�r�r��
CHUNK_SIZEr;s	       ��r�test_seek_and_tell_with_datazJTextIOWrapperTest.test_seek_and_tell.<locals>.test_seek_and_tell_with_data�s.���
G��	�	�)�*�*�D�1�A�
�G�G�D�M�
�G�G�I��	�	�)�*�*�^�	�D�A�&�A�M��f�f�h�G�
�G�G�I��7�C��L�1�$4�5���Q��G��q� 0�1�A��	�	�)�"2�"2�^�	�L�A��$�$�Q�V�V�A�Y�����<��V�V�X�F��$�$�Q�V�V�A�Y���!�a�%�0@�A��F�F�6�N��$�$�Q�V�V�X�w�q�r�{�;��G�G�I�2�6r r9r}�.r�)r�r�r�r�r)r;r�r�r��offsetr�r�r�s`      @rrz$TextIOWrapperTest.test_seek_and_tell�s�����
�	�,34�"�/�	8�=�H�H���q�!�,�U�3� I� >�H�H���q�!�#�c�%�j�!�m�3���f��� ��(��,�V�e�^�W�E� I�78�&�3��a�&�3�s�A!B�
Bc�P�|jtjdd��}|jd�|j	�|jtjdd��}|j|j
�d�|j�}|j|j
�d�|j�}|j|�|j|j
�d�|j|j�|�|j	�y)Nr�euc_jpr-u
AB
うえ
r+zAB
uうえ
)	r/rr�rMr�r�rr`r])r;r2r�r�s    r�test_multibyte_seek_and_tellz.TextIOWrapperTest.test_multibyte_seek_and_tell�s����I�I�i�&�&��h�I�?��	���$�%�	���	��I�I�i�&�&��h�I�?���������v�.�
�V�V�X���������'7�8�
�V�V�X��	���r�
��������'7�8��������2�&�	���	r c��|jtjdd��}|jd�|j	�}|jd�|j|�|jd�|j
�|jtjdd��}|j|j�d�|j
�y)	Nr�euc_jis_2004r-uæ̀�æùr+uæ̀̀)	r/rr�rMr`r]r�r�r)r;r2r�s   r�test_seek_with_encoder_statez.TextIOWrapperTest.test_seek_with_encoder_state�s����I�I�i�&�&��n�I�E��	�����
�V�V�X��	�����	���r�
�	�����	���	��I�I�i�&�&��n�I�E���������';�<�	���	r c���d}d}|D]�}|j�}|j||��}|j|�|j|�|jd�|j	|j�|dz�|jd�|j	|j�|dz�|j	|j
�|dzj|����y)N�
1234567890)rLrMrNrOrPrQr-rr})r:rFrMr]r�rsr�r�)r;rr]r.rcr2s      r�test_encoded_writesz%TextIOWrapperTest.test_encoded_writes�s��������H��,�,�.�C��"�"�3��"�:�A�
�G�G�D�M�
�G�G�D�M�
�F�F�1�I����Q�V�V�X�t�a�x�0�
�F�F�1�I����Q�V�V�X�t�a�x�0����S�\�\�^�d�Q�h�->�->�x�-H�I�r c��Gd�d|j�}|j|�d��}|jt|j�y)Nc��eZdZd�Zy)�5TextIOWrapperTest.test_unreadable.<locals>.UnReadablec��yr�r&r:s rrWz>TextIOWrapperTest.test_unreadable.<locals>.UnReadable.readable�r.r Nr/r&r r�
UnReadabler��r1r r�rr-)r:rFr�r�rs)r;r�rds   r�test_unreadablez!TextIOWrapperTest.test_unreadable�s?��	����	�� � ���� �@�����'�3�8�8�,r c��|j|jd�d��}d}	|jd�}|sn||z
}�|j|d�y)NsAA
BBrr-r�r9zAA
BB�rFr:rsr��r;rd�readsr�s    r�test_read_one_by_onez&TextIOWrapperTest.test_read_one_by_one�s[��� � ����k�!:�W� �M����������A����Q�J�E�	�
	
�����)r c�\�|j|jd�d��}|j|j�gd��|j	d�|j|jd�gd��|j	d�|j|jd�ddg�y)	NsAA
BB
CCrr-)�AA
�BB
�CCrr�r�r�)rFr:r�r�r]�r;rds  rr_z TextIOWrapperTest.test_readlines
s���� � ����m�!<�w� �O���������*@�A������������t�,�.D�E������������q�)�F�F�+;�<r c��|j|jd�d��}d}	|jd�}|sn||z
}�|j|d�y)Ns�AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Brr-r�r�z�AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Br�r�s    r�test_read_by_chunkz$TextIOWrapperTest.test_read_by_chunk
s\��� � ����.C�!D�w� �W���������
�A����Q�J�E�	�
	
����
�.r c���gd�}|j�}|j|d��}|j|�|j�|j	|j�d�y�N)r��cd�efrr-r�)r:rFrr�r�r��r;r�rcrds    rr�z!TextIOWrapperTest.test_writelines
sR�����l�l�n��� � ��w� �7�����q���	�	����������3r c���tgd��}|j�}|j|d��}|j|�|j	�|j|j
�d�yr�)rr:rFrr�r�r�r�s    rr�z*TextIOWrapperTest.test_writelines_userlist$
sX���'�(���l�l�n��� � ��w� �7�����q���	�	����������3r c��|j|j�d��}|jt|jgd��|jt|jd�|jt|jd�y)Nrr-r�r	)rFr:r�r�rr�s  rr�z'TextIOWrapperTest.test_writelines_error,
s_��� � �����'� �B�����)�S�^�^�Y�?����)�S�^�^�T�:����)�S�^�^�V�<r c���|j|j|j�d��}d}	|jd�}|sn||z
}�|j	||j
�y)NrDr-r�r9)rFr:rrsr�rr�s    r�test_issue1395_1z"TextIOWrapperTest.test_issue1395_12
se��� � ����d�m�m�!<�w� �O����������A����Q�J�E�	�
	
�������0r c���|j|j|j�d��}d|_d}	|j	d�}|sn||z
}�|j||j�y)NrDr-rsr��rFr:rr1rsr�rr�s    r�test_issue1395_2z"TextIOWrapperTest.test_issue1395_2>
sj��� � ����d�m�m�!<�w� �O�������������A����Q�J�E�	�
	
�������0r c�^�|j|j|j�d��}d|_|j	d�}||j	d�z
}||j�z
}||j�z
}||j�z
}|j
||j�y�NrDr-rs)rFr:rr1rsrr�r�r;rdr�s   r�test_issue1395_3z"TextIOWrapperTest.test_issue1395_3J
s���� � ����d�m�m�!<�w� �O�����������
����!����
�������
�������
��������������0r c���|j|j|j�d��}d|_|j	d�}||j	�z
}|j||j�yr�r�r�s   r�test_issue1395_4z"TextIOWrapperTest.test_issue1395_4U
s\��� � ����d�m�m�!<�w� �O�����������
��������������0r c�2�|j|j|j�d��}d|_|j	d�}|j�}|j
d�|j
|�|j|j	d�d�y)NrDr-rsrzBBB
)rFr:rr1rsr`r]r�)r;rdr�rs    r�test_issue1395_5z"TextIOWrapperTest.test_issue1395_5]
sq��� � ����d�m�m�!<�w� �O������������h�h�j�����������
�������!��g�.r c��|j|j�}|j|d��}|j|j	�|j	��y�NrDr-)r:rrFr�rY)r;r�rds   r�test_issue2282z TextIOWrapperTest.test_issue2282g
sF�����d�m�m�,��� � ��'� �:��������*�C�L�L�N�;r c��tj}dD�]}|j|d|��5}|jd�|j	�}ddd�|j|d�5}|j|j
�dj|��ddd�|j|d|��5}|jd�ddd�|j|d�5}|j|j
�dj|��ddd���y#1swY��xYw#1swY��xYw#1swY�oxYw#1swY��6xYw)	N��	utf-8-sigrLrOrr-�aaarr��xxx�aaaxxx)rr�r/rMr`r�rsr��r;�filename�charsetr2rs     r�test_append_bomz!TextIOWrapperTest.test_append_bomm
s����#�#��8�G����8�S�7��;�q�������f�f�h��<����8�T�*�a�� � �����5�<�<��+@�A�+����8�S�7��;�q������<����8�T�*�a�� � �����8�?�?�7�+C�D�+�*�9�;�;��+�*��<�;��*�*�s/�"D�'0D'�3D3�0D?�D$	�'D0	�3D<	�?E		c�N�tj}dD]�}|j|d|��5}|jd�|j	�}ddd�|j|d|��5}|j�|jd�|jd�|jd�ddd�|j|d	�5}|j
|j�d
j|��ddd���y#1swY��xYw#1swY�bxYw#1swY��xYw)Nr�rr-r�r��zzzr�bbbr�bbbzzz)	rr�r/rMr`r]r�rsr�r�s     r�
test_seek_bomzTextIOWrapperTest.test_seek_bom|
s����#�#��8�G����8�S�7��;�q�������f�f�h��<����8�T�G��<�����s����������q�	������	=�
���8�T�*�a�� � �����8�?�?�7�+C�D�+�*�9�;�;��=�<��
+�*�s$�"D�(AD�0D�D	�D	�D$	c� �tj}dD]�}|j|d|��5}|jd�ddd�|j|d|��5}|j	d�|j	d|j
�|jd�ddd�|j|d�5}|j
|j�d	j|��ddd���y#1swY��xYw#1swY�bxYw#1swY��xYw)
Nr�rr-r�r�rr�rr�)	rr�r/rMr]rr�rsr�)r;r�r�r2s    r�test_seek_append_bomz&TextIOWrapperTest.test_seek_append_bom�
s����#�#��8�G����8�S�7��;�q������<����8�S�7��;�q����q�	����q�$�-�-�(������<����8�T�*�a�� � �����8�?�?�7�+C�D�+�*�9�;�;��;�;��+�*�s#�C,�?C8�10D�,C5	�8D	�D
	c�R�|jtjdd��5}|j|jd�ddd�|jtjddd��5}|j|jd�ddd�y#1swY�RxYw#1swYyxYw)Nrrr-r�r@r)r/rr�r�ryrs  r�test_errors_propertyz&TextIOWrapperTest.test_errors_property�
s���
�Y�Y�y�'�'��w�Y�
?�1����Q�X�X�x�0�@�
�Y�Y�y�'�'��w�y�Y�
Q�UV����Q�X�X�y�1�R�
Q�@�
?��
Q�
Q�s�B�+B�B�B&c����tj��|jtjddd��5���fd�}td�D�cgc]}tj||f����}}tj|�j�5tjd�ddd�ddd�|jtjd�	�5��j�}td�D]&}|j|jd
|z�d��(	ddd�ycc}w#1swY��xYw#1swY��xYw#1swYyxYw)Nrrr9r@c�R��d|z}�j��j|�y)N�Thread%03d
)rrM)re�text�eventr2s  ��r�runz1TextIOWrapperTest.test_threads_write.<locals>.run�
s!���%��)���
�
������
r rr*r|r-r�)r�r�r/rr�r�r-r
r�r�r�r�rsr�r)r;r�r$r��contentrer�r2s      @@r�test_threads_writez$TextIOWrapperTest.test_threads_write�
s������!��
�Y�Y�y�'�'��w�!�Y�
L�PQ�
�
!&�b�	�+� )�1�!�'�'�s�!��>� )�
�+�!�/�/�����C��
�
�4� �D�M��Y�Y�y�'�'�'�Y�
:�a��f�f�h�G��2�Y��� � ����~��/A�!B�A�F��;�
:��	+�C�C��M�
L��;�
:�sB�D6�D%�-"D6�D*�%D6�AE�%D6�*D3	�/D6�6D?�Ec����|j|j|j�d���g���fd�}|�_|j	t
�j�|j�j�|j�jj�|j��|j�d�|j�d�d��_y)NrDr-c�b���j�jjg�ddt��rJ)r�r�r�)r�rds��rr�z>TextIOWrapperTest.test_flush_error_on_close.<locals>.bad_flush�
s&������S�Z�Z�%6�%6�7�F�1�I��)�Or rr9c��yrJr&r&r rr�z=TextIOWrapperTest.test_flush_error_on_close.<locals>.<lambda>�
rr )rFr:rr�r�r�r�r�r�r�r�)r;r�r�rds  @@rrz+TextIOWrapperTest.test_flush_error_on_close�
s����� � ����d�m�m�!<�w� �O����	���	����'�3�9�9�-�����
�
�#�����
�
�)�)�*������������#�������#� ��	r c�R�|j|j�}d�}d�}||_|j|d��}||_|jt�5}|j�ddd�|jjjd�|j|jjt�|j|jjjd�|j|j�d�|_d�|_y#1swY��xYw)	Nc��td��rr�r&r rr�z>TextIOWrapperTest.test_close_error_on_close.<locals>.bad_flush�
rr c��td��rr�r&r rrz>TextIOWrapperTest.test_close_error_on_close.<locals>.bad_close�
rr rDr-rr	c��yrJr&r&r rr�z=TextIOWrapperTest.test_close_error_on_close.<locals>.<lambda>�
r�r c��yrJr&r&r rr�z=TextIOWrapperTest.test_close_error_on_close.<locals>.<lambda>�
rr )r:rr�rFr�r�r�r�r(r�rr
r�r��r;r�r�rrdrs      rrz+TextIOWrapperTest.test_close_error_on_close�
s������d�m�m�,��	#�	#� ���� � ��'� �:����	�
�
�
�w�
'�3��I�I�K�(�������+�+�Z�8����c�m�m�7�7��A�������2�2�7�7��D�������$�$��� ��	�(�
'�s�D�D&c�N�|j|j�}d�}d�}||_|j|d��}||_|jt�5}|j�ddd�|jdtj��|j|jjt�|jdt|jj��|j|j�d�|_d�|_y#1swY��xYw)	Nc��t�rJrr&r rr�zLTextIOWrapperTest.test_nonnormalized_close_error_on_close.<locals>.bad_flush�
rr c��t�rJrr&r rrzLTextIOWrapperTest.test_nonnormalized_close_error_on_close.<locals>.bad_close�
rr rDr-rrc��yrJr&r&r rr�zKTextIOWrapperTest.test_nonnormalized_close_error_on_close.<locals>.<lambda>�
r�r c��yrJr&r&r rr�zKTextIOWrapperTest.test_nonnormalized_close_error_on_close.<locals>.<lambda>�
rr )r:rr�rFr�r�rrr'r(rr
r�r�rs      rrz9TextIOWrapperTest.test_nonnormalized_close_error_on_close�
s������d�m�m�,��	%�	%� ���� � ��'� �:����	�
�
�
�y�
)�S��I�I�K�*��
�
�*�C��
�
�,>�?����c�m�m�7�7��C��
�
�*�C��
�
�0I�0I�,J�K�������$�$��� ��	�*�
)�s�D�D$c��|j|j|j�d��}|j�|j�|j�|j	t
|j�yr�)rFr:rr�r�r�r�r�s  rrz"TextIOWrapperTest.test_multi_close�
sS��� � ����d�m�m�!<�w� �O���	�	���	�	���	�	�����*�c�i�i�0r c��|j|j|j�d��}|j|j|j
�|j|j|jd�y)Nrr-r)rFr�rr�r�r`r]r�s  rr"z!TextIOWrapperTest.test_unseekable�
s]��� � ��!6�!6�t�}�}�!E�PW� �X�����$�3�3�S�X�X�>����$�3�3�S�X�X�q�Ar c���|j|j|j�d��}|j|j�}|jt�5||_ddd�y#1swYyxYwr�)rFr:rr�r�r�)r;rdrcs   rr%z*TextIOWrapperTest.test_readonly_attributes�
sW��� � ����d�m�m�!<�w� �O���l�l�4�=�=�)��
�
�
�~�
.��C�J�/�
.�
.�s�A.�.A7c��|jgd��}|j|dd��}|j|jd�d�|j|j	�d�|jt|�dd	g�y)
N�r	r�sghi
jkl
opq
rDr#rGrs�abcdzefghi
zjkl
zopq
)rorFr�rsrrB�r;r�rds   r�
test_rawiozTextIOWrapperTest.test_rawio�
sq���n�n�A�B��� � ��w�� �E��������!��f�-���������3�����c��W�g�$6�7r c��|jgd��}|j|ddd��}|jd�|jd�|jd�|jd	j	|j
�d
�y)Nr
rDr#T)r.rHr�1z23
4�5r s123
45)rorFrMr�r�rDrs   r�test_rawio_write_throughz*TextIOWrapperTest.test_rawio_write_throughsp���n�n�A�B��� � ��w��/3�!�5���	�	�#���	�	�'���	�	�#��������#�"2�"2�3�Z�@r c����ggc��G��fd�d|j�}|j�}d}||t|�dz�}|j|dd��}|j	d�}|j|�|j
��|j��|j|j�d�g�|j|d	z�|j��|j|j�|d
z�y)Nc�.���eZdZ��fd�Z��fd�Z�xZS)�BTextIOWrapperTest.test_bufio_write_through.<locals>.BufferedWriterc�D���jd�t�|�|i|��SrOr�)r;r�r�r�flush_calleds   ��rr�zHTextIOWrapperTest.test_bufio_write_through.<locals>.BufferedWriter.flush�%����#�#�D�)��w�}�d�5�f�5�5r c�D���jd�t�|�|i|��SrO)rKr~rM)r;r�r�r�write_calleds   ��rrMzHTextIOWrapperTest.test_bufio_write_through.<locals>.BufferedWriter.writerr )r#r$r%r�rMr�)rrrs@��rr6rs���
6�
6�
6r r6rDr}rDT)r.rr rr~)
r6r:rrFr�rMr�r�r�r�)	r;r6rrr�rXr�rrs	       @@r�test_bufio_write_throughz*TextIOWrapperTest.test_bufio_write_throughs����&(��"��l�	6�T�0�0�	6���������u�c�$�i��k�2���#�#�E�G�26�$�8���{�{�7�#�����T��	
����&�����%�������)�3�/������T�B�Y������%�������)�4�"�9�5r c��|jg�}|j|dd��}|jd�|jd��|j	|j
d�|j	dj
|j�d�|jd	�|j	dj
|j�d
�|jd��|j	|j
d�|jd�|j�|j	dj
|j�d
�|j�|jd��|j	|j
d�|jd��|j�|jd��|j	|j
d�y)NrDr#rGrT�rr r��23r�F�45rN)	rorFrMr+r�rr�rDr�r!s   r�test_reconfigure_write_throughz0TextIOWrapperTest.test_reconfigure_write_through2sV���n�n�R� �����s�W�d��C��	�����	�
�
�D�
�)�������$�/�������#�"2�"2�3�T�:�	����
�������#�"2�"2�3�V�<�	�
�
�E�
�*�������%�0�	����
�	���	�������#�"2�"2�3�X�>�	�
�
��	�
�
�D�
�)�������%�0�	�
�
�D�
�)�	�
�
��	�
�
�D�
�)�������$�/r c��|j|jd�d��}|jt|jd�|j|jd�d��}|jt|j
�|j|jd�d��}|jt|j�y)Nr�rr-r9)rFrTr�r�rsrrs  r�test_read_nonbytesz$TextIOWrapperTest.test_read_nonbytesIs���
���t�}�}�S�1�G��D�����)�Q�V�V�Q�/����t�}�}�S�1�G��D�����)�Q�Z�Z�0����t�}�}�S�1�G��D�����)�Q�V�V�,r c��tjd�}tj|dd�5|j	|jd�d��}ddd�|j
tjd�y#1swY�+xYw)N�rot13�_is_text_encodingT�foor-r�)	r�r�rr�rFr:r�r�rM)r;r#rs   r�test_illegal_encoderz&TextIOWrapperTest.test_illegal_encoderSsi���
�
�g�&��
�
�
�u�&9�4�
@��"�"�4�<�<��#7�'�"�J�A�A����)�Q�W�W�e�4�A�
@�s�#A:�:Bc�����fd����}�jt|jd���}�jt|j���}�jt|j��fd�}|d�}�jt|jd�|d�}�jt|jd�|d�}�jt|jd�y)Nc���tjd�}d|_	�j�j	d�dd��}d|_|S#d|_wxYw)N�quopriTsaaaaaar#rRF)r�r�r$rFr:)r)rr;s  �r�_make_illegal_wrapperzETextIOWrapperTest.test_illegal_decoder.<locals>._make_illegal_wrapper^s_����]�]�8�,�F�'+�F�$�
1��&�&�t�|�|�I�'>�/3�h�'�H��,1��(��H��,1��(�s�#A�	Ar9c�����G�fd�d���fd�}tjd�}tj|d|�5��cddd�S#1swYyxYw)Nc���eZdZ�fd�Zy)�^TextIOWrapperTest.test_illegal_decoder.<locals>._make_very_illegal_wrapper.<locals>.BadDecoderc����SrJr&)r;�getstate_ret_vals �rr�zgTextIOWrapperTest.test_illegal_decoder.<locals>._make_very_illegal_wrapper.<locals>.BadDecoder.getstatets	���+�+r N)r#r$r%r�)r/s�r�
BadDecoderr-ss���,r r0c�����SrJr&)r�r0s �r�_get_bad_decoderzdTextIOWrapperTest.test_illegal_decoder.<locals>._make_very_illegal_wrapper.<locals>._get_bad_decodervs���!�|�#r r)r�)r�r�rr�)r/r2r)r0r*s`  @�r�_make_very_illegal_wrapperzJTextIOWrapperTest.test_illegal_decoder.<locals>._make_very_illegal_wrapperrsL���
,�
,�
$��]�]�8�,�F��"�"�6�+?�#3�5�,�.�5�5�5�s�A�ArTr&)r9r})r�r�rsr)r;rr3r*s`  @r�test_illegal_decoderz&TextIOWrapperTest.test_illegal_decoder[s����	�
"�#�����)�Q�V�V�Q�/�!�#�����)�Q�Z�Z�0�!�#�����)�Q�V�V�,�
		/�
'�r�*�����)�Q�V�V�R�0�&�r�*�����)�Q�V�V�R�0�&�v�.�����)�Q�V�V�R�0r c�l�|jj}dj||��}td|�S)Na�if 1:
            import codecs
            import {iomod} as io

            # Avoid looking up codecs at shutdown
            codecs.lookup('utf-8')

            class C:
                def __init__(self):
                    self.buf = io.BytesIO()
                def __del__(self):
                    io.TextIOWrapper(self.buf, **{kwargs})
                    print("ok")
            c = C()
            )�iomodr��-c)r�r#r�r)r;r�r6�codes    r�_check_create_at_shutdownz+TextIOWrapperTest._check_create_at_shutdown�s<����� � �����U�6��2�	
� ��d�+�+r c���|j�\}}}|r+|j|j|j��y|j	d|j�j��y)N�ok)r9r�shutdown_errorr�r��strip�r;�rc�outrs    r�(test_create_at_shutdown_without_encodingz:TextIOWrapperTest.test_create_at_shutdown_without_encoding�sT���5�5�7���C���
�M�M�$�-�-�s�z�z�|�<����T�3�:�:�<�#5�#5�#7�8r c��|jdd��\}}}|j|�|jd|j�j	��y)Nrr�rr;)r9r�r�r�r=r>s    r�%test_create_at_shutdown_with_encodingz7TextIOWrapperTest.test_create_at_shutdown_with_encoding�sP���5�5�w�=E�6�G���C�����������s�z�z�|�1�1�3�4r c���td�}|j|d�}t|j��j	�}|j|j
d�|jd��y)NsJust some random string
rr)�MemviewBytesIOrF�_to_memoryviewr�r�r�rsr�)r;r+r�	bytes_vals    r�test_read_byteslikez%TextIOWrapperTest.test_read_byteslike�s]���7�8�����q�'�*��
$�A�J�J�L�1�9�9�;�	���������i�&6�&6�w�&?�@r c���Gd�dt�}td�D]}	|j|�d���d�|_|j|�d��}y#t$rY�JwxYw)Nc��eZdZd�Zd�Zd�Zy)�,TextIOWrapperTest.test_issue22849.<locals>.Fc��yrOr&r:s rrWz5TextIOWrapperTest.test_issue22849.<locals>.F.readable����tr c��yrOr&r:s rrPz5TextIOWrapperTest.test_issue22849.<locals>.F.writable�rMr c��yrOr&r:s rrYz5TextIOWrapperTest.test_issue22849.<locals>.F.seekable�rMr N)r#r$r%rWrPrYr&r r�FrK�s��+�+�+r rPrrr-c��yrAr&�r$s rr�z3TextIOWrapperTest.test_issue22849.<locals>.<lambda>�s��1r )�objectr�rFrwr`)r;rPr�rs    r�test_issue22849z!TextIOWrapperTest.test_issue22849�sl��	,��	,�
�r��A�
��"�"�1�3��"�9��������q�s�W��5���	�
��
�s�A�	A&�%A&c�h�|j|jd��}|jd��y)N�testr2r-)rFr:r+)r;�wrappers  r�test_reconfigure_localez)TextIOWrapperTest.test_reconfigure_locale�s,���$�$�T�\�\�'�%:�;�����X��.r c���djd�djd�z}|j|�}|j|dd��}|j|j	�d�|j|j�5|jd��ddd�|j|j�5|jd�	�ddd�y#1swY�@xYw#1swYyxYw)
N�abcé
r��déf
�utf8r#rGrr-�rH)r�r:rFr�rr�r�r+)r;rr�rds    r�test_reconfigure_encoding_readz0TextIOWrapperTest.test_reconfigure_encoding_read�s����!�!�(�+�j�.?�.?��.G�G���l�l�4� ��� � ��x�� �F����������5�
�
�
�t�8�8�
9��O�O�W�O�-�:�
�
�
�t�8�8�
9��O�O�D�O�)�:�
9�:�
9��
9�
9�s�C�:C"�C�"C+c��|j�}|j|dd��}|jd�|jd��|jd�|j	�|j|j
�d�y)	NrDr#rG�foo
r�r-r	sfoo
é
)r:rFrMr+r�r�r�rs   r� test_reconfigure_write_fromasciiz2TextIOWrapperTest.test_reconfigure_write_fromascii�sl���l�l�n��� � ��w�� �E���	�	�'�������-��	�	�(���	�	���������);�<r c�d�|j�}|j|dd��}|jd�|jd��|j	|j�d�|jd�|j
�|j	|j�d	�|j�}|j|d
d��}|jd�|jd��|jd�|j
�|j	|j�d
�y)Nr�r#rGrZrr-sabc�
r[s
abc�
déf
rD�abc
r�s	abc
déf
)r:rFrMr+r�r�r�rs   r�test_reconfigure_writez(TextIOWrapperTest.test_reconfigure_write�s����l�l�n��� � ��x�� �F���	�	�+�������)���������6��	�	�*���	�	���������)A�B��l�l�n��� � ��w�� �E���	�	�'�������-��	�	�*���	�	���������)=�>r c�2�|j�}d�|_d|_|j|dd��}|j	d�|jd��|j	d�|j
�|j|j�d	�y)
Nc��yr�r&r&r rr�zGTextIOWrapperTest.test_reconfigure_write_non_seekable.<locals>.<lambda>�s��ur rDr#rGrcr�r-r[sabc
déf
)	r:rYr]rFrMr+r�r�r�rs   r�#test_reconfigure_write_non_seekablez5TextIOWrapperTest.test_reconfigure_write_non_seekable�sz���l�l�n��$������� � ��w�� �E���	�	�'�������-��	�	�*���	�	��	
�������*J�Kr c�d�|j|j�ddd�}|jd��|j|jd�|j|j
d�|j
d�|jd��|j|jd�|j|j
d�|jd�	�|j|jd�|j|j
d�|j
d
�|jdd��|j|j
d
�|jd�|j|j�d�|j|j�j�d�y)NrDr@r#r-�LF
rr]rb�ry�CRLF
rrGr�rzLF
CRLF
s	LF
CRLF
)rFr:r+r�r.ryrMr]rsr�r�r�s  r�test_reconfigure_defaultsz+TextIOWrapperTest.test_reconfigure_defaults�s<��� � ������)�T�J�������&�������w�/�������Y�/��	�	�&�������'�������w�/�������Y�/����x��(�������w�/�������X�.��	�	�(������$��7�������X�.�������������\�2��������.�.�0�/�Br c�	�|j|j�ddd�}|jt�5|j	d��ddd�|j
r`|jt�5|j	d��ddd�|jt�5|j	d��ddd�|jt�5|j	d��ddd�|j
r0|jt�5|j	d��ddd�|jt�5|j	d�	�ddd�|jt�5|j	d�	�ddd�|jt�5|j	d
�	�ddd�|j
s0|jt�5|j	d�	�ddd�|j
�r|jt�5|j	t���ddd�|jt�5|j	d
dz��ddd�|jt�5|j	t���ddd�|jt�5|j	d
dz��ddd�|jt�5|j	t�t���ddd�|j|jd�|j|jd�|j|j d�|j|j"d�|j	ddddd��|j|jd�|j|jd�|j|j d�|j|j"d�y#1swY���xYw#1swY���xYw#1swY��wxYw#1swY��TxYw#1swY��%xYw#1swY��xYw#1swY���xYw#1swY���xYw#1swY���xYw#1swY��UxYw#1swY��/xYw#1swY��xYw#1swY���xYw#1swY���xYw)NrDr@rKrTr-r
zlocalerjr]�xyzrr(r}rsr)rrFr�rbrT)r.ryrHrr)rFr:r�r�r+r
rrr�r�r6r
r�r.ryr�rrr�s  r�test_reconfigure_errorsz)TextIOWrapperTest.test_reconfigure_errorssY��� � ������)�T�J��
�
�
�y�
)��O�O�R�O�(�*��9�9��"�"�#5�6������2�7��"�"�;�/������4�0��
�
�y�
)��O�O�2�O�&�*��9�9��"�"�#5�6����x��0�7��
�
�y�
)��O�O�B�O�'�*�
�
�
�z�
*��O�O�H�O�-�+�
�
�
�z�
*��O�O�E�O�*�+��y�y��"�"�:�.������/�/��9�9��"�"�#4�5����x�z��:�6��"�"�=�1����q�$�w��7�2��"�"�#4�5����h�j��9�6��"�"�=�1����a��g��6�2��"�"�#4�5����x�z�.6�j� �:�6�	
������w�/�������Y�/��
�
�c�(�(�%�0��
�
�c�'�'��/�����(�F�'+�4�	�	A�������x�0�������X�.��
�
�c�(�(�$�/��
�
�c�'�'��.�c*�
)��7�6��/�/��*�
)��7�6��*�
)��
*�
*��
*�
*��/�.��6�5��1�1��5�5��1�1��5�5�s��P�4P�$P,�P9�Q�Q�0Q � Q-�Q:�R�R�R!�<R.�/$R;�P�P)�,P6�9Q�Q�Q� Q*�-Q7�:R�R�R�!R+�.R8�;Sc��|jd�}|j|dd��}|jd��|j|j	�d�|jd�}|j|dd��}|jd��|j|j	�d�|jd�}|j|dd	��}|jd��|j|j	�d
�|jd�}|j|dd��}|jd	��|j|j	�d�|jd
�}|j|dd	��}|jd��|j|j	�d�|j|j�dd	��}|jd��|jd�|jd��|jd�|jd��|jd�|jd	��|jd�|jd��|jd�dtjzdz}|j|j�j�jd�|�y)NsCR
EOFrDr#r]zCR
r�zCR
s	CR
LF
EOFrKzCR
LF
s	LF
CR
EOFzLF
CR
sCR
CRLF
EOFrz	CR
CRLF
zlinesep
rirkrgzLF
LF
CR
CRLF
)r:rFr+r�rrMr%rgr�r�r�)r;r�rdr�s    r�test_reconfigure_newlinez*TextIOWrapperTest.test_reconfigure_newlineKsM���l�l�:�&��� � ��g�t� �<�������%���������0��l�l�:�&��� � ��g�t� �<�������#���������0��l�l�>�*��� � ��g�t� �<�������%���������4��l�l�>�*��� � ��g�t� �<�������%���������4��l�l�-�.��� � ��g�t� �<�������'���������8�� � ������$� �G�������%��	�	�+�������#��	�	�&�������%��	�	�&�������%��	�	�&�������'��	�	�(���r�z�z�)�,B�B���������.�.�0�7�7��@�(�Kr c�R�|j|jd�d��}|jd�|j�|j�|j|jd�d��}|jd�|j	d�|j�y)NrVrDr-r9r$)rFr:rsr`rMrs  r�test_issue25862z!TextIOWrapperTest.test_issue25862osz�����t�|�|�G�4�w��G��	���q�	�	����	�������t�|�|�G�4�w��G��	���q�	�	�����	���r c�0�|j|jd�|j��}|j|�}|j�}|j	|d�|j|�|j	||j�zd�y)Nsfoo
bar
r`zfoo
bar
)r=r:rFrr�rM)r;�pr2r�s    r�test_issue35928z!TextIOWrapperTest.test_issue35928zst��������]� ;�T�\�\�^�L�����q�!���j�j�l������g�&�	���������q�z�z�|�+�\�:r N)Wr#r$r%r�r�r:r?rr�r�r�r&r,r�r�rZr�	utf8_moder:r>rBrEr]rerjr�r�r�r�r�r�r�r�rr�r�r�r�r�r_r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�
no_tracingr
r�r�rrrrr"r%r
rrrr!r&r4r9rArCrHrTrXr^rardrgrlrorqrsrvr&r rr�r��
s���>�+�!=�F	(�2�*�(�(�	5�1�6�X�_�_�S�Y�Y�(�(�*A�B�+�C�+�(	"�4�$5�0(I�T<� 7�$&�,�.B��:)�,�(5�"	�-8�^
��J�(-�*�=�	/�4�4�=�
1�
1�	1�1�/�<�
E�
E�E�2�
���0��0�0�2�G�3��G�"!�"!�(!�*1�B�
�	8�A�6�@0�.-�5�&1�P,�*9�5�	A�
6�/�
*�
=�?�*L�C�.3/�j"L�H	�;r r�c�*��eZdZ	�fd�Z�fd�Z�xZS)rEc�4��tt�|�	|��SrJ)rFr~rQ�r;�len_rs  �rrQzMemviewBytesIO.read1�s����e�g�m�D�1�2�2r c�4��tt�|�	|��SrJ)rFr~rsr{s  �rrszMemviewBytesIO.read�s����e�g�l�4�0�1�1r )r#r$r%rQrsr�r�s@rrErE�s����3�2�2r rEc��	tjd�}t|�t|�|jzz
}|j|d|�t	|�S)Nr�)r)r�itemsize�	frombytesr)rc�arr�idxs   rrFrF�sJ��@�
�+�+�c�
�C�

�c�(�S��X����,�
,�C��M�M�#�d�s�)���c�?�r c�8�eZdZeZdZd�Zd�Zd�Zd�Zd�Z	d�Z
y)	�CTextIOWrapperTest�$LookupError: unknown encoding: asciic�x�|jd�}|j|d�}|j|d��}|jt|j
|dd��|jt|j�|jj|j�}|jtt|�y)Nrrsrr-r�rG)
r:r2rFr�r�rHrsr>rwr�rs    rr�z&CTextIOWrapperTest.test_initialization�s����L�L��)������4�(�����q�7��3�����*�a�j�j�!�g�w��W����*�a�f�f�-����&�&�t�'9�'9�:�����)�T�1�-r c�H�tjdtf�5|jtj
d�}|j
|�}|j|d��}|jd�||_	tj|�}~tj�ddd�|j�|�|jtj
d�5}|j!|j#�d�ddd�y#1swY�jxYw#1swYyxYw)Nr�rrDr-�456defrs456def)rr�r�r&rr�r6rFrMr$r�r�rr�r�r/r�rs)r;rr(rr�r2s      rr�z*CTextIOWrapperTest.test_garbage_collection�s����
+�
+�R��,A�
B��K�K�	� 0� 0�$�7�E��#�#�E�*�A��"�"�1�w�"�7�A�
�G�G�H���A�C����Q��B����� �C�	
���"�$��#�
�Y�Y�y�'�'��
.�!����Q�V�V�X�y�1�/�
.�C�
B��/�
.�s�BD�"!D�D�D!c�l�td�D]�}|j|j�|j��}|j|d��}|j|j�|j��}|j|d��}||_||_��tj�y)NrsrDr-)r�r=rorF�buddyrr�)r;r��b1�t1�b2�t2s      r�!test_rwpair_cleared_before_textioz4CTextIOWrapperTest.test_rwpair_cleared_before_textio�s����t��A��$�$�T�^�^�%5�t�~�~�7G�H�B��#�#�B��#�9�B��$�$�T�^�^�%5�t�~�~�7G�H�B��#�#�B��#�9�B��B�H��B�H��	���r c��|j|j�d��}|jt�5|`ddd�y#1swYyxYwr�)rFr:r�r�r1rs  r� test_del__CHUNK_SIZE_SystemErrorz3CTextIOWrapperTest.test_del__CHUNK_SIZE_SystemError�s<�����t�|�|�~���@��
�
�
�~�
.��
�/�
.�
.�s�A�Ac�J��d�G�fd�d|j�}|�}|j|d��}|j�|jd�|jd�|j	g|j
�|j
t�5|jd�d	zz�ddd�|j	d
g|j
�|jd�|jd�z�|j	d
dd
�zg|j
�y#1swY�nxYw)Nr*c�"���eZdZ��fd�Z�xZS)�<CTextIOWrapperTest.test_internal_buffer_size.<locals>.MockIOc�J��t|��kDrt�t�|�
|�SrJ)rr�r~rM)r;rrr�s  ��rrMzBCTextIOWrapperTest.test_internal_buffer_size.<locals>.MockIO.write�s$����t�9�z�)�&�&��w�}�T�*�*r )r#r$r%rMr�)rr�s@�r�MockIOr��s
���
+�
+r r�rDr-r�r�r$r9r��ghir�r)rorFr1rMr�rDr�r�)r;r�rcrr�s    @r�test_internal_buffer_sizez,CTextIOWrapperTest.test_internal_buffer_size�s�����
�	+�T�^�^�	+��h�����s�W��5���]�]�
�	�����	���������S�-�-�.�
�
�
�|�
,�
�G�G�C��A��&�'�-�	
���)��c�&6�&6�7�	�����	����J������)�V�T�*�_�=�s�?O�?O�P�
-�
,�s�D�D"c�8��d}G�fd�d|j�}|�}|j|���jd��jd��jd|z��j�|j	ddd	|zg|j
�y)
Nr*c�&���eZdZdZ��fd�Z�xZS)�3CTextIOWrapperTest.test_issue119506.<locals>.MockIOFc�j��|jsd|_�jd�t�|�|�S)NT�middle)r�rMr~)r;rrrs  ��rrMz9CTextIOWrapperTest.test_issue119506.<locals>.MockIO.write�s,����|�|�#'�D�L��G�G�H�%��w�}�T�*�*r )r#r$r%r�rMr�)rrs@�rr�r��s����G�
+�
+r r�r�r��gr�smiddler)rorFrMr�r�rD)r;r�r�rcrs    @r�test_issue119506z#CTextIOWrapperTest.test_issue119506�s�����
�	+�T�^�^�	+��h�����s�#��	�����	�����	����j� �!�	���	����)�Y��Z��@��)�)�	+r N)r#r$r%r�r<r�r�r�r�r�r�r&r rr�r��s+��	�B�;�N�.�2�"��
Q�6+r r�c��eZdZeZdZy)�PyTextIOWrapperTestr�N)r#r$r%r�r�r<r&r rr�r��s��	
�B�;�Nr r�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�IncrementalNewlineDecoderTestc� �����fd�}|dd�|dd�|dd�|dd�|dd�|dd�|dd�|dd��jt�jdd	�
��j�|dd�|d
d�|ddd	�
�|d
dd	�
�|d
d�|dd�|dd�|d
d�|d
d�|dd�|dd�|dd�|dd�|dd�|dd�y)Nc�����j�}�j�j|fi|��|��j|��j�j|fi|��|�yrJ)r�r�r�r�)r(r�r�r��decoderr;s    ��r�
_check_decodezPIncrementalNewlineDecoderTest.check_newline_decoding_utf8.<locals>._check_decodes_����$�$�&�E����^�W�^�^�A�8��8�!�<����U�#����^�W�^�^�A�8��8�!�<r s袈u袈��r�����r T)r�r�r#r_rDz
a�

z

s
as袈
r�s袈
)r��UnicodeDecodeErrorr�r�)r;r�r�s`` r�check_newline_decoding_utf8z9IncrementalNewlineDecoderTest.check_newline_decoding_utf8s���	=�	�o�x�0��g�r�"��g�r�"��g�x�(��g�r�"��g�r�"��g�x�(��g�r�"����,�g�n�n�c���N��
�
���e�T�"��e�R� ��c�4�t�,��e�T��.��e�R� ��d�E�"��i��(��e�R� ��e�T�"��f�e�$��)�:�6��o�x�0��e�T�"��'��2��e�T�"r c������g�|�"tj|������fd�}nd���fd�}|j�jd�|d�|j�jd�|d�|j�jd�|d�|j�jd�|d�|j�jd	�|d�|jd
j	��d��j�d}��!�j��j
|�}|j�j|�d�|j�jd�y)Nc����j|�D],}�j�jt|g����.yrJ)r�rKr�r)r�r(r��encoderrns  ���r�_decode_bytewisezNIncrementalNewlineDecoderTest.check_newline_decoding.<locals>._decode_bytewise/s1��� ����*�A��M�M�'�.�.���s��"<�=�+r c�T��|D]"}�j�j|���$yrJ)rKr�)r�r�r�rns  ��rr�zNIncrementalNewlineDecoderTest.check_newline_decoding.<locals>._decode_bytewise5s"����A��M�M�'�.�.��"3�4�r zabc

r#z
abc)r#rzabc
r�)rKr#rr�zabc

abcabc
abcabc)r��getincrementalencoderr��newlinesr�r�r�r�)r;r�r.r�r�r�rns `   @@r�check_newline_decodingz4IncrementalNewlineDecoderTest.check_newline_decoding+s@�������<�f�2�2�8�<�>�G�
>�
�G�
5�	
����)�)�4�0���#�����)�)�4�0���!�����)�)�>�:���!�����)�)�>�:��������)�)�+?�@���!���������*A�B��
�
�������M�M�O��N�N�5�)�E��������.��6�����)�)�4�0r c�Z�d}|D]E}|xrtj|��}|j|d��}|j||��Gtjd��}|j|d��}|j	|�|jt|jd�y)N)	Nrr,rLrMrNrOrPrQT��	translaterrT)r��getincrementaldecoderr�r�r�r�r�r�)r;rUr�r�s    r�test_newline_decoderz2IncrementalNewlineDecoderTest.test_newline_decoderLs���
�	��C��A�?�f�:�:�3�?�A�G��4�4�W��4�M�G��'�'���5��8�&�.�.�w�7�9���0�0��D�0�I���(�(��1����)�W�%5�%5�r�:r c�|���fd�}�jdd��}||��jdd��}||�y)Nc�2���j|jd��j|jd�d��j|jd��j|jd�d��j|jd�y)Nuഀu਀)r�r�r�)�decr;s �r�_checkz@IncrementalNewlineDecoderTest.test_newline_bytes.<locals>._check_sq������S�\�\�4�0����S�Z�Z��1�8�<����S�\�\�4�0����S�Z�Z��1�8�<����S�\�\�4�0r Fr�T)r�)r;r�r�s`  r�test_newline_bytesz0IncrementalNewlineDecoderTest.test_newline_bytes]sB���	1��,�,�T�U�,�C���s���,�,�T�T�,�B���s�r c�(�dD]?}tjd��}|j||�}|j|��Atjd��}|j|d��}|j	|jd�d�y)N)r0r�r9r}rrr�r�z

)r�r�r�r�r�r�)r;r�r�s   r�test_translatez,IncrementalNewlineDecoderTest.test_translatejs���'�I�;�f�2�2�7�;�=�G��4�4�W�i�H�G��,�,�W�5�(�8�&�.�.�w�7�9���0�0��A�0�F��������	�2�H�=r N)r#r$r%r�r�r�r�r�r&r rr�r��s��(#�T1�B;�"�>r r�c�0�eZdZejd��Zy)�CIncrementalNewlineDecoderTestc�R�|jj|j�}|jt|jd�|jt|j
�|jt|jd�|jt|j�y)N�bar)r%r)r�r>r�r�r�r�r�r�)r;�
uninitializeds  rr?z1CIncrementalNewlineDecoderTest.test_uninitializedus}���6�6�>�>��*�*�,�
����*�m�&:�&:�F�C����*�m�&<�&<�=����*�m�&<�&<�k�J����*�m�&9�&9�:r N)r#r$r%rr3r?r&r rr�r�ts�����;��;r r�c��eZdZy)�PyIncrementalNewlineDecoderTestNr"r&r rr�r�rkr r�c�V�eZdZdZdZdZd�Zd�Zd�Zd�Z	e
jejd�e
jeed�d	�d
���Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Ze
jeed�d	�d��Zd�Ze
jejd�d��Ze
jejd�d��Ze
jeed�d�e
jeed�d	�d���Zd�Z d�Z!d�Z"d�Z#d�Z$d �Z%y)!�
MiscIOTestNr&c�J�tjtj�yrJr�r:s rr�zMiscIOTest.tearDown�r�r c��tj||j|j|j|j
��y)N)�extra�not_exported)r�check__all__r��name_of_module�extra_exportedr�r:s r�test___all__zMiscIOTest.test___all__�s2�����T�4�7�7�D�,?�,?�#'�#6�#6�*.�*;�*;�	=r c��|jtjdd��}|j|jd�|j�|jtjdd��}|j|jd�|j|jjd�|j|jjjd�|j|j�dd�	�}|j|jd�|j|jjd�|j|j|j��|j|jj|j��|j�|j�y)
Nrrrr�rr-rrFr�)
r/rr�r�rr�r�r�rUr5)r;r2r�s   r�test_attributeszMiscIOTest.test_attributes�s-���I�I�i�&�&���I�:���������&�	���	��I�I�i�&�&��w�I�?��������D�1���������E�2���������*�*�E�2��I�I�a�h�h�j�$��I�6��������T�*���������T�*�������Q�X�X�Z�0���������Q�X�X�Z�0�	���	�	���	r c���dD]e}|jt�5}|jtj|�ddd�|jdt
j���gy#1swY�1xYw)N)�U�rUzr+Uzinvalid mode)r�r�r/rr�rr'r()r;rr*s   r�test_removed_u_modezMiscIOTest.test_removed_u_mode�sS��&�D��"�"�:�.�"��	�	�)�*�*�D�1�/��M�M�.�#�b�l�l�*;�<�'�.�.�s�!A,�,A5	r r!r"c�6�tj�\}}|jtj|�|j	|dd��}|j|j�t
jdk7r |j|j��yy)Nr�rr-r�)	r%r!r,r�r/rZr[r�rY)r;r+rr2s    r�test_open_pipe_with_appendz%MiscIOTest.test_open_pipe_with_append�sp���w�w�y���1�������!�$��I�I�a��w�I�/�������� ��<�<�7�"����Q�Z�Z�\�*�#r c��ddiddiddd�ddd�ddd�ddidd	iddd�ddd�d	dd�dd
iddid
dd�d
dd�ddd�fD�]}d|dvrd
|d<|jtjfi|��}|j�|j	t
|j�|j	t
|j�|j	t
|j�|j	t
|j�t|d�r!|j	t
|jd�|j	t
|j�t|d�rA|j	t
|jd�|j	t
|j�t|d�r |j	t
|j�t|d�r*|j	t
|jt!d��t|d�r*|j	t
|j"t!d��|j	t
|j$�|j	t
|j&�|j	t
|j&d�|j	t
|j(d�|j	t
|j*�|j	t
|j,�|j	t
|j.d|dvrdnd�|j	t
|j0g�|j	t
t2|���y)Nrrrr9�rrr}rr+rr�r�r(rr.rPrQr7rerfrr r�)r/rr�r�r�r�r�rUre�__iter__rrPrsrQrerfr�rrr�r]r`rhrMrr~)r;r�r2s   r�test_io_after_closezMiscIOTest.test_io_after_close�s�����
�����1�-��1�-��A�.���
�����1�-��1�-��A�.��������A�.��A�.��Q�/��F�"�&��.�(�%,��z�"���	�	�)�*�*�5�f�5�A�
�G�G�I����j�!�'�'�2����j�!�(�(�3����j�!�(�(�3����j�!�*�*�5��q�&�!��!�!�*�a�f�f�a�8����j�!�&�&�1��q�'�"��!�!�*�a�g�g�t�<��!�!�*�a�g�g�6��q�)�$��!�!�*�a�i�i�8��q�*�%��!�!�*�a�j�j�)�D�/�J��q�+�&��!�!�*�a�k�k�9�T�?�K����j�!�*�*�5����j�!�+�+�6����j�!�+�+�q�9����j�!�&�&�!�4����j�!�&�&�1����j�!�*�*�5����j�!�'�'�%(�F�6�N�%:�c��
D����j�!�,�,��;����j�$��2�]r c��Gd�dt�}|d�}|jd|�}||_||_t	j
|�}~~t
j�|j|�|�y)Nc��eZdZy)�*MiscIOTest.test_blockingioerror.<locals>.CNr"r&r r�Cr��s��r r�r�r9)	r'r�r(r�r�r�rr�r�)r;r�r�r(r�s     r�test_blockingioerrorzMiscIOTest.test_blockingioerror�sg��	��	�
�b�E��� � ��A�&��������
�[�[��^��
�q��������"�$��#r c�T�|j|jtj�|j|jtj�|j|j
tj�|j|jtj�yrJ)rr|r��ABCMetarXrBrWr:s r�	test_abcszMiscIOTest.test_abcs�sd�����d�k�k�3�;�;�7����d�n�n�c�k�k�:����d�1�1�3�;�;�?����d�o�o�s�{�{�;r c���|jtjdd��5}|j||j�|j||j
�|j
||j�|j
||j�ddd�|jtjd�5}|j||j�|j
||j
�|j||j�|j
||j�ddd�|jtjdd��5}|j||j�|j
||j
�|j
||j�|j||j�ddd�y#1swY��?xYw#1swY��xYw#1swYyxYw�Nrrrrrr-)	r/rr�rr|rX�assertNotIsInstancerBrW)r;�	abcmoduler2s   r�_check_abc_inheritancez!MiscIOTest._check_abc_inheritances���
�Y�Y�y�'�'���Y�
;�q��!�!�!�Y�%5�%5�6��!�!�!�Y�%8�%8�9��$�$�Q�	�(@�(@�A��$�$�Q�	�(<�(<�=�	<�
�Y�Y�y�'�'��
.�!��!�!�!�Y�%5�%5�6��$�$�Q�	�(;�(;�<��!�!�!�Y�%=�%=�>��$�$�Q�	�(<�(<�=�	/�
�Y�Y�y�'�'��w�Y�
?�1��!�!�!�Y�%5�%5�6��$�$�Q�	�(;�(;�<��$�$�Q�	�(@�(@�A��!�!�!�Y�%9�%9�:�	@�
?�<�
;��
/�
.��
@�
?�s&�A1G�<A1G�A1G*�G�G'�*G3c�&�|j|�yrJ)r�r:s r�test_abc_inheritancezMiscIOTest.test_abc_inheritances���#�#�D�)r c�.�|jt�yrJ)r�r�r:s r�test_abc_inheritance_officialz(MiscIOTest.test_abc_inheritance_officials��	
�#�#�B�'r c��t|i|��}t|�}|jt�5}d}t	j
�ddd�|j
|tjjd��y#1swY�<xYwrA)
r/r��assertWarnsr�rr�rr'�warningr�)r;r�r�r2r+r*s      r�_check_warn_on_deallocz!MiscIOTest._check_warn_on_deallocsk���$�!�&�!����G��
�
�
�o�
.�"��A���� �/�	
�
�
�a��R�Z�Z�_�_�Q�/�0�1�/�
.�s�A>�>Bc���|jtjdd��|jtjd�|jtjdd��yr�)r�rr�r:s r�test_warn_on_dealloczMiscIOTest.test_warn_on_dealloc#sN���#�#�I�$4�$4�d�a�#�H��#�#�I�$4�$4�d�;��#�#�I�$4�$4�c�G�#�Lr c�P��g��fd�}|j|�tj�\}}�||fz
�|j|g|��i|��tj�\}}�||fz
�t	j
|�5t
|g|��ddi|��ddd�y#1swYyxYw)Nc����D]}	tj|��y#t$r(}|jtjk7r�Yd}~�Hd}~wwxYwrJ)r%r�r�r7r8)rrx�fdss  �r�cleanup_fdsz9MiscIOTest._check_warn_on_dealloc_fd.<locals>.cleanup_fds*sG�������H�H�R�L������w�w�%�+�+�-��.���s� �	A�A�Ar�F)r,r%r!r�rrBr/)r;r�r�r�r+rr�s      @r�_check_warn_on_dealloc_fdz$MiscIOTest._check_warn_on_dealloc_fd(s������	�	
����$��w�w�y���1��q�!�t���#��#�#�A�7��7��7��w�w�y���1��q�!�t���
�
6�
6�t�
<���3�T�3�5�3�F�3�=�
<�
<�s�B�B%c�r�|jdd��|jd�|jdd��y)Nrrrr+rr-)r�r:s r�test_warn_on_dealloc_fdz"MiscIOTest.test_warn_on_dealloc_fd;s6���&�&�t�q�&�9��&�&�t�,��&�&�s�W�&�=r c���d}ddiddiddd�ddiddiddd�dd	idd
id
dd�f	D]�}d|dvrd|d
<ttjdz�D]}}|j||��5|jt
jfi|��5}|jt|�5tj||�ddd�ddd�ddd����y#1swY�xYw#1swY�"xYw#1swY��xYw)Nz
cannot picklerrrrr�r+rr�r�r(rr.r9)�protocolr�)
r��pickle�HIGHEST_PROTOCOLrUr/rr�r^r��dumps)r;r�r�r�r2s     r�
test_picklingzMiscIOTest.test_picklingBs������
�����A�.���
�����A�.��������Q�/�
�F��&��.�(�%,��z�"�!�&�"9�"9�A�"=�>���\�\�8�F�\�C�"����9�#3�#3�>�v�>�!�!�3�3�I�s�C�"�L�L��H�5�D�?�D�C�?�
� D�C��?�>��D�C�s<�$"C)�C	�C�4C	�<C)�C�C	�C&
�"C)�)C2c�&�|jd�y)Ni@��_test_nonblock_pipe_writer:s r�test_nonblock_pipe_write_bigbufz*MiscIOTest.test_nonblock_pipe_write_bigbufXs��	
�&�&�w�/r c�&�|jd�y)Nr7rr:s r�!test_nonblock_pipe_write_smallbufz,MiscIOTest.test_nonblock_pipe_write_smallbuf^s��	
�&�&�t�,r �set_blockingz(os.set_blocking() required for this testc���g}g}tj�\}}tj|d�tj|d�|j|dd|��}|j|dd|��}|5|5dD]B}	d}		t	|	dzd	zg�|z}
|j|
�|j
|
�|	d
z
}	�=		|j�	|t|jd�z
}ddd�ddd�dj!|�dj!|�}}|j||�|j#|j$�|j#|j$�y#|j$r�}|j|jdtj�|j|jd|j�|dd|j|d<|j|j��d
}
|j
|
�|j|
�Yd}~���d}~wwxYw#|j$r�}|j|jdtj�|j|jd|j�|j|jd�|j|j��Yd}~nd}~wwxYw�� #1swY���xYw#1swY���xYw)NFrT)rr�rr)r��Ii�r��ar9r}r�sBLOCKEDr )r%r!r	r/rrKrMr�r�r�r7�EAGAINr�rsr��iterr�r�r�)r;r��sent�receivedr+r�rf�wfr�r�r�rxs            rrz$MiscIOTest._test_nonblock_pipe_writedsm�������w�w�y���1�
����5�!�
����5�!��Y�Y�q�t�T�W�Y�
E��
�Y�Y�q�t�T�W�Y�
E��
��#��%��A��#�Q��V�b�[�M�2�Q�6�����C�(�����
��Q���	�$�$�/��H�H�J��
��R�W�W�d�+�+�H�;�R�>���$�����(�);�h������x�(�����	�	�"�����	�	�"��1�+�+�%��$�$�Q�V�V�A�Y����=��$�$�Q�V�V�A�Y��0D�0D�E�#�B�x�(=��)=�)=�>�D��H��O�O�B�G�G�I�.�$�C��H�H�S�M��K�K��$�$��%���+�+�/��$�$�Q�V�V�A�Y����=��$�$�Q�V�V�A�Y��0D�0D�E��$�$�Q�%9�%9�1�=��O�O�B�G�G�I�.�.��	/��	�'���R�R�s{�4K-�7K �>AE&�>K �H1�K �+K-�&H.	�5B.H)	�#K �)H.	�.K �1K�BK�K �K�K � K*	�%K-�-K7c���|jtjdd��5	ddd�|jt|jtjdd��y#1swY�<xYw)Nrrr-r$)r/rr�r��FileExistsErrorr:s r�test_create_failzMiscIOTest.test_create_fail�sQ��
�Y�Y�y�'�'��w�Y�
?��@����/�4�9�9�i�6F�6F��V]��^�@�
?�s�A � A)c�:�|jtjd�5}|jd�ddd�|jtjd�5}|j	d|j��ddd�y#1swY�SxYw#1swYyxYw)N�xbrrr�rs  r�test_create_writeszMiscIOTest.test_create_writes�sm��
�Y�Y�y�'�'��
.�!�
�G�G�G��/�
�Y�Y�y�'�'��
.�!����W�a�f�f�h�/�/�
.�/�
.��
.�
.�r�c�h�|jt|jtjdd��y)Nzrwax+rr-r�r:s r�test_open_allargszMiscIOTest.test_open_allargs�s&�����*�d�i�i��1A�1A�7�U\��]r c���|jj}t}d}tjd|�d|�d|�d|�d|�d|�d|�d	|�d
��}tddd
|�}|j
|jd|�y)NzBoom, Shaka Laka, Boom!z)
            import sys
            from zC import open, TextIOWrapper

            try:
                open(z, encoding=z�)
            except LookupError:
                pass
            else:
                sys.exit(21)

            try:
                open(z	, errors=z})
            except LookupError:
                pass
            else:
                sys.exit(22)

            fp = open(za, "rb")
            with fp:
                try:
                    TextIOWrapper(fp, encoding=z�)
                except LookupError:
                    pass
                else:
                    sys.exit(23)

                try:
                    TextIOWrapper(fp, errors=z�)
                except LookupError:
                    pass
                else:
                    sys.exit(24)

            sys.exit(10)
        �-X�devr7r)r�r#r0�textwrap�dedentr	r�r?)r;�modr�rFr8�procs      r�test_check_encoding_errorsz%MiscIOTest.test_check_encoding_errors�s����g�g������+�����$�����\��W�K�8��\��7�+�6� �l�#0�18�{�;.�/6�[�9	�9# �#
��H%�T�5�$��=��������"�d�+r c	��|jj}t}tjd|�d|�d|�d��}tddd|�}|jj�}|jt|�d�|j|d	jd
��|j|djd��y)
Nz(            import sys
            from zN import open, TextIOWrapper
            import pathlib

            with open(zJ) as f:           # line 5
                pass

            pathlib.Path(z ).read_text()  # line 8
        r�warn_default_encodingr7r}rs<string>:5: EncodingWarning: r9s<string>:8: EncodingWarning: )r�r#r0rr rrrcr�rr�r\)r;r!r�r8r"rcs      r�test_check_encoding_warningz&MiscIOTest.test_check_encoding_warning�s����g�g���������$���� �l�#�#��&	�	 �	
�� ��&=�t�T�J���8�8�&�&�(������X���*�����Q�K�"�"�#C�D�	F�����Q�K�"�"�#C�D�	Fr c���d}tddd|�}|jd|jj��tddd|�}|jd|jj��y)Nz(import io; print(io.text_encoding(None))rzutf8=0r7slocalezutf8=1sutf-8)rr�r@r=)r;r8r"s   r�test_text_encodingzMiscIOTest.test_text_encoding�s_��:����h��d�;������D�H�H�N�N�$4�5���h��d�;������4�8�8�>�>�#3�4r )&r#r$r%r�r�r�r�r�r�r�r�r�rr�r�rr%r�r�r�r�r�r�r�r�r�r�r�rrrrrrrr#r&r(r&r rr�r��s����N��N��L�+�=�
�$=��X�_�_����F���X�����V�,�.B�C�	+�D��	+�/3�b$�<�;�"*�(�
2�M�
4�&�X�����V�,�.B�C�>�D�>�6�,�X�_�_����F��0��0��X�_�_����F��-��-��X�����^�4�C�E��X�����V�,�.B�C�0#�D�E�0#�d_�0�^�+,�ZF�.	5r r�c���eZdZeZdZdZd�Zd�Zej�e
jd�d���Zej�e
jd�d���Z
y)	�CMiscIOTest)r�r�)r�c��Gd�d|jj�}|�}td�}|jt|j
|�y)Nc��eZdZdd�Zy)�<CMiscIOTest.test_readinto_buffer_overflow.<locals>.BadReaderc��ddzS)Nri@Br&rrs  rrszACMiscIOTest.test_readinto_buffer_overflow.<locals>.BadReader.reads���e�|�#r Nr�rtr&r r�	BadReaderr-s��
$r r/r})r�rBr�r�r�rf)r;r/r�r(s    r�test_readinto_buffer_overflowz)CMiscIOTest.test_readinto_buffer_overflow�s@��	$����.�.�	$�����a�L�����*�e�n�n�a�8r c�>�djt��}td|�\}}|jj	�}|j
dk7r,djt��}|j
||�y|j|jd��y)Na�if 1:
            import sys
            import time
            import threading
            from test.support import SuppressCrashReport

            file = sys.{stream_name}

            def run():
                while True:
                    file.write('.')
                    file.flush()

            crash = SuppressCrashReport()
            crash.__enter__()
            # don't call __exit__(): the crash occurs at Python shutdown

            thread = threading.Thread(target=run)
            thread.daemon = True
            thread.start()

            time.sleep(0.5)
            file.write('!')
            file.flush()
            r7rz�Fatal Python error: _enter_buffered_busy: could not acquire lock for <(_io\.)?BufferedWriter name='<{stream_name}>'> at interpreter shutdown, possibly due to daemon threadsz.!)	�
format_map�localsr
rr�r?r�r�r=)r;�stream_namer8r�r�r�patterns       r�&check_daemon_threads_shutdown_deadlockz2CMiscIOTest.check_daemon_threads_shutdown_deadlocks����0�
�6�8�$�1	
�2&�d�D�1���Q��g�g�n�n����6�6�Q�;�)�*4��F�H�)=�	
�

���S�'�*����S�Y�Y�t�_�-r �walltimec�&�|jd�y)N�stdout�r6r:s r�,test_daemon_threads_shutdown_stdout_deadlockz8CMiscIOTest.test_daemon_threads_shutdown_stdout_deadlock1���	
�3�3�H�=r c�&�|jd�y)N�stderrr:r:s r�,test_daemon_threads_shutdown_stderr_deadlockz8CMiscIOTest.test_daemon_threads_shutdown_stderr_deadlock6r<r N)r#r$r%r�r�r�r0r6r
r�rr�r;r?r&r rr*r*�s���	�B� �N�'�N�9�'.�R1��0�0�2��W���z�*�>�+�3�>�1��0�0�2��W���z�*�>�+�3�>r r*c��eZdZeZdZdZdZy)�PyMiscIOTest)�_pyior�)r��	open_code)�valid_seek_flagsN)r#r$r%r�r�r�r�r�r&r rrArA<s��	
�B�"�N�4�N�&�Lr rA�ntz%POSIX signals required for this test.c�:�eZdZd�Zd�Zd�Zd�Zeeje
ed�d�d���Zeeje
ed�d�d���Z
eeje
ed�d�d	���Zej d
��Zed��Zed��Zd
�Zeej*d�d���Zeej*d�d���Zd�Zeej*d�d���Zeej*d�d���Zy)�SignalsTestc�j�tjtj|j�|_yrJ)�signal�SIGALRM�alarm_interrupt�oldalrmr:s rr�zSignalsTest.setUpFs���}�}�V�^�^�T�5I�5I�J��r c�`�tjtj|j�yrJ)rIrJrLr:s rr�zSignalsTest.tearDownIs���
�
�f�n�n�d�l�l�3r c��ddzyr8r&)r;�sig�frames   rrKzSignalsTest.alarm_interruptLr=r c��
��	tj�g��
�fd�}tj|��}d|_tj�\�
}d|d<|tjt|�zdzz}	|jj|fi|��}ttd�rwtjtjtjg�|j!�tjtj"tjg�n|j!�tj$d�	|j't(|j*|�tj$d�|j-��j/tj0�
d��|j3�|dd|dd	g�tj4|�tj4�
�	|j5�y#tj$d�|j-�wxYw#t6$r(}	|	j8t8j:k7r�Yd}	~	yd}	~	wwxYw#tj4|�tj4�
�	j5�w#t6$r(}	|	j8t8j:k7r�Yd}	~	wd}	~	wwxYwxYw)
Nc�T��tj�d�}�j|�yr�)r%rsrK)r�r+�read_resultss ��rr�z2SignalsTest.check_interrupted_write.<locals>._readms �������1�
�A�����"r r{TFr�r9�pthread_sigmaskrr})rr�r�r-�daemonr%r!�
PIPE_MAX_SIZErr�r/rrIrT�	SIG_BLOCKrJr.�SIG_UNBLOCKr4r�r�rMr�rKrsr�r�r�r7r8)r;�itemr�
fdopen_kwargsr�rr�
large_data�wiorxr+rSs          @@r�check_interrupted_writez#SignalsTest.check_interrupted_writeOs���	�4	������	#�
���E�*������w�w�y���1�#(�
�i� ��W�2�2�c�$�i�?�!�C�D�
�$	��$�'�'�,�,�q�2�M�2�C��v�0�1��&�&�v�'7�'7�&�.�.�9I�J����	��&�&�v�'9�'9�F�N�N�;K�L����	�
�L�L��O�
��!�!�"3�S�Y�Y�
�K����Q������
�������1�
�.����\�E�!�A�J��a��
�+C�D��H�H�Q�K��H�H�Q�K�
��	�	������Q��������
��7�7�e�k�k�)��*��
��
�H�H�Q�K��H�H�Q�K�
��	�	����
��7�7�e�k�k�)��*��
�sh�<C	I%�!H�'A$I%�6H1�'H.�.I%�1	I"�:I�I"�%+K�J"�!K�"	K�+K�	K�K�Kr!r"c�.�|jdddd��y)Nrrrrr��r]r:s r�!test_interrupted_write_unbufferedz-SignalsTest.test_interrupted_write_unbuffered�s��	
�$�$�U�E���$�Jr c�,�|jddd��y�Nrrr�rr_r:s r�test_interrupted_write_bufferedz+SignalsTest.test_interrupted_write_buffered�s��	
�$�$�U�E��$�=r c�.�|jdddd��y)N�xyrrrrD�rr.r_r:s r�test_interrupted_write_textz'SignalsTest.test_interrupted_write_text�s��	
�$�$�T�5�s�W�$�Mr c�z��	���	fd�}tjtj|�tj�\}}|jj
|fi|���		tjd�|jttf�5}	td�D]#}�	j���	j��%tj|t��dz��T#1swYnxYwj}t!|t�r3|j#t%|�j'd�t%|��tjd��	j)�tj(|�y#tjd��	j)�tj(|�wxYw)Nc�2���j��ddzyr8)rM)r�rr\s ��r�on_alarmz3SignalsTest.check_reentrant_write.<locals>.on_alarm�s����I�I�d�O�
�a�Cr r9r)zreentrant callr)rIrJr%r!r�r/r4r�r�r�r�rMr�rsrr(rVr�r'r\r�)
r;rrZrkr+rr*r�rr\s
 `       @r�check_reentrant_writez!SignalsTest.check_reentrant_write�s1���	�	�
�
�f�n�n�h�/��w�w�y���1��d�g�g�l�l�1�.�
�.��	��L�L��O��"�"�$5�|�#D�E���"�3�Z���	�	�$���	�	��(��G�G�A�s�4�y�3��/��F�E���,�,�C��#�|�,�����C�� 3� 3�4D� E�s�3�x�P��L�L��O��I�I�K��H�H�Q�K��
�L�L��O��I�I�K��H�H�Q�K�s �"0E>�AC(�(C1�-AE>�><F:c�*�|jdd��yrb�rlr:s r�test_reentrant_write_bufferedz)SignalsTest.test_reentrant_write_buffered�s���"�"�5�t�"�4r c�,�|jddd��y)NrfrrDrgrnr:s r�test_reentrant_write_textz%SignalsTest.test_reentrant_write_text�s���"�"�4�c�G�"�Dr c���	tj�\}�d|d<�fd�}tjtj|�	|jj
|fi|��}tj�d�tjd�|j||jd��d�tjd�|j�tj��tj|�y#tjd�j�tj��tj|�wxYw)	NFr�c�2��tj�d�y)Nr�)r%rM)rOrPrs  �r�
alarm_handlerz?SignalsTest.check_interrupted_read_retry.<locals>.alarm_handler�s����H�H�Q��r r%r9r��foobarr)r%r!rIrJr�r/rMr4r�rsr�)r;r�rZr+rt�riors      @r�check_interrupted_read_retryz(SignalsTest.check_interrupted_read_retry�s����	D��w�w�y���1�#(�
�i� �	 ��
�
�f�n�n�m�4�
	��$�'�'�,�,�q�2�M�2�C��H�H�Q����L�L��O�

���V�C�H�H�Q�K�0�(�;��L�L��O��I�I�K��H�H�Q�K��H�H�Q�K��
�L�L��O��I�I�K��H�H�Q�K��H�H�Q�K�s�	A/D�AEr7c�,�|jd�d��y)Nc�$�|jd�S)Nr�)r�rRs rr�zBSignalsTest.test_interrupted_read_retry_buffered.<locals>.<lambda>�s
��A�H�H�X�4Fr rrc�rwr:s r�$test_interrupted_read_retry_bufferedz0SignalsTest.test_interrupted_read_retry_buffered�s��	
�)�)�*F�/3�	*�	5r c�.�|jd�dd��y)Nc��|SrJr&rRs rr�z>SignalsTest.test_interrupted_read_retry_text.<locals>.<lambda>�s��Ar r+r�rgrzr:s r� test_interrupted_read_retry_textz,SignalsTest.test_interrupted_read_retry_text�s��	
�)�)�+�/2�X�	*�	Gr c�����
�����	tjd��tj}t	j
�\�
}d|d<g�d�d���
���fd�}t
j|���d�_�fd�}�fd��||z}tjtj|�	|jj|fi|��}tjd	�|j|�}	|j||	�|j!�d��j#�|j%��|j|t'd
��D���tjd�d�t	j(|�t	j(�
�	|j)�y#t*$r(}
|
j,t,j.k7r�Yd}
~
yd}
~
wwxYw#tjd�d�t	j(|�t	j(�
�	j)�w#t*$r(}
|
j,t,j.k7r�Yd}
~
wd}
~
wwxYwxYw)N�selectFr�c���	�s`��j�gggd�dvrBtj�d�}�j|���j�gggd�dvr�B�s�_yy#t$r}|�Yd}~yd}~wwxYw)Ng�?rr7)r�r%rsrK�
BaseException)r�r�errorr+rSr��write_finisheds  �����rr�z8SignalsTest.check_interrupted_write_retry.<locals>._reads����
�(��v�}�}�a�S�"�b�#�>�q�A�A��G�G�A�t�,��$�+�+�A�.��v�}�}�a�S�"�b�#�>�q�A�A�)��!�
����
�s�AA&�!A&�&	A;�/A6�6A;r{Tc�x��tjtj��tjd�yr�)rIrJr4)rOrP�alarm2s  �r�alarm1z9SignalsTest.check_interrupted_write_retry.<locals>.alarm1s ����M�M�&�.�.�&�1��L�L��Or c�&���j�yrJ)r.)rOrPrs  �rr�z9SignalsTest.check_interrupted_write_retry.<locals>.alarm2s���
�G�G�Ir r9c3�2K�|]}t|����y�wrJ)r)�.0r$s  r�	<genexpr>z<SignalsTest.check_interrupted_write_retry.<locals>.<genexpr>(s����#A�L�q�C��F�L�s�r)rr�rrVr%r!r�r-rUrIrJr�r/r4rMr�r�r�r��sumr�r�r7r8)r;rYrZr�rr�r�r[r\r�rxr�r�r+rSr�rr�s           @@@@@@@r�check_interrupted_write_retryz)SignalsTest.check_interrupted_write_retry�s����	D��,�,�X�6��
�!�!���w�w�y���1�#(�
�i� �
������	�	�
���E�*�����	�	��A�X�
��
�
�f�n�n�f�-�	��$�'�'�,�,�q�2�M�2�C��L�L��O��i�i�
�+�G����Q��(��I�I�K�!�N�
�F�F�H����e�$����Q��#A�L�#A� A�B��L�L��O�!�N��H�H�Q�K��H�H�Q�K�
��	�	����
��7�7�e�k�k�)��*��
��
�L�L��O�!�N��H�H�Q�K��H�H�Q�K�
��	�	����
��7�7�e�k�k�)��*��
�sP�*B*G�F'�'	G�0G�G�AI#�H/�.I#�/	I �8I�I#�I � I#c�*�|jdd��y)Nrrrc�r�r:s r�%test_interrupted_write_retry_bufferedz1SignalsTest.test_interrupted_write_retry_buffered7s��	
�*�*�4�d�*�;r c�,�|jddd��y)Nr$rr�rgr�r:s r�!test_interrupted_write_retry_textz-SignalsTest.test_interrupted_write_retry_text<s��	
�*�*�3�S�8�*�Lr N)r#r$r%r�r�rKr]�requires_alarmr�r�rr%r`rdrhrrxrlrorqrwr�r{r~r�r�r�r&r rrGrGCs���K�4��K�Z��X�����V�,�.B�C�K�D��K���X�����V�,�.B�C�>�D��>���X�����V�,�.B�C�N�D��N�
������6�5��5��E��E��0��W���z�*�5�+��5���W���z�*�G�+��G�B�H��W���z�*�<�+��<���W���z�*�M�+��Mr rGc��eZdZeZy)�CSignalsTestN)r#r$r%r�r&r rr�r�Bs��	�Br r�c��eZdZeZdZdZy)�
PySignalsTestN)r#r$r%r�r�rorqr&r rr�r�Es��	
�B�%)�!� $�r r�c���tttttt
ttttttttttt t"t$t&t(f}t*t,t.t0t2t4t6t8t:f	}t<j>}|D�cic]}|tAt<|���}}|D�cic]}|tAtB|���}}tE��|jG�fd�|D��|jG�fd�|D��|D]�}|jHjKd�r-|jM�D]\}}	tO|||	��d|_(�K|jHjKd�s�g|jM�D]\}}	tO|||	��d|_(��|jS�}
|D]"}|
jU|jW|���$|
Scc}wcc}w)Nc3�Z�K�|]"}|j�d|jzf���$y�w)r�N�r#�r�r$�globss  �rr�zload_tests.<locals>.<genexpr>ds)�����H�%�Q�A�J�J��c�A�J�J�&6� 7�8�%���(+c3�Z�K�|]"}|j�d|jzf���$y�w)�PyNr�r�s  �rr�zload_tests.<locals>.<genexpr>es)�����J�E�q�Q�Z�Z��t�a�j�j�'8�!9�:�E�r�r�Tr�F),r�r�r�r�r�rr rmror�r�r�r�r�r�r�r*rAr�r�r�rorzr�r�r�r�r?r�r�r��__all__rTr��globalsr6r#r\r��setattrr
�
suiteClass�addTest�loadTestsFromTestCase)�loaderr]r5�mocks�all_membersr5�c_io_ns�py_io_nsr^r�suiter�s           @r�
load_testsr�Ns����
�h��
 �"6�
 �"6�
 �"6�
 �"6�
+�
+�-L�
�!4�
�,�
�=�,�

�E����^�
!�#3�5I�
�4�
6�E��*�*�K�4?�@�K�D�t�g�b�$�'�'�K�G�@�7B�C�{�t��w�t�T�*�*�{�H�C��I�E��N�N�H�%�H�H��O�O�J�E�J�J����=�=�#�#�C�(�$�]�]�_�	��c���d�C�(�-��D�I�
�]�]�
%�
%�d�
+�%�^�^�-�	��c���d�C�(�.��D�I��
����E���
�
�
�f�2�2�4�8�9���L��%A��Cs�0G6�G;�__main__)~r�r)r7r2r%r�r~rIrZrr�r�r�rcr��collectionsrr�	itertoolsrrr^r�test.support.script_helperrr	r
�test.supportrrr
rr�test.support.os_helperrr�r�rBr�rr�	Structurer�ImportErrorrrrr�r3r�rr�r6r?rXrjrmrorvrxrzr�r�r�r�r�r�r�r�r�r:r�r�r�r�r�r�r�r�r�r�r��TestCaser�r�r3r�r�r�r�r'r5r�r�r�rr r"rmrorqr�r�r�r�r�r�r�rErFr�r�r�r�r�r�r*rAr�r5rGr�r�r�r#�mainr&r r�<module>r�sN��#�*���
�	�
�
�
�
�������'�"��C�C�&�"�)�(�*�+�
�	��
��
�
�f�&�&�
�
#�+�+�A�s�y�y�/A�/A���
%��$�$��F�G��<���
��6�6�p	�0�"�,�,�	�	�1�4�>�>�	��$��	��B�L�L�	�	�)�T�^�^�	��i��"	�����	�	�����	��Y��	�n�b�l�l�	�	�~�t�~�~�	��Y��	�n�b�l�l�	�	�~�t�~�~�	��� 	�*�b�j�j�	�	�:�t�|�|�	�8�8�3�(�"�*�*�3�5�)�4�<�<�5��j��	�6��
�
�	�	� 7����	�.�.�`)�0�"�,�,�)�+�1�4�>�>�+�
$�X�
�
�
$�D$�f�$�(	���VG�8�$�$�VG��VG�p	�v�	�	���h�h�'�'�h��h�j�j�Z5�5�,L6��*�*�,?�L6�^
AA�,�j�AA�H�-��d��*�*�,?�d�P	.6�,�j�.6�b�-��N��*�*�N�`�,���-��|&�+�-?�|&�~6�,�j�6�4�-��I��!:�!:�I�\;�)4�X�%6�%6�)4�Vp;��)�)�p;�f%2�R�Z�Z�2��a+�*�a+�H<�+�<�
s>�H�$5�$5�s>�j;�%B�;�	�&C�	�r5��"�"�r5�j?>�*�?>�D'�:�'��������D��"I�J�{M�(�#�#�{M�K�{M�|�;��%�K�%�%�N�z���H�M�M�O���}Y�3�3�3�s�T?�?U�
U

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists