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_gzip.cpython-312.pyc

�

'Μg����
�dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZddlm
Z
ddlmZmZmZddlmZmZej(d�Zej(d	�Zd
ZdZej2j5e
j6�dzZGd
�dej:�ZGd�dej>�Z Gd�de �Z!Gd�de �Z"d�Z#Gd�dej>�Z$e%dk(rejL�yy)z!Test script for the gzip module.
�N)�PIPE�Popen)�
import_helper)�	os_helper)�_4G�
bigmemtest�requires_subprocess)�assert_python_ok�assert_python_failure�gzip�zlibsy  int length=DEFAULTALLOC, err = Z_OK;
  PyObject *RetVal;
  int flushmode = Z_FINISH;
  unsigned long start_total_out;

s�/* zlibmodule.c -- gzip-compatible data compression */
/* See http://www.gzip.org/zlib/
/* See http://www.winimage.com/zLibDll for Windows */
z-gzdirc��eZdZd�Zd�Zd�Zy)�UnseekableIOc��y)NF���selfs �+/usr/local/lib/python3.12/test/test_gzip.py�seekablezUnseekableIO.seekable%s���c�"�tj��N��io�UnsupportedOperationrs r�tellzUnseekableIO.tell(����%�%�%rc�"�tj�rr)r�argss  r�seekzUnseekableIO.seek+rrN)�__name__�
__module__�__qualname__rrr rrrrr$s���&�&rrc�0�eZdZejZd�Zd�Zy)�BaseTestc�B�tj|j�yr�r�unlink�filenamers r�setUpzBaseTest.setUp2���������'rc�B�tj|j�yrr'rs r�tearDownzBaseTest.tearDown5r+rN)r!r"r#r�TESTFNr)r*r-rrrr%r%/s�����H�(�(rr%c�l�eZdZd:d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zee
d
��d��Zd
�Zd�Zd�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/�Z1d0�Z2d1�Z3d2�Z4d3�Z5d4�Z6d5�Z7d6�Z8d7�Z9d8�Z:y9);�TestGzipc��t|�}tj|jd|z�5}|j	|�}ddd�|jt
|��tj|jd|z�5}|j|j�|�ddd�y#1swY�qxYw#1swYyxYw)N�w�r)�bytesr�GzipFiler)�write�assertEqual�len�read)r�data�mode�b_data�f�ls      r�write_and_read_backzTestGzip.write_and_read_back:s����t���
�]�]�4�=�=�#�d�(�
3�q�����
�A�4�����C��K�(�
�]�]�4�=�=�#�d�(�
3�q����Q�V�V�X�v�.�4�
3�4�
3��4�
3�s�B1�!B=�1B:�=Cc��tj|jd�5}|jtdz�|j�|j
�ttd�r#tj|j
��|j�ddd�j�y#1swY�xYw)N�wb�2�fsync)rr5r)r6�data1�flush�fileno�hasattr�osrC�close�rr=s  r�
test_writezTestGzip.test_writeBsx��
�]�]�4�=�=�$�
/�1�
�G�G�E�B�J��
�G�G�I�
�H�H�J��r�7�#��������$�
�G�G�I�0�	
���	�0�
/�s�A<B6�6B?c��tj|j�}tj	|d�5}|jtdz�ddd�|jjt�|j|j|j�tj	|d�5}|jt�ddd�tj	|�5}|j�}ddd�|jtdz�|j|jt�|j|j|j�y#1swY��xYw#1swY��xYw#1swY��xYw)Nr2rB�a�3)r�FakePathr)rr5r6rD�assertIsInstance�name�strr7r9)rr)r=�ds    r�"test_write_read_with_pathlike_filez+TestGzip.test_write_read_with_pathlike_filePs����%�%�d�m�m�4��
�]�]�8�S�
)�Q�
�G�G�E�B�J��*����a�f�f�c�*����������/�
�]�]�8�S�
)�Q�
�G�G�E�N�*�
�]�]�8�
$������A�%�����E�B�J�'����a�f�f�c�*����������/�*�
)��*�
)��
$�
$�s#�E�3E,�&E8�E)�,E5�8Fc���|jttdz��ttt	d���}|jdgd���}|j|�y)NrB��B)�rX�)�shape)r?�
memoryviewrDr4�range�cast)r�mr:s   r�test_write_memoryviewzTestGzip.test_write_memoryviewasL��� � ��E�B�J�!7�8��u�U�3�Z�(�)���v�v�c��v�)��� � ��&rc�F�|jttdz��y)NrB)r?�	bytearrayrDrs r�test_write_bytearrayzTestGzip.test_write_bytearraygs��� � ��5�2�:�!6�7rc�\�|jtjdtdz��y)N�I�()r?�arrayrDrs r�test_write_arrayzTestGzip.test_write_arrayjs��� � ����S�%�"�*�!=�>rc�6�tj|jd�5}|jt�5|jd�ddd�|jt�5|jg�ddd�|jt�ddd�tj|jd�5}|j|j�t�ddd�y#1swY��xYw#1swY��xYw#1swY�oxYw#1swYyxYw)NrA��rb)	rr5r)�assertRaises�	TypeErrorr6rDr7r9rJs  r�test_write_incompatible_typez%TestGzip.test_write_incompatible_typems����]�]�4�=�=�$�
/�1��"�"�9�-������.��"�"�9�-������.�
�G�G�E�N�0��]�]�4�=�=�$�
/�1����Q�V�V�X�u�-�0�
/�.�-��-�-��0�
/��0�
/�sF�D�C+�	D�&C7�8D�=%D�+C4	�0D�7D	�<D�D�Dc���|j�tj|jd�5}|j	�}ddd�|jtdz�y#1swY�#xYw)Nr3rB)rKrr5r)r9r7rD�rr=rSs   r�	test_readzTestGzip.test_readzsM������
�]�]�4�=�=�#�
.�!�����A�/�����E�"�H�%�/�
.�s�A$�$A-c��|j�g}d}tj|jd�5}	|j	�}|sn@|j|�|t
|�z
}|j|j�|��S	ddd�|jdj|�tdz�y#1swY�2xYw)Nrr3rrB)rKrr5r)�read1�appendr8r7r�joinrD)r�blocks�nreadr=rSs     r�
test_read1zTestGzip.test_read1�s�����������
�]�]�4�=�=�#�
.�!���G�G�I�����
�
�a� ���Q����� � �����5�1���	/�	
������&�)�5�2�:�6�/�
.�s�AB<�<C�)�size�memusec���tjtd��}tjt	j
|�d��}|j
|j|�t�y)Nrx��
compresslevelrj��fileobjr;)r�compressrDr5r�BytesIOr7r9)rry�
compressedr=s    r�test_read_largezTestGzip.test_read_large�sI���]�]�5��]�:�
��M�M�"�*�*�Z�"8�t�M�D����������u�-rc�:�|j�tj|jd�}|j}|j|j�|j�|j|j�|jt�5|jd�ddd�|jt�5|jd�ddd�|jt�5|j�ddd�tj|jd�}|j}|j|j�|j�|j|j�|jt�5|jd�ddd�|jt�5|j�ddd�y#1swY��7xYw#1swY��xYw#1swY��xYw#1swY�^xYw#1swYyxYw)Nr3rxrr2r)rKrr5r)r�assertFalse�closedrI�
assertTruerk�
ValueErrorr9r rr6rE)rr=rs   r�test_io_on_closed_objectz!TestGzip.test_io_on_closed_object�s\��
	
�����M�M�$�-�-��-���)�)��������(�	���	�������'�
�
�
�z�
*�
�F�F�1�I�+�
�
�
�z�
*�
�F�F�1�I�+�
�
�
�z�
*�
�F�F�H�+�
�M�M�$�-�-��-���)�)��������(�	���	�������'�
�
�
�z�
*�
�G�G�C�L�+�
�
�
�z�
*�
�G�G�I�+�
*�+�
*��
*�
*��
*�
*��+�
*��
*�
*�s<�G�G,�6G9�H�H�G)�,G6�9H�H�Hc��|j�tj|jd�5}|j	t
dz�ddd�tj|jd�5}|j
�}ddd�|jtdzt
dzz�y#1swY�fxYw#1swY�9xYw)N�ab�rjrB)	rKrr5r)r6�data2r9r7rDros   r�test_appendzTestGzip.test_append�s�������
�]�]�4�=�=�$�
/�1�
�G�G�E�B�J��0��]�]�4�=�=�$�
/�1�����A�0�����U�2�X�%��(�3�4�0�
/��0�
/�s�B/�2B;�/B8�;Cc��tj|jdd�5}|jd�ddd�t	dd�D]=}tj|jdd�5}|jd�ddd��?tj|jd�5}d}	|jd	�}||z
}|sn�	ddd�|j
d
�y#1swY��xYw#1swY��xYw#1swY�4xYw)NrA�	�ar��r�rjri s�aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)rr5r)r6r\r9r7)rr=�i�zgfile�contents�ztxts      r�test_many_appendzTestGzip.test_many_append�s����]�]�4�=�=�$��
2�a�
�G�G�D�M�3��q�#��A����t�}�}�d�A�6�!�����
�7�6��
�]�]�4�=�=�$�
/�6��H���{�{�4�(���D� ���U��#�0�	
����8�,�3�
2��7�6��0�
/�s#�C"�,C.�(C:�"C+�.C7	�:Dc���tj|jd�5}|jtdz�ddd�tj|jd�5}|j|j
�tdz�ddd�|jt�5tj|jd�ddd�y#1swY��xYw#1swY�TxYw#1swYyxYw)N�xbrBrj)	rr5r)r6rDr7r9rk�FileExistsErrorrJs  r�test_exclusive_writezTestGzip.test_exclusive_write�s���
�]�]�4�=�=�$�
/�1�
�G�G�E�B�J��0�
�]�]�4�=�=�$�
/�1����Q�V�V�X�u�r�z�2�0�
�
�
��
/��M�M�$�-�-��.�0�
/�	0�
/��
/�
/��
/�
/�s#�C�"(C�'!C)�C�C&�)C2c�\�|j�tj|jd�5}t	j
|�5}|D�cgc]}|��}}ddd�ddd�|j
dtjd��z�ycc}w#1swY�@xYw#1swY�DxYw)NrjrBT��keepends)	rKrr5r)r�BufferedReaderr7rD�
splitlines)rr=r3�line�liness     r�test_buffered_readerzTestGzip.test_buffered_reader�s���	
����
�]�]�4�=�=�$�
/�1��"�"�1�%��*+�,�!�$��!��,�&�0�	
�����U�%5�%5�t�%5�%D� D�E��-�&�%��0�
/�s5�B"�B�	B�B�B"�B�B	�B"�"B+c��|j�tj|jd�5}d}	|j	|�}|s|dk7rn&|jt
|�|k�|dzdz}�?	ddd�y#1swYyxYw)NrjrrxrB)rKrr5r)�readliner�r8)rr=�line_length�Ls    r�
test_readlinezTestGzip.test_readline�s{�������]�]�4�=�=�$�
/�1��K���J�J�{�+���[�A�-�u�����A��+� 5�6�*�Q��"�4��	�/4�	0�
/�
/�s�AA>�>Bc�L�|j�tj|jd�5}|j	�}ddd�tj|jd�5}	|j	d�}|gk(rn�	ddd�y#1swY�MxYw#1swYyxYw)Nrj�)rKrr5r)�	readlines)rr=r�s   r�test_readlineszTestGzip.test_readlines�s��������]�]�4�=�=�$�
/�1����
�A�0��]�]�4�=�=�$�
/�1���K�K��$����7�E��!�0�
/�0�
/��0�
/�s�B�*B�B�B#c��|j�tj|j�5}	|j	�}|j�}|snu|j	�}|j
|�t|�dkDrd}nt|�}|j|�}|j|d||�|j
|���	ddd�y#1swYyxYw)N�
)
rKrr5r)rr�r r8r9r7)rr=�oldpos�line1�newpos�amount�line2s       r�test_seek_readzTestGzip.test_seek_read�s��������]�]�4�=�=�
)�Q��������
�
����e���������v���u�:�b�=��F� ��Z�F����v���� � ��w����7����v���$�	*�
)�
)�s�BC�Cc�(�|j�tj|j�5}|j	d�|jdd��|j	d�}ddd�|j
tdd�y#1swY�#xYw)Nr�rx)�whence��)rKrr5r)r9r r7rD)rr=�ys   r�test_seek_whencezTestGzip.test_seek_whencesn�������]�]�4�=�=�
)�Q�
�F�F�2�J�
�F�F�2�a�F� ����r�
�A�*�	
����E�"�R�L�)�	*�
)�s�6B�Bc���tj|jd�5}tddd�D]$}|j	|�|jd��&	ddd�y#1swYyxYw)Nr2rrV�sGZ
)rr5r)r\r r6)rr=�poss   r�test_seek_writezTestGzip.test_seek_writesL��
�]�]�4�=�=�#�
.�!��Q��R�(�����s������ �)�/�
.�
.�s�5A � A)c���|j�tj|jd�5}|j	|j
jd�ddd�tj|j�tj|jd�5}|j	|j
jd�ddd�y#1swY�xxYw#1swYyxYw)Nr3rj�xr�)	rKrr5r)r7�	myfileobjr;rr(rJs  r�	test_modezTestGzip.test_mode s�������
�]�]�4�=�=�#�
.�!����Q�[�[�-�-�t�4�/�������'�
�]�]�4�=�=�#�
.�!����Q�[�[�-�-�t�4�/�
.�/�
.��/�
.�s�'C�'C�C�C$c��dD]l}tj|j|�5}|jt	|d��|j|j|j�ddd��ny#1swY�yxYw)N)rArjrQ)rr5r)r�rGr7rQ)rr;r=s   r�test_1647484zTestGzip.test_1647484(sZ�� �D����t�}�}�d�3�q������6� 2�3�� � �������7�4�3�!�3�3�s�AA3�3A<	c�8�|j�tj|jd�5}|j	t|jd��|j|jj|j�ddd�y#1swYyxYw)NrjrQ)	rKrr5r)r�rGrr7rQrJs  r�test_paddedfile_getattrz TestGzip.test_paddedfile_getattr.s_������
�]�]�4�=�=�$�
/�1��O�O�G�A�I�I�v�6�7����Q�Y�Y�^�^�T�]�]�;�0�
/�
/�s�AB�Bc��d}tj|jd|��5}|jt�ddd�tj|j�5}|jt
|d��|j|j�|j�}|j|t�|j|j|�ddd�y#1swY��xYw#1swYyxYw)N��[r2��mtimer�)rr5r)r6rDr�rG�assertIsNoner�r9r7)rr��fWrite�fRead�dataReads     r�
test_mtimezTestGzip.test_mtime4s�����
�]�]�4�=�=�#�u�]�
=���L�L���>�
�]�]�4�=�=�
)�U��O�O�G�E�7�3�4����e�k�k�*��z�z�|�H����X�u�-����U�[�[�%�0�*�
)�>�
=��
)�
)�s�C$�"A9C0�$C-�0C9c
���d}tj|jd|��5}|jt�ddd�t|jd�5}|j
d�}|j|d�|j
d�}|j|d�	|jjd	�d
z}d}|j
d�}|j||�|j
d�}	|j|	tjd
|��|j
d�}
|j|
d�|j
d�}|j|d�|j
t|��}|j||�|jtj|j�j dz
�|j
d�}
|j|
d�|j
d�}|j|tjd
tt���ddd�y#1swY���xYw#t$rd}d
}Y���wxYw#1swYyxYw)Nr�r2r�rj���rx�zLatin-1�rrYz<i���rXs��d�)rr5r)r6rD�openr9r7�encode�UnicodeEncodeError�struct�packr8r rH�stat�st_size)rr�r�r��idBytes�cmByte�expectedname�
expectedflags�	flagsByte�
mtimeBytes�xflByte�osByte�	nameBytes�
crc32Bytes�
isizeBytess               r�
test_metadatazTestGzip.test_metadata?s�����
�]�]�4�=�=�#�u�]�
=���L�L���>��$�-�-��
&�%��j�j��m�G����W�k�2��Z�Z��]�F����V�W�-�
(�#�}�}�3�3�I�>��H�� '�
�
�
�
�1�
�I����Y�
�6����A��J����Z����T�5�)A�B��j�j��m�G����W�g�.��Z�Z��]�F����V�W�-��
�
�3�|�#4�5�I����Y��5�
�J�J�r�w�w�t�}�}�-�5�5��9�:����A��J����Z�)9�:����A��J����Z����T�3�u�:�)F�G�W'�
&�>�
=��&�
(�"�� '�
�
(��'�
&�s=�H8�AI�! I�E.I�8I�
I�I�I�I�I"c�N�tj|_|j�yr)r�TESTFN_ASCIIr)r�rs r�test_metadata_ascii_namez!TestGzip.test_metadata_ascii_namers��!�.�.��
����rc���gd�}d}|D]�\}}}|j|�5tj|jd|��}|5|j	t
�ddd�t
|jd�5}|j|�|jd�}|j||�ddd�ddd���y#1swY�gxYw#1swY� xYw#1swY��xYw)N))�fastrx�)�bestr�r�)�tradeoff�r�rXr2r|rjrx)
�subTestrr5r)r6rDr�r r9r7)	r�cases�	xflOffsetrQ�level�expectedXflByter�r�r�s	         r�test_compresslevel_metadataz$TestGzip.test_compresslevel_metadatavs���
��
�	�.3�*�T�5�/����d�#����t�}�}�c���O����L�L��'���$�-�-��.�%��J�J�y�)�#�j�j��m�G��$�$�W�o�>�/�	$�#�/4��V��.�.��	$�#�s;�%C�C�C�:5C�/C�C�C�C�C�C#	c��tj|jd�5}|jd�ddd�tj|jd�}|j	�	|5	ddd�|jd�	tj|jd�5}ddzddd�|jd�y#1swY��xYw#1swY�gxYw#t$rY�dwxYw#1swY�BxYw#t$rYywxYw)NrAsxxxrjz4__enter__ on a closed file didn't raise an exceptionrxrz1/0 didn't raise an exception)rr5r)r6rI�failr��ZeroDivisionErrorrJs  r�test_with_openzTestGzip.test_with_open�s���
�]�]�4�=�=�$�
/�1�
�G�G�F�O�0��M�M�$�-�-��.��	���	�	N����

�I�I�L�M�	7����t�}�}�d�3�q��!��4�

�I�I�5�6�#0�
/��
����	��	��
4�3�� �	��	�s_�C
�,C"�.C�0C"�
 C=�*C1�0C=�
C�C�C"�"	C.�-C.�1C:�6C=�=	D	�D	c���tj|jd�5}|jtdz�ddd�t|jd�5}|jd�ddd�tj|jd�5}|j
�}|j|tdzd�ddd�y#1swY��xYw#1swY�ixYw#1swYyxYw)NrArBr�s2rjzIncorrect data in file)rr5r)r6rDr�r9r7ros   r�test_zero_padded_filezTestGzip.test_zero_padded_file�s���
�]�]�4�=�=�$�
/�1�
�G�G�E�B�J��0��$�-�-��
&�!�
�G�G�L�!�'��]�]�4�=�=�$�
/�1�����A����Q���
�,D�E�0�
/�0�
/��'�
&��0�
/�s#�C�C�+C�C�C�C'c�^�|jttjt��yr)r��
issubclassr�BadGzipFile�OSErrorrs r�test_gzip_BadGzipFile_exceptionz(TestGzip.test_gzip_BadGzipFile_exception�s�����
�4�#3�#3�W�=�>rc�H�t|jd�5}|jtdz�ddd�tj|jd�5}|j
tj|j�ddd�y#1swY�]xYw#1swYyxYw)NrArBr3)	r�r)r6rDrr5rkrr�)r�files  r�test_bad_gzip_filezTestGzip.test_bad_gzip_file�sm��
�$�-�-��
&�$��J�J�u�r�z�"�'�
�]�]�4�=�=�#�
.�$����d�.�.����?�/�
.�'�
&��
.�
.�s�B�+B�B�B!c�r�tdz}t�}tj|d��5}|j	|�ddd�|j�}t|�}tj|d��5}|j
|j�|�ddd�y#1swY�exYw#1swYyxYw)NrBrAr~rj)rDrrr5r6�getvaluer7r9)r�uncompressed�bufr=r�s     r�test_non_seekable_filezTestGzip.test_non_seekable_file�s����r�z���n��
�]�]�3�T�]�
2�a�
�G�G�L�!�3��\�\�^�
��:�&��
�]�]�3�T�]�
2�a����Q�V�V�X�|�4�3�
2�	3�
2��3�
2�s�B!�7!B-�!B*�-B6c	�T�tdz}tj|jd�5}|j	|�ddd�d�}tj|jd�5}d|_d}|�D]R}|j
|�}|dk(rn:|j|jt|��|�|t|�z
}�T|j|jd�d�|j|t|��ddd�y#1swY��xYw#1swYyxYw)	Nr�rAc3�:K�	tddd�D]}|�����w)N�rBr�)r\)�ns r�sizesz!TestGzip.test_peek.<locals>.sizes�s&������q�"�b�)�A��G�*��s�rj�!rr�d)
rDrr5r)r6�max_read_chunk�peekr7r9r8)rr	r=rrvr�ss       r�	test_peekzTestGzip.test_peek�s����s�{��
�]�]�4�=�=�$�
/�1�
�G�G�L�!�0�	�
�]�]�4�=�=�$�
/�1�!�A���E��W���F�F�1�I����8��� � �����A����3���Q�����
���Q�V�V�C�[�#�.����U�C��$5�6�0�
/�0�
/��0�
/�s�D�'B"D�D�D'c�v�tdzjd�jd��}|j�tj|jd�5}tj|d��5}|j|j�|�ddd�ddd�y#1swY�xYw#1swYyxYw)NrB�asciiTr�r3��encoding)rD�decoder�rKrr5r)r�
TextIOWrapperr7r�)rr�r=�ts    r�test_textio_readlineszTestGzip.test_textio_readlines�s������#�#�G�,�7�7��7�F������
�]�]�4�=�=�#�
.�!��!�!�!�g�6�!�� � ������6�7�/�
.�6�6��/�
.�s$�B/�1!B#�B/�#B,	�(B/�/B8c��t|jd�5}tj|d��5}|j	d�|j|j|j�|j|j�|j��|j|jtj�|j|j�d�|j|j�d�|j|j�d�|j|jd�ddd�|jjd�|j|j|j�|jt |j�|j|jtj�|j|j�d�|j|j�d�|j|j�d�ddd�t|jd�5}tj|d��5}|j	d	�|j|j|j�|j|j�|j��|j|jtj�|j|j�d�|j|j�d�|j|j�d�|j|jd�ddd�|jjd�|j|j|j�|jt |j�|j|jtj�|j|j�d�|j|j�d�|j|j�d�ddd�t|jd
�5}tj|d��5}|j	d�|j|j|j�|j|j�|j��|j|jtj�|j|j�d�|j|j�d�|j|j�d�|j|jd�ddd�|jjd�|j|j|j�|jt |j�|j|jtj�|j|j�d�|j|j�d�|j|j�d�ddd�t|jd
�5}tj|d��5}|j|j#�d�|j|j|j�|j|j�|j��|j|jtj$�|j|j�d�|j|j�d�|j|j�d�|j|jd�ddd�|jjd�|j|j|j�|jt |j�|j|jtj$�|j|j�d�|j|j�d�|j|j�d�ddd�y#1swY���xYw#1swY���xYw#1swY���xYw#1swY���xYw#1swY��xxYw#1swY���xYw#1swY��MxYw#1swYyxYw)Nr�r�r~�oneFTrAr2�twor�rM�threerjr3�twothree)r�r)rr5r6r7rQrFr;�WRITE�assertIs�readable�writablerr�rk�AttributeErrorr9�READ)r�rawr=s   r�test_fileobj_with_namezTestGzip.test_fileobj_with_name�s���
�$�-�-��
&�#����s���5�������� � �������2�� � �����S�Z�Z�\�:�� � �������4��
�
�a�j�j�l�E�2��
�
�a�j�j�l�D�1��
�
�a�j�j�l�D�1��
�
�a�h�h��.�6�
�M�M�!�(�(�D�)����Q�V�V�S�X�X�.����n�a�h�h�7����Q�V�V�T�Z�Z�0��M�M�!�*�*�,��.��M�M�!�*�*�,��-��M�M�!�*�*�,��-�!'�$�$�-�-��
&�#����s���5�������� � �������2�� � �����S�Z�Z�\�:�� � �������4��
�
�a�j�j�l�E�2��
�
�a�j�j�l�D�1��
�
�a�j�j�l�D�1��
�
�a�h�h��.�6�
�M�M�!�(�(�D�)����Q�V�V�S�X�X�.����n�a�h�h�7����Q�V�V�T�Z�Z�0��M�M�!�*�*�,��.��M�M�!�*�*�,��-��M�M�!�*�*�,��-�!'�$�$�-�-��
&�#����s���5������!�� � �������2�� � �����S�Z�Z�\�:�� � �������4��
�
�a�j�j�l�E�2��
�
�a�j�j�l�D�1��
�
�a�j�j�l�D�1��
�
�a�h�h��.�6�
�M�M�!�(�(�D�)����Q�V�V�S�X�X�.����n�a�h�h�7����Q�V�V�T�Z�Z�0��M�M�!�*�*�,��.��M�M�!�*�*�,��-��M�M�!�*�*�,��-�!'�$�$�-�-��
&�#����s���5��� � �����;�7�� � �������2�� � �����S�Z�Z�\�:�� � �������3��
�
�a�j�j�l�D�1��
�
�a�j�j�l�E�2��
�
�a�j�j�l�D�1��
�
�a�h�h��.�6�
�M�M�!�(�(�D�)����Q�V�V�S�X�X�.����n�a�h�h�7����Q�V�V�T�Y�Y�/��M�M�!�*�*�,��-��M�M�!�*�*�,��.��M�M�!�*�*�,��-�!'�
&�k6�5��'�
&��&6�5��'�
&��&6�5��'�
&��&6�5��'�
&�s��c6�Dc)�;C4c6�
d�%Dd�1C4d�d*�Dd�'C4d*�9e�Dd7�,C4e�)c3	�.c6�6d�d
	�d�d�d'	�"d*�*d4�7e	�<e�e
c�
�tj|jtjtjztj
z�}tj|d�5}tj|d��5}|jd�|j|jd�|j|j�|j��ddd�|jjd�|j|jd�|jt |j�ddd�tj|jtjtjztj"z�}tj|d�5}tj|d��5}|jd	�|j|jd�|j|j�|j��ddd�|jjd�|jt |j�ddd�tj|jtjtjztj$z�}tj|d
�5}tj|d��5}|jd�|j|jd�|j|j�|j��ddd�|jjd�|jt |j�ddd�tj|jtj&�}tj|d
�5}tj|d��5}|j|j)�d�|j|jd�|j|j�|j��ddd�|jjd�|jt |j�ddd�y#1swY���xYw#1swY��wxYw#1swY���xYw#1swY��kxYw#1swY���xYw#1swY��_xYw#1swY��xYw#1swYyxYw)Nr�r�r~r riTrAr2r!r�rMr"rjr3r#)rHr�r)�O_WRONLY�O_CREAT�O_EXCL�fdopenrr5r6r7rQrFr%r�rkr(�O_TRUNC�O_APPEND�O_RDONLYr9)r�fdr*r=s    r�test_fileobj_from_fdopenz!TestGzip.test_fileobj_from_fdopen%sM���W�W�T�]�]�B�K�K�"�*�*�$<�r�y�y�$H�
I��
�Y�Y�r�4�
 �C����s���5�������� � �����,�� � �����S�Z�Z�\�:�6�
�M�M�!�(�(�D�)����Q�V�V�R�(����n�a�h�h�7�!��W�W�T�]�]�B�K�K�"�*�*�$<�r�z�z�$I�
J��
�Y�Y�r�4�
 �C����s���5�������� � �����,�� � �����S�Z�Z�\�:�6�
���Q�V�V�R�(����n�a�h�h�7�
!��W�W�T�]�]�B�K�K�"�*�*�$<�r�{�{�$J�
K��
�Y�Y�r�4�
 �C����s���5������!�� � �����,�� � �����S�Z�Z�\�:�6�
���Q�V�V�R�(����n�a�h�h�7�
!��W�W�T�]�]�B�K�K�
0��
�Y�Y�r�4�
 �C����s���5��� � �����;�7�� � �����,�� � �����S�Z�Z�\�:�6�
���Q�V�V�R�(����n�a�h�h�7�
!�
 �76�5��!�
 ��6�5��!�
 ��6�5��!�
 ��6�5��!�
 �s��'R0�?AR#�A R0�)S
�AR=�AS
�S$�'AS�AS$�S=�+A+S1�AS=�#R-	�(R0�0R:�=S	�S
�
S�S!	�S$�$S.�1S:	�6S=�=Tc��tj|jd�j�t	|jd�5}tj|d��5}|j|jtj�ddd�tj|d��5}|j|jtj�ddd�tj|d��5}|j|jtj�ddd�tj|d��5}|j|jtj�ddd�|jt�5tj|d��ddd�ddd�d	D]j}t	|j|�5}tj|�
�5}|j|jtj�ddd�ddd��ldD]�}d|vrtj|j�t	|j|�5}|jt�5tj|�
�}ddd�5|j|jtj�ddd�ddd���y#1swY��GxYw#1swY��
xYw#1swY���xYw#1swY���xYw#1swY��hxYw#1swY��mxYw#1swY��xYw#1swY���xYw#1swY��xYw#1swY��xYw#1swY��;xYw)NrA�r+br3r~r2rMr��z)rjr7�r)rAr�r�)rr5r)rIr�r7r;r)r$rkr�rr(�assertWarns�
FutureWarning)rr=�gr;s    r�test_fileobj_modezTestGzip.test_fileobj_modeMs:���
�
�d�m�m�T�*�0�0�2�
�$�-�-��
'�1����q�s��3�q�� � �������3�4����q�s��3�q�� � �������4�4����q�s��3�q�� � �������4�4����q�s��3�q�� � �������4�4��"�"�:�.��
�
�a�c�
�2�/�(� �D��d�m�m�T�*�a��]�]�1�]�-���$�$�Q�V�V�T�Y�Y�7�.�+�*� �%�D��d�{�� � ����/��d�m�m�T�*�a��%�%�m�4��
�
�a�
�0�A�5���$�$�Q�V�V�T�Z�Z�8��+�*�%�4�3��3�3��3�3��3�3��.�.��(�
'��.�-��+�*��5�4���Q��+�*�s��L�+K
�L�'+K�L�1+K'�L�;+K4�&L�L�L�L(�+L�L(�M
�.L5�
M
�+M�:M
�
K	�L�K$	�L�'K1	�,L�4K>	�9L�L	�L�L�L%� L(�(L2	�5L>�:M
�M
�M
�
M	c��|j}tj|�}tj	|d�5}|jtdz�ddd�|jj|�tj	|d�5}|j|j�tdz�ddd�|j|j|�tj	|d�5}|j|j�tdz�ddd�|j|j|�y#1swY��xYw#1swY��xYw#1swY�>xYw)NrArBrj)
r)rH�fsencoderr5r6rDr7rQr9)r�str_filename�bytes_filenamer=s    r�test_bytes_filenamezTestGzip.test_bytes_filenamegs����}�}�����\�2��
�]�]�>�4�
0�A�
�G�G�E�B�J��1��������0�
�]�]�>�4�
0�A����Q�V�V�X�u�r�z�2�1��������0�
�]�]�<��
.�!����Q�V�V�X�u�r�z�2�/��������.�1�
0��1�
0��/�
.�s#�D:�(E�-(E�:E�E�Ec��tj�}tj|d��5}|j	t
dz�|j
|jd�|jtj|j�|j
|jtj�|j|j�d�|j|j�d�|j|j!�d�|j|j"d�ddd�|jj"d�|j
|jd�|jt$|j�|j
|jtj�|j|j�d�|j|j�d�|j|j!�d�|j'd�tj|d��5}|j
|j)�t
dz�|j
|jd�|jtj|j�|j
|jtj*�|j|j�d�|j|j�d�|j|j!�d�|j|j"d�ddd�|j|j"d�|j
|jd�|jt$|j�|j
|jtj*�|j|j�d�|j|j�d�|j|j!�d�y#1swY��xYw#1swY��xYw)	NrAr~rBriFTrrj)rr�rr5r6rDr7rQrkrrFr;r$r%r&r'rr�r(r r9r))r�bior=s   r�test_fileobj_without_namez"TestGzip.test_fileobj_without_nameus����j�j�l��
�]�]�3�T�]�
2�a�
�G�G�E�B�J�����Q�V�V�R�(����b�5�5�q�x�x�@����Q�V�V�T�Z�Z�0��M�M�!�*�*�,��.��M�M�!�*�*�,��-��M�M�!�*�*�,��-��M�M�!�(�(�E�*�3�	
�
�
�a�h�h��%��������$����.�!�(�(�3����������,��
�
�a�j�j�l�E�*��
�
�a�j�j�l�D�)��
�
�a�j�j�l�D�)������
�]�]�3�T�]�
2�a����Q�V�V�X�u�r�z�2����Q�V�V�R�(����b�5�5�q�x�x�@����Q�V�V�T�Y�Y�/��M�M�!�*�*�,��-��M�M�!�*�*�,��.��M�M�!�*�*�,��-��M�M�!�(�(�E�*�3�	
�
�
�a�h�h��%��������$����.�!�(�(�3����������+��
�
�a�j�j�l�D�)��
�
�a�j�j�l�E�*��
�
�a�j�j�l�D�)�C3�
2��$3�
2�s�DQ�DQ�Q�Qc�x�|jdz}t|jd�5}tj||d��5}|j	t
dz�|j
|j|�ddd�ddd�t|jd�5}tj||d��5}|j
|j�t
dz�|j
|j|�ddd�ddd�tj|jd�5}|j
|j�t
dz�|j
|j|j�ddd�y#1swY��xYw#1swY��xYw#1swY��xYw#1swY��xYw#1swYyxYw)N�newrA)rr)r;rBrj)	r)r�rr5r6rDr7rQr9)r�	filename2rr=s    r�test_fileobj_and_filenamez"TestGzip.test_fileobj_and_filename�sA���M�M�E�)�	��4�=�=�$�'�7��m�m�G�i�d�m�K�q�
�G�G�E�B�J�����Q�V�V�Y�/�L�(��4�=�=�$�'�7��m�m�G�i�d�m�K�q����Q�V�V�X�u�r�z�2����Q�V�V�Y�/�L�(�
�]�]�4�=�=�$�
/�1����Q�V�V�X�u�r�z�2����Q�V�V�T�]�]�3�0�
/�L�K��(�'��
L�K��(�'��
0�
/�sT�F�5E>�4F�F$�3AF�7F$�'AF0�>F	�F�F�F!	�F$�$F-�0F9c���tjdtd�zd��}|jt	|�t
j�tj|�}tj|��}|j|jd�d�dt
jz}|j|jjj�|d�y)	z-Decompressed data buffering should be limitedr�g��>Ar�r|r9rxz)Excessive amount of data was decompressedN)rr��int�
assertLessr8r�DEFAULT_BUFFER_SIZEr�r5r7r9�assertLessEqual�_bufferr*r)r�bomb�decomp�
max_decomps    r�test_decompress_limitedz TestGzip.test_decompress_limited�s����}�}�U�S��X�-�Q�}�?������D�	�2�#9�#9�:��z�z�$������t��,��������Q���/���/�/�/�
����V�^�^�/�/�4�4�6�
�7�	9rc�\�ttfD]�}dD]�}tj|g|���}|j	t|�t�tjtj|�d��5}|j	|j�|�ddd�����y#1swY��xYw)N�r)rx)r�)r�rjr~)rDr�rr�r7�typer4r5rr�r9)rr:r�datacr=s     r�
test_compresszTestGzip.test_compress�s����E�N�D�.���
�
�d�2�T�2��� � ��e��e�4��]�]�2�:�:�e�+<�4�]�H�A��$�$�Q�V�V�X�t�4�I�H�/�#�I�H�s�4!B"�"B+c	���d}ttfD]�}dD]�}|j||��5tj|g|��d|i�}|jt
|�t�tjtj|�d��5}|jd�|j|j|�ddd�ddd�����y#1swY�xYw#1swY��xYw)Nr�rU)r:rr�rjr~rx)
rDr�r�rr�r7rVr4r5rr�r9r�)rr�r:rrWr=s      r�test_compress_mtimezTestGzip.test_compress_mtime�s������E�N�D�.���\�\�t�$�\�7� �M�M�$�C��C�U�C�E��$�$�T�%�[�%�8����r�z�z�%�/@�t��L�PQ����q�	��(�(����%�8�M�8�7�/�#�
M�L��8�7�s$�A#C�
.C	�;C�C
�C�C%c�(�dD]�}|j|��5tjtd|��}tjtd|��}|j	t|�|jt|�ddd���y#1swY��xYw)N)r�*r�r)r}r�rx)r�rr�rD�assertIn�assertNotIn)rr��
nocompress�yescompresss    r�test_compress_correct_levelz$TestGzip.test_compress_correct_level�so���E����E��*�!�]�]�5���]�O�
�"�m�m�E��%�m�P���
�
�e�Z�0�� � ���4�	+�*��*�*�s�A%B�B	c��ttfD]�}tj�}tj|d��5}|j
|�ddd�|jtj|j��|�tj|�}|jtj|�|���y#1swY�yxYw)NrAr~)rDr�rr�rr5r6r7�
decompressrr�)rr:r
r=rWs     r�test_decompresszTestGzip.test_decompress�s����E�N�D��*�*�,�C����s���6�!�����
�7����T�_�_�S�\�\�^�<�d�C��M�M�$�'�E����T�_�_�U�3�T�:�#�6�6�s�C�C	c��tjt�}|jttj
|dd�y)N����rr�rDrk�EOFErrorrc�r�compressed_datas  r�!test_decompress_truncated_trailerz*TestGzip.test_decompress_truncated_trailer��-���-�-��.�����(�D�O�O�_�S�b�5I�Jrc��tjt�}|jttj
|dd�y)N���rgris  r�test_decompress_missing_trailerz(TestGzip.test_decompress_missing_trailer�rlrc��tdz}tj|�dd}tjt	j
|���5}|j
t|j�ddd�tjt	j
|���5}|j|jt|��|�|j
t|jd�ddd�tdd�D]X}tjt	j
|d|���5}|j
t|jd�ddd��Zy#1swY��xYw#1swY�}xYw#1swY�}xYw)NrBrnr9rxr�r�)rDrr�r5rr�rkrhr9r7r8r\)rr:�	truncatedr=r�s     r�test_read_truncatedzTestGzip.test_read_truncated�s
���R�x���M�M�$�'���,�	�
�]�]�2�:�:�i�#8�]�
9�Q����h����/�:�
�]�]�2�:�:�i�#8�]�
9�Q����Q�V�V�C��I�.��5����h�����2�:��q�"��A����r�z�z�)�B�Q�-�'@��A�Q��!�!�(�A�F�F�A�6�B�A��
:�
9��
9�
9��
B�A�s%�!E�AE%�,"E1�E"�%E.�1E:	c���d}tjtj|���5}|j	|j�d�ddd�y#1swYyxYw)Ns��cQ�ExtraI-.2�Mxr9sTest)rr5rr�r7r9)r�gzdatar=s   r�test_read_with_extrazTestGzip.test_read_with_extra�sF��<���]�]�2�:�:�f�#5�]�
6�!����Q�V�V�X�w�/�7�
6�
6�s�!A�Ac�^�tj|jd�5}|jt�ddd�tj|jd�5}|j
jjj�ddd�y#1swY�axYw#1swYyxYw)NrArj)	rr�r)r6rDrOr*�_fp�prependrJs  r�test_prepend_errorzTestGzip.test_prepend_error�sl��
�Y�Y�t�}�}�d�
+�q�
�G�G�E�N�,�
�Y�Y�t�}�}�d�
+�q�
�I�I�M�M���%�%�'�,�
+�,�
+��
+�
+�s�B�/B#�B �#B,c�b�tjdgd��}t|�|jz}tj	tj�d��5}|j|j|�|�|j|j�|�ddd�y#1swYyxYw)N�Q)rxr��rYrr2r~)
rfr8�itemsizerr5rr�r7r6r)r�q�LENGTHr=s    r�test_issue44439zTestGzip.test_issue44439sv���K�K��_�-���Q��!�*�*�$��
�]�]�2�:�:�<�c�]�
:�a����Q�W�W�Q�Z��0����Q�V�V�X�v�.�;�
:�
:�s
�AB%�%B.c���tj�}d}tj|d��5}|j	|�|j�|j
�}ddd�|j
�}|jtj|�|�|jt�5tj�ddd�tjtj��}tj�}tj|�|j|j��}|j||�y#1swY��xYw#1swY��xYw)N�important message here.r2r~)�wbits)rr�rr5r6rErr7rcrkrhr
�
decompressobj�	MAX_WBITS�_read_gzip_headerr9)r�b�messager=�partial_data�	full_datarS�read_messages        r�test_flush_flushes_compressorz&TestGzip.test_flush_flushes_compressor
s����J�J�L��,��
�]�]�1�3�]�
/�1�
�G�G�G��
�G�G�I��:�:�<�L�0��J�J�L�	��������3�W�=��
�
�x�
(��O�O�L�)�)����d�n�n�_��5���J�J�|�$�����q�!��|�|�A�F�F�H�-������w�/�0�
/��)�
(�s�2E�2E�E�E&c�z�Gd�d�}tj�}|�}tj|d��5}||_|j�|jd�|jd��ddd�tjdddg}|j|j|�y#1swY�:xYw)	Nc� �eZdZd�Zd�Zdd�Zy)�1TestGzip.test_flush_modes.<locals>.FakeCompressorc��g|_yr)�modesrs r�__init__z:TestGzip.test_flush_modes.<locals>.FakeCompressor.__init__#s	����
rc��y�Nrr)rr:s  rr�z:TestGzip.test_flush_modes.<locals>.FakeCompressor.compress%s��rc�:�|jj|�yr�)r�rs)rr;s  rrEz7TestGzip.test_flush_modes.<locals>.FakeCompressor.flush's���
�
�!�!�$�'�rN)���)r!r"r#r�r�rErrr�FakeCompressorr�"s��
 �
�
rr�r2r~rBr)�	zlib_moder�)
rr�rr5r�rEr
�Z_SYNC_FLUSHr7r�)rr�r��fcr=�expected_modess      r�test_flush_modeszTestGzip.test_flush_modess���	�	�
�J�J�L��
�
��
�]�]�1�3�]�
/�1��A�J�
�G�G�I�
�G�G�B�K�
�G�G�c�G�"�	0�
������	
��	
������>�2�0�
/�s�;B1�1B:c�p�tj�}d}tj|d��5}|j	|�|jt
|��|j	|�ddd�|j�}|jtj|�|dz�y#1swY�BxYw)Nr�r2r~r�)
rr�rr5r6r r8rr7rc)rr�r�r=r:s     r�test_write_seek_writezTestGzip.test_write_seek_write:s���
�J�J�L��,��
�]�]�1�3�]�
/�1�
�G�G�G��
�F�F�3�w�<� �
�G�G�G��0��z�z�|���������.��!��<�0�
/�s�=B,�,B5N)r�);r!r"r#r?rKrTr_rbrgrmrprwrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr+r5r=rBrErIrSrXrZrardrkrorrruryr�r�r�r�rrrr0r09s1��/��0�"'�8�?�.�&�
7��S��#�.�$�.��85�-�&/�	F�
5�
"��&*�!�5�8�<�	1�1H�f�?�(7�*
F�?�@�5�7�,7�G.�R&8�P9�4/�#*�J
4�
9�5�	9�5�;�K�K�7�0�(�/�0�*3�6
=rr0c�B�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�TestOpenc��tdz}tj|jd�5}|j	|�ddd�t|jd�5}tj|j
��}|j||�ddd�tj|jd�5}|j|j
�|�ddd�tj|jd�5}|j	|�ddd�t|jd�5}tj|j
��}|j||dz�ddd�|jt�5tj|jd�ddd�tj|j�tj|jd�5}|j	|�ddd�t|jd�5}tj|j
��}|j||�ddd�y#1swY��$xYw#1swY���xYw#1swY���xYw#1swY��txYw#1swY��*xYw#1swY��xYw#1swY��xYw#1swYyxYw)NrBrArjr�r�r��rDrr�r)r6rcr9r7rkr�rr(�rr	r=�	file_datas    r�test_binary_modeszTestOpen.test_binary_modesHs����r�z��
�Y�Y�t�}�}�d�
+�q�
�G�G�L�!�,�
�$�-�-��
&�!��������1�I����Y��5�'��Y�Y�t�}�}�d�
+�q����Q�V�V�X�|�4�,��Y�Y�t�}�}�d�
+�q�
�G�G�L�!�,�
�$�-�-��
&�!��������1�I����Y��q�(8�9�'��
�
��
/��I�I�d�m�m�T�*�0�������'�
�Y�Y�t�}�}�d�
+�q�
�G�G�L�!�,�
�$�-�-��
&�!��������1�I����Y��5�'�
&�),�
+��
&�
&��,�
+��,�
+��
&�
&��0�
/��,�
+��
&�
&��_�I�6I+�8!I8�J�19J�!J�/J+�6J7�I(�+I5�8J�J�J�J(�+J4�7Kc���tj|j�}tj	|d�5}|jtdz�ddd�|jj|j�tj	|d�5}|jt�ddd�|j|j|j�tj	|�5}|j|j�tdz�ddd�|j|j|j�y#1swY��xYw#1swY��xYw#1swY�HxYw)NrArBr�rN)
rrOr)rr�r6rDr7rQr9)rr)r=s   r�test_pathlike_filezTestOpen.test_pathlike_filecs����%�%�d�m�m�4��
�Y�Y�x��
&�!�
�G�G�E�B�J��'����������/�
�Y�Y�x��
&�!�
�G�G�E�N�'����������/�
�Y�Y�x�
 �A����Q�V�V�X�u�r�z�2�!����������/�'�
&��'�
&��!�
 �s#�E�E�,(E�E�E�E$c��tdz}tj|jd�5}|j	|�ddd�t|jd�5}tj|j
��}|j||�ddd�tj|jd�5}|j|j
�|�ddd�tj|jd�5}|j	|�ddd�t|jd�5}tj|j
��}|j||dz�ddd�|jt�5tj|jd�ddd�tj|j�tj|jd�5}|j	|�ddd�t|jd�5}tj|j
��}|j||�ddd�y#1swY��$xYw#1swY���xYw#1swY���xYw#1swY��txYw#1swY��*xYw#1swY��xYw#1swY��xYw#1swYyxYw)NrBr2rjr3rMr�r�r�r�s    r�test_implicit_binary_modesz#TestOpen.test_implicit_binary_modesos����r�z��
�Y�Y�t�}�}�c�
*�a�
�G�G�L�!�+�
�$�-�-��
&�!��������1�I����Y��5�'��Y�Y�t�}�}�c�
*�a����Q�V�V�X�|�4�+��Y�Y�t�}�}�c�
*�a�
�G�G�L�!�+�
�$�-�-��
&�!��������1�I����Y��q�(8�9�'��
�
��
/��I�I�d�m�m�S�)�0�������'�
�Y�Y�t�}�}�c�
*�a�
�G�G�L�!�+�
�$�-�-��
&�!��������1�I����Y��5�'�
&�)+�
*��
&�
&��+�
*��+�
*��
&�
&��0�
/��+�
*��
&�
&�r�c��tjd�dz}|jdtj�}t
j
|jdd��5}|j|�ddd�t
|jd�5}t
j|j��jd�}|j||�ddd�t
j
|jdd��5}|j|j�|�ddd�t
j
|jdd��5}|j|�ddd�t
|jd�5}t
j|j��jd�}|j||d	z�ddd�y#1swY��[xYw#1swY��xYw#1swY��xYw#1swY��xYw#1swYyxYw)
NrrB�
�wtrrj�rt�atr��rDr�replacerH�lineseprr�r)r6rcr9r7�rr	�uncompressed_rawr=r�s     r�test_text_modeszTestOpen.test_text_modes�sl���|�|�G�,�r�1��'�/�/��b�j�j�A��
�Y�Y�t�}�}�d�W�Y�
=��
�G�G�L�!�>�
�$�-�-��
&�!��������1�8�8��A�I����Y�(8�9�'��Y�Y�t�}�}�d�W�Y�
=�����Q�V�V�X�|�4�>�
�Y�Y�t�}�}�d�W�Y�
=��
�G�G�L�!�>�
�$�-�-��
&�!��������1�8�8��A�I����Y�(8�1�(<�=�'�
&�>�
=��
&�
&��>�
=��
=�
=��
&�
&�s>�G�AG�:!G �G,�5AG8�G�G� G)�,G5�8Hc��tdz}|jd�}tj|�}tj	tj|�d�5}|j|j�|�ddd�tj	tj|�d�5}|j|j�|�ddd�tj	tj|�dd��5}|j|j�|�ddd�y#1swY��xYw#1swY�jxYw#1swYyxYw)NrBrr3rjr�r)	rDrrr�r�rr�r7r9)r�uncompressed_bytes�uncompressed_strr�r=s     r�test_fileobjzTestOpen.test_fileobj�s���"�R�Z��-�4�4�W�=���]�]�#5�6�
�
�Y�Y�r�z�z�*�-�s�
3�q����Q�V�V�X�'9�:�4�
�Y�Y�r�z�z�*�-�t�
4�����Q�V�V�X�'9�:�5�
�Y�Y�r�z�z�*�-�t�g�Y�
F�!����Q�V�V�X�'7�8�G�
F�	4�
3��
4�
4��
F�
F�s$�!D)�+!D5�?!E�)D2�5D>�E
c�v�|jt�5tjd�ddd�|jt�5tj|j
d�ddd�|jt�5tj|j
d�ddd�|jt�5tj|j
dd��ddd�|jt�5tj|j
dd��ddd�|jt�5tj|j
dd	�
�ddd�y#1swY��GxYw#1swY��xYw#1swY��xYw#1swY��xYw#1swY�|xYw#1swYyxYw)Ngw��/�^@�wbt�xbtrjzutf-8r�ignore)�errorsr�)�newline)rkrlrr�r�r)rs r�test_bad_paramszTestOpen.test_bad_params�s��
�
�
�y�
)��I�I�g��*�
�
�
�z�
*��I�I�d�m�m�U�+�+�
�
�
�z�
*��I�I�d�m�m�U�+�+�
�
�
�z�
*��I�I�d�m�m�T�G�I�<�+�
�
�
�z�
*��I�I�d�m�m�T�(�I�;�+�
�
�
�z�
*��I�I�d�m�m�T�4�I�8�+�
*�*�
)��
*�
*��
*�
*��
*�
*��
*�
*��
*�
*�sG�E1�	!E>�!F�#F�#F#�#F/�1E;�>F�F�F �#F,�/F8c��tjd�dz}|jdtj�}t
j
|jdd��5}|j|�ddd�t
|jd�5}t
j|j��jd�}|j||�ddd�t
j
|jdd��5}|j|j�|�ddd�y#1swY��xYw#1swY�axYw#1swYyxYw)	NrrBr�r�zutf-16rrjr�r�r�s     r�
test_encodingzTestOpen.test_encoding�s����|�|�G�,�r�1��'�/�/��b�j�j�A��
�Y�Y�t�}�}�d�X�Y�
>�!�
�G�G�L�!�?�
�$�-�-��
&�!��������1�8�8��B�I����Y�(8�9�'��Y�Y�t�}�}�d�X�Y�
>�!����Q�V�V�X�|�4�?�
>�?�
>��
&�
&��?�
>�s%�D$�AD0�:!D<�$D-�0D9�<Ec�@�tj|jd�5}|jd�ddd�tj|jddd��5}|j	|j�d�ddd�y#1swY�VxYw#1swYyxYw)NrAsfoo�barr�rr�)rr��foobar)rr�r)r6r7r9rJs  r�test_encoding_error_handlerz$TestOpen.test_encoding_error_handler�sq��
�Y�Y�t�}�}�d�
+�q�
�G�G�M�"�,�
�Y�Y�t�}�}�d�W�X�Y�
N�����Q�V�V�X�x�0�O�
N�,�
+��
N�
N�s�B�!B�B�Bc�x�tjd�dz}tj|jddd��5}|j|�ddd�tj|jddd��5}|j
|j�|g�ddd�y#1swY�WxYw#1swYyxYw)NrrBr�r�)rr�r��
)rDrrr�r)r6r7r�)rr	r=s   r�test_newlinezTestOpen.test_newline�s����|�|�G�,�r�1��
�Y�Y�t�}�}�d�W�d�Y�
K�q�
�G�G�L�!�L�
�Y�Y�t�}�}�d�W�d�Y�
K�q����Q�[�[�]�\�N�;�L�
K�L�
K��
K�
K�s�B$�9"B0�$B-�0B9N)r!r"r#r�r�r�r�r�r�r�r�r�rrrr�r�Gs/��6�6
0�6�8>� 	9�
9�
5�1�<rr�c����fd�}|S)Nc�F���tj����fd��}|S)Nc���tj��	�|i|��tj��S#tj��wxYwr)rH�makedirsr�rmtree)r�kwargs�	directory�functions  ��r�wrapperz?create_and_remove_directory.<locals>.decorator.<locals>.wrapper�s>����K�K�	�"�
,���0��0�� � ��+��	� � ��+�s	�5�A)�	functools�wraps)r�r�r�s` �r�	decoratorz.create_and_remove_directory.<locals>.decorator�s%���	����	"�	,�
#�	,��rr)r�r�s` r�create_and_remove_directoryr��s�����rc��eZdZdZe�d��Zee�d��Zd�Z	e�ee�d���Z
ee�d��Zee�d��Zd�Z
d	�Zy
)�TestCommandLinesThis is a simple test with gzipc��tj�5}tj|d��5}|j	|j
�ddd�tjdddf}t|ttt��5}|j|j��\}}ddd�ddd�|jd�|j|j
�y#1swY��xYw#1swY�LxYw#1swY�PxYw)NrAr~�-mr�-d��stdin�stdout�stderrr)
rr�rr5r6r:�sys�
executablerr�communicaterr7)r�bytes_io�	gzip_filer�proc�out�errs       r�test_decompress_stdin_stdoutz,TestCommandLine.test_decompress_stdin_stdout�s���
�Z�Z�\�X����x�d��;�y�����	�	�*�<��>�>�4���5�D��t�4��T�B�d��+�+�H�,=�,=�,?�@���S�C��	
����c�"�����d�i�i�(�<�;��C�B���\�s:�C:�C"�	7C:�#C.�#C:�"C+	�'C:�.C7	�3C:�:Dc��tjjtd�}|j	tjj|��tj|d��5}|j|j�ddd�tddd|�\}}}ttjjtd�d�5}|j|j�|j�ddd�|jtjj|��|j|d	�|j|d
�|j|d
�y#1swY��xYw#1swY�zxYw)Nztestgzip.gzrA)r;r�rr��testgziprjrr)rH�pathrt�TEMPDIRr��existsrr�r6r:r
r7r9r�)r�gzipname�fp�rcr�r��gunzipeds       r�test_decompress_infile_outfilez.TestCommandLine.test_decompress_infile_outfile�s���7�7�<�<���7�����������1�2�
�Y�Y�x�d�Y�
+�r��H�H�T�Y�Y��,�'��f�d�H�E���C��
�"�'�'�,�,�w�
�3�T�
:�h����X�]�]�_�d�i�i�8�;�	
��������x�0�1�����Q������c�"�����c�"�,�
+��;�
:�s�*E&�+E2�&E/�2E;c��tdddd�\}}}|jd|j��|j|d�|j|d�y)Nr�rr�zthisisatest.outs.filename doesn't end in .gz: 'thisisatest.out'rxr)rr7�strip�rr�r�r�s    r�$test_decompress_infile_outfile_errorz4TestCommandLine.test_decompress_infile_outfile_errorsP��,�T�6�4�AR�S���C�����J�C�I�I�K�X�����Q������c�"rc��tjddf}t|ttt��5}|j	|j
�\}}ddd�|j
d�|j
ddd�y#1swY�1xYw)Nr�rr�rr�r�)r�r�rrr�r:r7)rrr�r�r�s     r�test_compress_stdin_outfilez+TestCommandLine.test_compress_stdin_outfilesr���~�~�t�V�+��
�4�t�D��
>�$��'�'��	�	�2�H�C��?�	
����c�"�����R�a��+�.�	?�
>�s�A>�>Bc���tjjtd�}|dz}|j	tjj|��t
|d�5}|j|j�ddd�tdd|�\}}}|jtjj|��|j|d�|j|d�y#1swY�mxYw)Nr��.gzrAr�rr)rHr�rtr�r�r�r�r6r:r
r�r7)r�local_testgzipr�r�r�r�r�s       r�$test_compress_infile_outfile_defaultz4TestCommandLine.test_compress_infile_outfile_defaults��������g�z�:��!�E�)�����������1�2�
�.�$�
'�2��H�H�T�Y�Y��(�(��f�n�E���C����������x�0�1�����c�"�����c�"�(�
'�s�$C,�,C5c���dD�]L}|j|��5tjjtd�}|dz}|jtjj
|��t|d�5}|j|j�ddd�tdd||�\}}}|jtjj
|��|j|d�|j|d�tj|�|jtjj
|��ddd���Oy#1swY��xYw#1swY��gxYw)	N)�--fast�--best)�compress_levelr�r�rAr�rr)r�rHr�rtr�r�r�r�r6r:r
r�r7�remove)rr�r�r�r�r�r�r�s        r�test_compress_infile_outfilez,TestCommandLine.test_compress_infile_outfiles��2�N����^��<�!#�����g�z�!B��)�E�1��� � �������!9�:��.�$�/�2��H�H�T�Y�Y�'�0� 0��f�n�n�]���C����������x� 8�9�� � ��c�*�� � ��c�*��	�	�(�#�� � �������!9�:�=�<�3�0�/��=�<�s%�A$E �=E�B/E �E�E � E*	c�p�tdddd�\}}}|jd|�|j|d�y)Nr�rr�r�s8error: argument --best: not allowed with argument --fastr�rr]r7r�s    r�%test_compress_fast_best_are_exclusivez5TestCommandLine.test_compress_fast_best_are_exclusive2s8��,�T�6�8�X�N���C���
�
�Q�SV�W�����c�"rc�p�tdddd�\}}}|jd|�|j|d�y)Nr�rr�r�sAerror: argument -d/--decompress: not allowed with argument --fastrrr�s    r�-test_decompress_cannot_have_flags_compressionz=TestCommandLine.test_decompress_cannot_have_flags_compression7s8��,�T�6�8�T�J���C���
�
�Z�\_�`�����c�"rN)r!r"r#r:r	r�r�r�r�r�r�r�rrrrrrr�r��s���-�D���
)��
)�!��)�#�*�#� #��� ��)�/�*��/�!��)�#�*�#�!��)�;�*�;�$#�
#rr��__main__)'�__doc__rfr�rrHr�r��unittest�
subprocessrr�test.supportrrrrr	�test.support.script_helperr
r�
import_modulerr
rDr�r��abspathr.r�r�r�TestCaser%r0r�r�r�r!�mainrrr�<module>rs����
��	�	�
�
��"�&�"�=�=�N�"�}�"�"�6�*��"�}�"�"�6�*��	��	��
�'�'�/�/�)�*�*�
+�h�
6��&�2�:�:�&�(�x� � �(�K=�x�K=�\H<�x�H<�V
�[#�h�'�'�[#�|�z���H�M�M�O�r

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