Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_gzip.cpython-311.pyc
�

�Ke�}����dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
ddlmZddlmZmZmZddlmZmZe
jd��Zd	Zd
Zej�ej��dzZGd�d
ej��ZGd�dej��Z Gd�de ��Z!Gd�de ��Z"d�Z#Gd�dej��Z$e%dkrej&��dSdS)z!Test script for the gzip module.
�N)�PIPE�Popen)�
import_helper)�	os_helper)�_4G�
bigmemtest�requires_subprocess)�assert_python_ok�assert_python_failure�gzipsy  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�ZdS)�UnseekableIOc��dS)NF���selfs �8/usr/local/apps/python3/lib/python3.11/test/test_gzip.py�seekablezUnseekableIO.seekable%s���u�c��tj��N��io�UnsupportedOperationrs r�tellzUnseekableIO.tell(����%�%rc��tj�rr)r�argss  r�seekzUnseekableIO.seek+rrN)�__name__�
__module__�__qualname__rrrrrrrr$sA���������&�&�&�&�&�&�&�&rrc�(�eZdZejZd�Zd�ZdS)�BaseTestc�8�tj|j��dSr�r�unlink�filenamers r�setUpzBaseTest.setUp2�������'�'�'�'�'rc�8�tj|j��dSrr&rs r�tearDownzBaseTest.tearDown5r*rN)r r!r"r�TESTFNr(r)r,rrrr$r$/s:��������H�(�(�(�(�(�(�(�(rr$c�V�eZdZd5d�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/�Z0d0�Z1d1�Z2d2�Z3d3�Z4d4S)6�TestGzip�bc���t|��}t�|jd|z��5}|�|��}ddd��n#1swxYwY|�|t
|����t�|jd|z��5}|�|���|��ddd��dS#1swxYwYdS)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�
3�	�q�����
�
�A�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����C��K�K�(�(�(�
�]�]�4�=�#�d�(�
3�
3�	/�q����Q�V�V�X�X�v�.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/s#�A�A�A�&)C�C �#C c���t�|jd��5}|�tdz��|���|���ttd��r&tj	|�����|�
��ddd��n#1swxYwY|�
��dS)N�wb�2�fsync)rr5r(r6�data1�flush�fileno�hasattr�osrC�close�rr=s  r�
test_writezTestGzip.test_writeBs���
�]�]�4�=�$�
/�
/�	�1�
�G�G�E�B�J����
�G�G�I�I�I�
�H�H�J�J�J��r�7�#�#�
%��������$�$�$�
�G�G�I�I�I�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
���	�	�	�	�	s�BC�C�	Cc��tj|j��}t�|d��5}|�tdz��ddd��n#1swxYwY|�|jt��t�|d��5}|�t��ddd��n#1swxYwYt�|��5}|�
��}ddd��n#1swxYwY|�|tdz��|�|jt��dS)Nr2rB�a�3)�pathlib�Pathr(rr5r6rD�assertIsInstance�name�strr9r7)rr(r=�ds    r�"test_write_read_with_pathlike_filez+TestGzip.test_write_read_with_pathlike_filePs����<��
�.�.��
�]�]�8�S�
)�
)�	 �Q�
�G�G�E�B�J����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ����a�f�c�*�*�*�
�]�]�8�S�
)�
)�	�Q�
�G�G�E�N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�]�]�8�
$�
$�	�������A�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����E�B�J�'�'�'����a�f�c�*�*�*�*�*s5�A�A#�&A#�%C�C�C�1D�D�Dc��|�ttdz����ttt	d������}|�dgd����}|�|��dS)NrB��B)�rY�)�shape)r?�
memoryviewrDr4�range�cast)r�mr:s   r�test_write_memoryviewzTestGzip.test_write_memoryview_sp��� � ��E�B�J�!7�!7�8�8�8��u�U�3�Z�Z�(�(�)�)���v�v�c����v�)�)��� � ��&�&�&�&�&rc�Z�|�ttdz����dS)NrB)r?�	bytearrayrDrs r�test_write_bytearrayzTestGzip.test_write_bytearrayes(��� � ��5�2�:�!6�!6�7�7�7�7�7rc�f�|�tjdtdz����dS)N�I�()r?�arrayrDrs r�test_write_arrayzTestGzip.test_write_arrayhs,��� � ���S�%�"�*�!=�!=�>�>�>�>�>rc��t�|jd��5}|�t��5|�d��ddd��n#1swxYwY|�t��5|�g��ddd��n#1swxYwY|�t��ddd��n#1swxYwYt�|jd��5}|�|���t��ddd��dS#1swxYwYdS)NrA��rb)	rr5r(�assertRaises�	TypeErrorr6rDr7r9rJs  r�test_write_incompatible_typez%TestGzip.test_write_incompatible_typeks���]�]�4�=�$�
/�
/�	�1��"�"�9�-�-�
�
��������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��"�"�9�-�-�
�
��������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�G�G�E�N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��]�]�4�=�$�
/�
/�	.�1����Q�V�V�X�X�u�-�-�-�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�	.�	.sj�C�A�C�A"	�"C�%A"	�&C�B%�C�%B)	�)C�,B)	�-C�C�C�.D<�<E�Ec��|���t�|jd��5}|���}ddd��n#1swxYwY|�|tdz��dS)Nr3rB)rKrr5r(r9r7rD�rr=rTs   r�	test_readzTestGzip.test_readxs���������
�]�]�4�=�#�
.�
.�	�!������A�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����E�"�H�%�%�%�%�%s�A�A�Ac���|���g}d}t�|jd��5}	|���}|snP|�|��|t
|��z
}|�|���|���g	ddd��n#1swxYwY|�d�	|��tdz��dS)Nrr3TrrB)rKrr5r(�read1�appendr8r7r�joinrD)r�blocks�nreadr=rTs     r�
test_read1zTestGzip.test_read1s������������
�]�]�4�=�#�
.�
.�	2�!�
2��G�G�I�I������
�
�a� � � ���Q������ � ������5�1�1�1�
2��		2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	
������&�)�)�5�2�:�6�6�6�6�6s�A)B/�/B3�6B3�)�size�memusec��t�td���}t�t	j|��d���}|�|�|��t��dS)Nry��
compresslevelrk��fileobjr;)r�compressrDr5r�BytesIOr7r9)rrz�
compressedr=s    r�test_read_largezTestGzip.test_read_large�s^���]�]�5��]�:�:�
��M�M�"�*�Z�"8�"8�t�M�D�D�����������u�-�-�-�-�-rc��|���t�|jd��}|j}|�|j��|���|�|j��|�	t��5|�d��ddd��n#1swxYwY|�	t��5|�d��ddd��n#1swxYwY|�	t��5|�
��ddd��n#1swxYwYt�|jd��}|j}|�|j��|���|�|j��|�	t��5|�d��ddd��n#1swxYwY|�	t��5|���ddd��dS#1swxYwYdS)Nr3ryrr2r)rKrr5r(r��assertFalse�closedrI�
assertTruerl�
ValueErrorr9rrr6rE)rr=r�s   r�test_io_on_closed_objectz!TestGzip.test_io_on_closed_object�s��
	
�������M�M�$�-��-�-���)�������(�(�(�	���	�	�	������'�'�'�
�
�
�z�
*�
*�	�	�
�F�F�1�I�I�I�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�z�
*�
*�	�	�
�F�F�1�I�I�I�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�z�
*�
*�	�	�
�F�F�H�H�H�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�M�M�$�-��-�-���)�������(�(�(�	���	�	�	������'�'�'�
�
�
�z�
*�
*�	�	�
�G�G�C�L�L�L�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�z�
*�
*�	�	�
�G�G�I�I�I�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	sZ�C�C�C�%D�D�D�,E
�
E�E�!H�H�
H�(I
�
I�Ic���|���t�|jd��5}|�t
dz��ddd��n#1swxYwYt�|jd��5}|���}ddd��n#1swxYwY|�|tdzt
dzz��dS)N�ab�rkrB)	rKrr5r(r6�data2r9r7rDrps   r�test_appendzTestGzip.test_append�s0��������
�]�]�4�=�$�
/�
/�	 �1�
�G�G�E�B�J����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ��]�]�4�=�$�
/�
/�	�1������A�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����U�2�X�%��(�3�4�4�4�4�4s#�A�A#�&A#�
B+�+B/�2B/c�D�t�|jdd��5}|�d��ddd��n#1swxYwYt	dd��D]P}t�|jdd��5}|�d��ddd��n#1swxYwY�Qt�|jd��5}d}	|�d
��}||z
}|sn�	ddd��n#1swxYwY|�|d��dS)NrA�	�ar��r�rkrryi s�aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)rr5r(r6r]r9r7)rr=�i�zgfile�contents�ztxts      r�test_many_appendzTestGzip.test_many_append�s����]�]�4�=�$��
2�
2�	�a�
�G�G�D�M�M�M�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��q�#���	�	�A����t�}�d�A�6�6�
�!�����
�
�
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
���]�]�4�=�$�
/�
/�	#�6��H�
#��{�{�4�(�(���D� ���"�U�
#�#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�	
����8�,�,�,�,�,s5�A�A�A�B$�$B(	�+B(	�"C?�?D�Dc�&�t�|jd��5}|�tdz��ddd��n#1swxYwYt�|jd��5}|�|���tdz��ddd��n#1swxYwY|�t��5t�|jd��ddd��dS#1swxYwYdS)N�xbrBrk)	rr5r(r6rDr7r9rl�FileExistsErrorrJs  r�test_exclusive_writezTestGzip.test_exclusive_write�s���
�]�]�4�=�$�
/�
/�	 �1�
�G�G�E�B�J����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �
�]�]�4�=�$�
/�
/�	3�1����Q�V�V�X�X�u�r�z�2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�
�
�
��
/�
/�	/�	/��M�M�$�-��.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/s5�A�A�A�61B3�3B7�:B7�!D�D
�
D
c�r�|���t�|jd��5}t	j|��5}d�|D��}ddd��n#1swxYwYddd��n#1swxYwY|�|dt�d���z��dS)Nrkc��g|]}|��Srr)�.0�lines  r�
<listcomp>z1TestGzip.test_buffered_reader.<locals>.<listcomp>�s��,�,�,�$��,�,�,rrBT��keepends)	rKrr5r(r�BufferedReaderr7rD�
splitlines)rr=r3�liness    r�test_buffered_readerzTestGzip.test_buffered_reader�s&��	
������
�]�]�4�=�$�
/�
/�	-�1��"�1�%�%�
-��,�,�!�,�,�,��
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	
�����U�%5�%5�t�%5�%D�%D� D�E�E�E�E�Es5�A:�

A#�A:�#A'	�'A:�*A'	�+A:�:A>�A>c�B�|���t�|jd��5}d}	|�|��}|s|dkrn/|�t
|��|k��|dzdz}�M	ddd��dS#1swxYwYdS)NrkrryrB)rKrr5r(�readliner�r8)rr=�line_length�Ls    r�
test_readlinezTestGzip.test_readline�s����������]�]�4�=�$�
/�
/�	5�1��K�
5��J�J�{�+�+���4�[�A�-�-�u�����A���+� 5�6�6�6�*�Q��"�4��	
5�/4�		5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�	5�	5s�AB�B�Bc�v�|���t�|jd��5}|���}ddd��n#1swxYwYt�|jd��5}	|�d��}|gkrn�	ddd��dS#1swxYwYdS)Nrkry�)rKrr5r(�	readlines)rr=r�s   r�test_readlineszTestGzip.test_readlines�s+���������]�]�4�=�$�
/�
/�	�1����
�
�A�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��]�]�4�=�$�
/�
/�	"�1�
"��K�K��$�$����7�7�E�
"�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"s#�A�A�A�B.�.B2�5B2c�&�|���t�|j��5}	|���}|���}|sn�|���}|�|��t|��dkrd}nt|��}|�|��}|�	|d|�|��|�|����	ddd��dS#1swxYwYdS)Nry�
)
rKrr5r(rr�rr8r9r7)rr=�oldpos�line1�newpos�amount�line2s       r�test_seek_readzTestGzip.test_seek_read�s3���������]�]�4�=�
)�
)�
	�Q�
��������
�
�����#�e����������v�����u�:�:�b�=�=��F�F� ��Z�Z�F����v����� � ��w��w���7�7�7����v����
�$�	
	�
	�
	�
	�
	�
	�
	�
	�
	�
	�
	�
	����
	�
	�
	�
	�
	�
	s�CD�D
�
D
c�d�|���t�|j��5}|�d��|�dd���|�d��}ddd��n#1swxYwY|�|tdd���dS)Nr�ry)�whence��)rKrr5r(r9rr7rD)rr=�ys   r�test_seek_whencezTestGzip.test_seek_whence
s����������]�]�4�=�
)�
)�	�Q�
�F�F�2�J�J�J�
�F�F�2�a�F� � � ����r�
�
�A�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
����E�"�R�%�L�)�)�)�)�)s�AB�B�	Bc��t�|jd��5}tddd��D],}|�|��|�d���-	ddd��dS#1swxYwYdS)Nr2rrW�sGZ
)rr5r(r]rr6)rr=�poss   r�test_seek_writezTestGzip.test_seek_writes���
�]�]�4�=�#�
.�
.�	!�!��Q��R�(�(�
!�
!�����s�������� � � � �
!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!�	!�	!s�?A.�.A2�5A2c���|���t�|jd��5}|�|jjd��ddd��n#1swxYwYtj|j��t�|jd��5}|�|jjd��ddd��dS#1swxYwYdS)Nr3rk�xr�)	rKrr5r(r7�	myfileobjr;rr'rJs  r�	test_modezTestGzip.test_modes:��������
�]�]�4�=�#�
.�
.�	5�!����Q�[�-�t�4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�����'�'�'�
�]�]�4�=�#�
.�
.�	5�!����Q�[�-�t�4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�	5�	5s#�!A"�"A&�)A&�&!C�C�Cc��dD]}}t�|j|��5}|�t	|d����|�|j|j��ddd��n#1swxYwY�~dS)N)rArkrR)rr5r(r�rGr7rR)rr;r=s   r�test_1647484zTestGzip.test_1647484&s��� �	8�	8�D����t�}�d�3�3�
8�q������6� 2� 2�3�3�3�� � �����7�7�7�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8��	8�	8s�AA5�5A9	�<A9	c�:�|���t�|jd��5}|�t|jd����|�|jj|j��ddd��dS#1swxYwYdS)NrkrR)	rKrr5r(r�rGr�r7rRrJs  r�test_paddedfile_getattrz TestGzip.test_paddedfile_getattr,s���������
�]�]�4�=�$�
/�
/�	<�1��O�O�G�A�I�v�6�6�7�7�7����Q�Y�^�T�]�;�;�;�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<s�AB�B�Bc�0�d}t�|jd|���5}|�t��ddd��n#1swxYwYt�|j��5}|�t
|d����|�|j��|�	��}|�
|t��|�
|j|��ddd��dS#1swxYwYdS)N��[r2��mtimer�)rr5r(r6rDr�rG�assertIsNoner�r9r7)rr��fWrite�fRead�dataReads     r�
test_mtimezTestGzip.test_mtime2sg����
�]�]�4�=�#�u�]�
=�
=�	 ���L�L�����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �
�]�]�4�=�
)�
)�	1�U��O�O�G�E�7�3�3�4�4�4����e�k�*�*�*��z�z�|�|�H����X�u�-�-�-����U�[�%�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s$�A�A�A�6BD�D�Dc
�p�d}t�|jd|���5}|�t��ddd��n#1swxYwYt|jd��5}|�d��}|�|d��|�d��}|�|d��	|j�d	��d
z}d}n#t$rd}d
}YnwxYw|�d��}|�||��|�d��}	|�|	tjd
|����|�d��}
|�|
d��|�d��}|�|d��|�t|����}|�||��|�
tj|j��jdz
��|�d��}
|�|
d��|�d��}|�|tjd
tt������ddd��dS#1swxYwYdS)Nr�r2r�rk���ry�zLatin-1�rrZz<i���rYs��d�)rr5r(r6rD�openr9r7�encode�UnicodeEncodeError�struct�packr8rrH�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�����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ��$�-��
&�
&�+	H�%��j�j��m�m�G����W�k�2�2�2��Z�Z��]�]�F����V�W�-�-�-�
(�#�}�3�3�I�>�>��H�� '�
�
��%�
(�
(�
(�"�� '�
�
�
�
(�����
�
�1�
�
�I����Y�
�6�6�6����A���J����Z���T�5�)A�)A�B�B�B��j�j��m�m�G����W�g�.�.�.��Z�Z��]�]�F����V�W�-�-�-��
�
�3�|�#4�#4�5�5�I����Y��5�5�5�
�J�J�r�w�t�}�-�-�5��9�:�:�:����A���J����Z�)9�:�:�:����A���J����Z���T�3�u�:�:�)F�)F�G�G�G�W+	H�+	H�+	H�+	H�+	H�+	H�+	H�+	H�+	H�+	H�+	H�+	H����+	H�+	H�+	H�+	H�+	H�+	HsI�A�A�A�,AJ+�C$�#J+�$C5�2J+�4C5�5F)J+�+J/�2J/c�P�tj|_|���dSr)r�TESTFN_ASCIIr(r�rs r�test_metadata_ascii_namez!TestGzip.test_metadata_ascii_nameps$��!�.��
��������rc��gd�}d}|D]�\}}}|�|��5t�|jd|���}|5|�t
��ddd��n#1swxYwYt
|jd��5}|�|��|�d��}|�	||��ddd��n#1swxYwYddd��n#1swxYwY��dS)N))�fastry�)�bestr�r�)�tradeoff�r�rYr2r}rkry)
�subTestrr5r(r6rDr�rr9r7)	r�cases�	xflOffsetrR�level�expectedXflByter�r�r�s	         r�test_compresslevel_metadataz$TestGzip.test_compresslevel_metadatats���
�
�
��
�	�.3�	?�	?�*�T�5�/����d�#�#�
?�
?����t�}�c���O�O���(�(��L�L��'�'�'�(�(�(�(�(�(�(�(�(�(�(����(�(�(�(��$�-��.�.�?�%��J�J�y�)�)�)�#�j�j��m�m�G��$�$�W�o�>�>�>�?�?�?�?�?�?�?�?�?�?�?����?�?�?�?�	
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?��	?�	?sZ�%C4�	A0�$C4�0A4�4C4�7A4�8C4�AC�C4�C!�!C4�$C!�%C4�4C8	�;C8	c�T�t�|jd��5}|�d��ddd��n#1swxYwYt�|jd��}|���	|5	ddd��n#1swxYwY|�d��n#t$rYnwxYw	t�|jd��5}ddzddd��n#1swxYwY|�d��dS#t$rYdSwxYw)NrAsxxxrkz4__enter__ on a closed file didn't raise an exceptionryrz1/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�O�O�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��M�M�$�-��.�.��	���	�	�	�	N��
�
��
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�

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

�I�I�5�6�6�6�6�6��!�	�	�	��D�D�	���s}�A�A�
A�B4�B�B4�B�B4�B�B4�4
C�C� D�%C7�+D�7C;�;D�>C;�?D�
D'�&D'c��t�|jd��5}|�tdz��ddd��n#1swxYwYt|jd��5}|�d��ddd��n#1swxYwYt�|jd��5}|���}|�|tdzd��ddd��dS#1swxYwYdS)NrArBr�s2rkzIncorrect data in file)rr5r(r6rDr�r9r7rps   r�test_zero_padded_filezTestGzip.test_zero_padded_file�s���
�]�]�4�=�$�
/�
/�	 �1�
�G�G�E�B�J����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ��$�-��
&�
&�	"�!�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"��]�]�4�=�$�
/�
/�	F�1������A����Q���
�,D�E�E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs5�A�A�A�+B
�
B�B�84C9�9C=�C=c�j�|�ttjt����dSr)r��
issubclassr�BadGzipFile�OSErrorrs r�test_gzip_BadGzipFile_exceptionz(TestGzip.test_gzip_BadGzipFile_exception�s'�����
�4�#3�W�=�=�>�>�>�>�>rc�V�t|jd��5}|�tdz��ddd��n#1swxYwYt�|jd��5}|�tj|j��ddd��dS#1swxYwYdS)NrArBr3)	r�r(r6rDrr5rlrr�)r�files  r�test_bad_gzip_filezTestGzip.test_bad_gzip_file�s!��
�$�-��
&�
&�	#�$��J�J�u�r�z�"�"�"�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�
�]�]�4�=�#�
.�
.�	@�$����d�.���?�?�?�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�	@�	@s#�A�A�A�+&B�B"�%B"c���tdz}t��}t�|d���5}|�|��ddd��n#1swxYwY|���}t|��}t�|d���5}|�|���|��ddd��dS#1swxYwYdS)NrBrArrk)rDrrr5r6�getvaluer7r9)r�uncompressed�bufr=r�s     r�test_non_seekable_filezTestGzip.test_non_seekable_file�s=���r�z���n�n��
�]�]�3�T�]�
2�
2�	"�a�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"��\�\�^�^�
��:�&�&��
�]�]�3�T�]�
2�
2�	5�a����Q�V�V�X�X�|�4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�	5�	5s#�A�A�A�!)C�C�Cc	��tdz}t�|jd��5}|�|��ddd��n#1swxYwYd�}t�|jd��5}d|_d}|��D]g}|�|��}|dkrnI|�|�t|����|��|t|��z
}�h|�|�d��d��|�|t|����ddd��dS#1swxYwYdS)	Nr�rAc3�:K�	tddd��D]}|V���)NT�rBr�)r])�ns r�sizesz!TestGzip.test_peek.<locals>.sizes�s6����
��q�"�b�)�)���A��G�G�G�G�
rrk�!rr�d)
rDrr5r(r6�max_read_chunk�peekr7r9r8)rr
r=rrwr�ss       r�	test_peekzTestGzip.test_peek�s����s�{��
�]�]�4�=�$�
/�
/�	"�1�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	�	�	�
�]�]�4�=�$�
/�
/�
	7�1�!�A���E��U�W�W�
 �
 ���F�F�1�I�I����8�8��E�� � �����A������3�3�3���Q���������Q�V�V�C�[�[�#�.�.�.����U�C��$5�$5�6�6�6�
	7�
	7�
	7�
	7�
	7�
	7�
	7�
	7�
	7�
	7�
	7�
	7����
	7�
	7�
	7�
	7�
	7�
	7s$�A
�
A�A�;CE�E�Ec��tdz�d���d���}|���t�|jd��5}tj|d���5}|�	|�
��|��ddd��n#1swxYwYddd��dS#1swxYwYdS)NrB�asciiTr�r3��encoding)rD�decoder�rKrr5r(r�
TextIOWrapperr7r�)rr�r=�ts    r�test_textio_readlineszTestGzip.test_textio_readlines�s7�����#�#�G�,�,�7�7��7�F�F��������
�]�]�4�=�#�
.�
.�	7�!��!�!�g�6�6�6�
7�!�� � �������6�6�6�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7����
7�
7�
7�
7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	7�	7s6�&C
�=)B2�&C
�2B6	�6C
�9B6	�:C
�
C�Cc�.�tj|jtjtjz��}tj|d��5}t�|d���5}	ddd��n#1swxYwYddd��dS#1swxYwYdS)NrAr2r)rHr�r(�O_WRONLY�O_CREAT�fdopenrr5)r�fdr=�gs    r�test_fileobj_from_fdopenz!TestGzip.test_fileobj_from_fdopen�s����W�T�]�B�K�"�*�$<�
=�
=��
�Y�r�4�
 �
 �	�A����q�s��3�3�
�q��
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s6�B
�$A2�&B
�2A6	�6B
�9A6	�:B
�
B�Bc���t�|jd�����t	|jd��5}t�|d���5}|�|jtj��ddd��n#1swxYwYt�|d���5}|�|jtj��ddd��n#1swxYwYt�|d���5}|�|jtj��ddd��n#1swxYwYt�|d���5}|�|jtj��ddd��n#1swxYwY|�	t��5t�|d���ddd��n#1swxYwYddd��n#1swxYwYd	D]�}t	|j|��5}t�|�
��5}|�|jtj��ddd��n#1swxYwYddd��n#1swxYwY��dD]�}d|vrtj|j��t	|j|��5}|�
t��5t�|�
��}ddd��n#1swxYwY|5|�|jtj��ddd��n#1swxYwYddd��n#1swxYwY��dS)NrA�r+br3rr2rMr��z)rkr+�r�)rAr�r�)rr5r(rIr�r7r;�READ�WRITErlr�rr'�assertWarns�
FutureWarning)rr=r(r;s    r�test_fileobj_modezTestGzip.test_fileobj_mode�s����
�
�d�m�T�*�*�0�0�2�2�2�
�$�-��
'�
'�
	3�1����q�s��3�3�
4�q�� � �����3�3�3�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4����q�s��3�3�
5�q�� � �����4�4�4�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5����q�s��3�3�
5�q�� � �����4�4�4�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5����q�s��3�3�
5�q�� � �����4�4�4�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5��"�"�:�.�.�
3�
3��
�
�a�c�
�2�2�2�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�
	3�
	3�
	3�
	3�
	3�
	3�
	3�
	3�
	3�
	3�
	3����
	3�
	3�
	3�
	3� �	8�	8�D��d�m�T�*�*�
8�a��]�]�1�]�-�-�8���$�$�Q�V�T�Y�7�7�7�8�8�8�8�8�8�8�8�8�8�8����8�8�8�8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8��%�	9�	9�D��d�{�{�� ���/�/�/��d�m�T�*�*�
9�a��%�%�m�4�4�1�1��
�
�a�
�0�0�A�1�1�1�1�1�1�1�1�1�1�1����1�1�1�1��9�9��$�$�Q�V�T�Z�8�8�8�9�9�9�9�9�9�9�9�9�9�9����9�9�9�9�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9����
9�
9�
9�
9��	9�	9sV�H�%&B�H�B	�H�B	�H�>&C0�$H�0C4	�4H�7C4	�8H�&E	�=H�	E
	�
H�E
	�H�0&F"�H�"F&	�&H�)F&	�*H�G0�$H�0G4	�4H�7G4	�8H�H�H�+J�&I9�-J�9I=�=J�I=�J�J	�J	�M+�-L�	M+�L�M+�L�M+�"&M�M+�M�M+�M�M+�+M/	�2M/	c��|j}	|�d��}n%#t$r|�d��YnwxYwt�|d��5}|�tdz��ddd��n#1swxYwYt�|d��5}|�|�	��tdz��ddd��n#1swxYwYt�|d��5}|�|�	��tdz��ddd��dS#1swxYwYdS)Nrz%Temporary file name needs to be ASCIIrArBrk)
r(r�r��skipTestrr5r6rDr7r9)r�str_filename�bytes_filenamer=s    r�test_bytes_filenamezTestGzip.test_bytes_filename�s����}��	C�)�0�0��9�9�N�N��!�	C�	C�	C��M�M�A�B�B�B�B�B�	C����
�]�]�>�4�
0�
0�	 �A�
�G�G�E�B�J����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �
�]�]�>�4�
0�
0�	3�A����Q�V�V�X�X�u�r�z�2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3��]�]�<��
.�
.�	3�!����Q�V�V�X�X�u�r�z�2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3sE��A�A�B	�	B
�B
�/1C,�,C0�3C0�1E�E�Ec���t�dtd��zd���}|�t	|��t
j��tj|��}t�|���}|�	|�
d��d��dt
jz}|�|jj
���|d��dS)	z-Decompressed data buffering should be limitedr�g��>Ar�r}r-ryz)Excessive amount of data was decompressedN)rr��int�
assertLessr8r�DEFAULT_BUFFER_SIZEr�r5r7r9�assertLessEqual�_buffer�rawr)r�bomb�decomp�
max_decomps    r�test_decompress_limitedz TestGzip.test_decompress_limited
s����}�}�U�S��X�X�-�Q�}�?�?������D�	�	�2�#9�:�:�:��z�$�������t��,�,��������Q����/�/�/���/�/�
����V�^�/�4�4�6�6�
�7�	9�	9�	9�	9�	9rc��ttfD]�}dD]�}tj|g|�R�}|�t|��t��t�tj	|��d���5}|�|�
��|��ddd��n#1swxYwY����dS)N�r)ry)r�)r�rkr)rDr�rr�r7�typer4r5rr�r9)rr:r�datacr=s     r�
test_compresszTestGzip.test_compresss����E�N�	5�	5�D�.�
5�
5���
�d�2�T�2�2�2��� � ��e���e�4�4�4��]�]�2�:�e�+<�+<�4�]�H�H�5�A��$�$�Q�V�V�X�X�t�4�4�4�5�5�5�5�5�5�5�5�5�5�5����5�5�5�5��
5�	5�	5s�=)B2�2B6�9B6c	��d}ttfD]�}dD]�}|�||���5tj|g|�Rd|i�}|�t
|��t��t�tj
|��d���5}|�d��|�|j|��ddd��n#1swxYwYddd��n#1swxYwY���dS)Nr�rD)r:rr�rkrry)
rDr�r�rr�r7rEr4r5rr�r9r�)rr�r:rrFr=s      r�test_compress_mtimezTestGzip.test_compress_mtime sy�����E�N�	9�	9�D�.�
9�
9���\�\�t�$�\�7�7�9�9� �M�$�C��C�C�C�U�C�C�E��$�$�T�%�[�[�%�8�8�8����r�z�%�/@�/@�t��L�L�9�PQ����q�	�	�	��(�(���%�8�8�8�9�9�9�9�9�9�9�9�9�9�9����9�9�9�9�9�9�9�9�9�9�9�9�9�9�9����9�9�9�9��
9�	9�	9s6�A,C.�1C	�C.�C
�C.�C
�C.�.C2�5C2c�`�dD]�}|�|���5t�td|���}t�td|���}|�t|��|�t|��ddd��n#1swxYwY��dS)N)r�*r�r)r~r�ry)r�rr�rD�assertIn�assertNotIn)rr��
nocompress�yescompresss    r�test_compress_correct_levelz$TestGzip.test_compress_correct_level+s����	5�	5�E����E��*�*�
5�
5�!�]�]�5���]�O�O�
�"�m�m�E��%�m�P�P���
�
�e�Z�0�0�0�� � ���4�4�4�	
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5��	5�	5s�A;B"�"B&	�)B&	c���ttfD]�}tj��}t�|d���5}|�|��ddd��n#1swxYwY|�t�|�	����|��t�
|��}|�t�|��|����dS)NrAr)rDr�rr�rr5r6r7�
decompressrr�)rr:rr=rFs     r�test_decompresszTestGzip.test_decompress4s���E�N�	;�	;�D��*�,�,�C����s���6�6�
�!�����
�
�
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
����T�_�_�S�\�\�^�^�<�<�d�C�C�C��M�M�$�'�'�E����T�_�_�U�3�3�T�:�:�:�:�	;�	;s�A"�"A&	�)A&	c��t�t��}|�ttj|dd���dS)N����rr�rDrl�EOFErrorrR�r�compressed_datas  r�!test_decompress_truncated_trailerz*TestGzip.test_decompress_truncated_trailer>�<���-�-��.�.�����(�D�O�_�S�b�S�5I�J�J�J�J�Jrc��t�t��}|�ttj|dd���dS)N���rVrXs  r�test_decompress_missing_trailerz(TestGzip.test_decompress_missing_trailerBr[rc�b�tdz}t�|��dd�}t�t	j|�����5}|�t|j��ddd��n#1swxYwYt�t	j|�����5}|�	|�t|����|��|�t|jd��ddd��n#1swxYwYtdd��D]p}t�t	j|d|������5}|�t|jd��ddd��n#1swxYwY�qdS)NrBr]r-ryr�r�)rDrr�r5rr�rlrWr9r7r8r])rr:�	truncatedr=r�s     r�test_read_truncatedzTestGzip.test_read_truncatedFs���R�x���M�M�$�'�'����,�	�
�]�]�2�:�i�#8�#8�]�
9�
9�	0�Q����h���/�/�/�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0�
�]�]�2�:�i�#8�#8�]�
9�
9�	3�Q����Q�V�V�C��I�I�.�.��5�5�5����h����2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3��q�"���	7�	7�A����r�z�)�B�Q�B�-�'@�'@��A�A�
7�Q��!�!�(�A�F�A�6�6�6�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7����
7�
7�
7�
7��	7�	7s7�!B�B�B�?AD#�#D'�*D'�5"F#�#F'	�*F'	c���d}t�tj|�����5}|�|���d��ddd��dS#1swxYwYdS)Ns��cQ�ExtraI-.2�Mxr-sTest)rr5rr�r7r9)r�gzdatar=s   r�test_read_with_extrazTestGzip.test_read_with_extraTs���<���]�]�2�:�f�#5�#5�]�
6�
6�	0�!����Q�V�V�X�X�w�/�/�/�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0�	0�	0s�)A&�&A*�-A*c�b�t�|jd��5}|�t��ddd��n#1swxYwYt�|jd��5}|jjj���ddd��dS#1swxYwYdS)NrArk)	rr�r(r6rDr=r>�_fp�prependrJs  r�test_prepend_errorzTestGzip.test_prepend_error\s	��
�Y�Y�t�}�d�
+�
+�	�q�
�G�G�E�N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�Y�Y�t�}�d�
+�
+�	(�q�
�I�M��%�%�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s#�A�A�A�3$B$�$B(�+B(c��tjdgd���}t|��|jz}t�tj��d���5}|�|�|��|��|�|�	��|��ddd��dS#1swxYwYdS)N�Q)ryr��rZrr2r)
rgr8�itemsizerr5rr�r7r6r)r�q�LENGTHr=s    r�test_issue44439zTestGzip.test_issue44439cs����K��_�_�_�-�-���Q���!�*�$��
�]�]�2�:�<�<�c�]�
:�
:�	/�a����Q�W�W�Q�Z�Z��0�0�0����Q�V�V�X�X�v�.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/s�AB;�;B?�B?N)r0)5r r!r"r?rKrUr`rcrhrnrqrxrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
rrr"r)r2r7rBrGrIrPrSrZr^rardrhrorrrr/r/9s������/�/�/�/����
+�
+�
+�'�'�'�8�8�8�?�?�?�.�.�.�&�&�&�
7�
7�
7��Z�S��#�#�#�.�.�$�#�.����85�5�5�-�-�-�&/�/�/�	F�	F�	F�
5�
5�
5�
"�
"�
"����&*�*�*�!�!�!�5�5�5�8�8�8�<�<�<�	1�	1�	1�1H�1H�1H�f���?�?�?�(7�7�7�*
F�
F�
F�?�?�?�@�@�@�5�5�5�7�7�7�,7�7�7����9�9�9�43�3�3�
9�
9�
9�5�5�5�	9�	9�	9�5�5�5�;�;�;�K�K�K�K�K�K�7�7�7�0�0�0�(�(�(�/�/�/�/�/rr/c�D�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
S)�TestOpenc� �tdz}t�|jd��5}|�|��ddd��n#1swxYwYt|jd��5}t�|�����}|�||��ddd��n#1swxYwYt�|jd��5}|�|���|��ddd��n#1swxYwYt�|jd��5}|�|��ddd��n#1swxYwYt|jd��5}t�|�����}|�||dz��ddd��n#1swxYwY|�t��5t�|jd��ddd��n#1swxYwYtj|j��t�|jd��5}|�|��ddd��n#1swxYwYt|jd��5}t�|�����}|�||��ddd��dS#1swxYwYdS)NrBrArkr�r�r��rDrr�r(r6rRr9r7rlr�rr'�rr
r=�	file_datas    r�test_binary_modeszTestOpen.test_binary_modesmsd���r�z��
�Y�Y�t�}�d�
+�
+�	"�q�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�$�-��
&�
&�	6�!���������1�1�I����Y��5�5�5�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6��Y�Y�t�}�d�
+�
+�	5�q����Q�V�V�X�X�|�4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5��Y�Y�t�}�d�
+�
+�	"�q�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�$�-��
&�
&�	:�!���������1�1�I����Y��q�(8�9�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:��
�
��
/�
/�	+�	+��I�I�d�m�T�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�����'�'�'�
�Y�Y�t�}�d�
+�
+�	"�q�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�$�-��
&�
&�	6�!���������1�1�I����Y��5�5�5�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6�	6�	6��A
�
A�A�-AB<�<C�C�')D�D �#D �E)�)E-�0E-�	AG�G�"G�!H-�-H1�4H1�1J�J�J�3AL�L�
Lc�8�tj|j��}t�|d��5}|�tdz��ddd��n#1swxYwYt�|d��5}|�t��ddd��n#1swxYwYt�|��5}|�|���tdz��ddd��dS#1swxYwYdS)NrArBr�rN)	rOrPr(rr�r6rDr7r9)rr(r=s   r�test_pathlike_filezTestOpen.test_pathlike_file�s����<��
�.�.��
�Y�Y�x��
&�
&�	 �!�
�G�G�E�B�J����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �
�Y�Y�x��
&�
&�	�!�
�G�G�E�N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�Y�Y�x�
 �
 �	3�A����Q�V�V�X�X�u�r�z�2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3s5�A�A#�&A#�B,�,B0�3B0�1D�D�Dc� �tdz}t�|jd��5}|�|��ddd��n#1swxYwYt|jd��5}t�|�����}|�||��ddd��n#1swxYwYt�|jd��5}|�|���|��ddd��n#1swxYwYt�|jd��5}|�|��ddd��n#1swxYwYt|jd��5}t�|�����}|�||dz��ddd��n#1swxYwY|�t��5t�|jd��ddd��n#1swxYwYtj|j��t�|jd��5}|�|��ddd��n#1swxYwYt|jd��5}t�|�����}|�||��ddd��dS#1swxYwYdS)NrBr2rkr3rMr�r�rsrts    r�test_implicit_binary_modesz#TestOpen.test_implicit_binary_modes�sd���r�z��
�Y�Y�t�}�c�
*�
*�	"�a�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�$�-��
&�
&�	6�!���������1�1�I����Y��5�5�5�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6��Y�Y�t�}�c�
*�
*�	5�a����Q�V�V�X�X�|�4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5��Y�Y�t�}�c�
*�
*�	"�a�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�$�-��
&�
&�	:�!���������1�1�I����Y��q�(8�9�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:��
�
��
/�
/�	*�	*��I�I�d�m�S�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�����'�'�'�
�Y�Y�t�}�c�
*�
*�	"�a�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�$�-��
&�
&�	6�!���������1�1�I����Y��5�5�5�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6�	6�	6rwc��t�d��dz}|�dtj��}t
�|jdd���5}|�|��ddd��n#1swxYwYt
|jd��5}t
�	|�
�����d��}|�||��ddd��n#1swxYwYt
�|jdd���5}|�|�
��|��ddd��n#1swxYwYt
�|jdd���5}|�|��ddd��n#1swxYwYt
|jd��5}t
�	|�
�����d��}|�||d	z��ddd��dS#1swxYwYdS)
NrrB�
�wtrrk�rt�atr��rDr�replacerH�lineseprr�r(r6rRr9r7�rr
�uncompressed_rawr=rus     r�test_text_modeszTestOpen.test_text_modes�s���|�|�G�,�,�r�1��'�/�/��b�j�A�A��
�Y�Y�t�}�d�W�Y�
=�
=�	"��
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�$�-��
&�
&�	:�!���������1�1�8�8��A�A�I����Y�(8�9�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:��Y�Y�t�}�d�W�Y�
=�
=�	5�����Q�V�V�X�X�|�4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�
�Y�Y�t�}�d�W�Y�
=�
=�	"��
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�$�-��
&�
&�	>�!���������1�1�8�8��A�A�I����Y�(8�1�(<�=�=�=�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>����	>�	>�	>�	>�	>�	>s\� B�B�	B�"AD�D�D�1)E&�&E*�-E*�F5�5F9�<F9�AH;�;H?�H?c��tdz}|�d��}t�|��}t�tj|��d��5}|�|���|��ddd��n#1swxYwYt�tj|��d��5}|�|���|��ddd��n#1swxYwYt�tj|��dd���5}|�|���|��ddd��dS#1swxYwYdS)NrBrr3rkrr)	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�6�
�
�Y�Y�r�z�*�-�-�s�
3�
3�	;�q����Q�V�V�X�X�'9�:�:�:�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�
�Y�Y�r�z�*�-�-�t�
4�
4�	;�����Q�V�V�X�X�'9�:�:�:�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�
�Y�Y�r�z�*�-�-�t�g�Y�
F�
F�	9�!����Q�V�V�X�X�'7�8�8�8�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9����	9�	9�	9�	9�	9�	9s6�')B�B �#B �)D	�	D
�D
�)E9�9E=�E=c���|�t��5t�d��ddd��n#1swxYwY|�t��5t�|jd��ddd��n#1swxYwY|�t��5t�|jd��ddd��n#1swxYwY|�t��5t�|jdd���ddd��n#1swxYwY|�t��5t�|jdd���ddd��n#1swxYwY|�t��5t�|jdd	�
��ddd��dS#1swxYwYdS)Ngw��/�^@�wbt�xbtrkzutf-8r�ignore)�errorsr})�newline)rlrmrr�r�r(rs r�test_bad_paramszTestOpen.test_bad_params�s��
�
�
�y�
)�
)�	�	��I�I�g����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�z�
*�
*�	,�	,��I�I�d�m�U�+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�
�
�
�z�
*�
*�	,�	,��I�I�d�m�U�+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�
�
�
�z�
*�
*�	=�	=��I�I�d�m�T�G�I�<�<�<�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=�
�
�
�z�
*�
*�	<�	<��I�I�d�m�T�(�I�;�;�;�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�
�
�
�z�
*�
*�	9�	9��I�I�d�m�T�4�I�8�8�8�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9����	9�	9�	9�	9�	9�	9sk�A�A�	A�'!B�B�B�9!C&�&C*�-C*�#D:�:D>�D>�#F�F�F�3#G#�#G'�*G'c���t�d��dz}|�dtj��}t
�|jdd���5}|�|��ddd��n#1swxYwYt
|jd��5}t
�	|�
�����d��}|�||��ddd��n#1swxYwYt
�|jdd���5}|�|�
��|��ddd��dS#1swxYwYdS)	NrrBr}r~zutf-16rrkrr�r�s     r�
test_encodingzTestOpen.test_encoding�s����|�|�G�,�,�r�1��'�/�/��b�j�A�A��
�Y�Y�t�}�d�X�Y�
>�
>�	"�!�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�$�-��
&�
&�	:�!���������1�1�8�8��B�B�I����Y�(8�9�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:��Y�Y�t�}�d�X�Y�
>�
>�	5�!����Q�V�V�X�X�|�4�4�4�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�	5�	5s7� B�B�	B�"AD�D�D�1)E'�'E+�.E+c�h�t�|jd��5}|�d��ddd��n#1swxYwYt�|jddd���5}|�|���d��ddd��dS#1swxYwYdS)NrAsfoo�barrrr�)rr��foobar)rr�r(r6r7r9rJs  r�test_encoding_error_handlerz$TestOpen.test_encoding_error_handler�s��
�Y�Y�t�}�d�
+�
+�	#�q�
�G�G�M�"�"�"�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�
�Y�Y�t�}�d�W�X�Y�
N�
N�	1�����Q�V�V�X�X�x�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s#�A�A�
A�1)B'�'B+�.B+c��t�d��dz}t�|jddd���5}|�|��ddd��n#1swxYwYt�|jddd���5}|�|���|g��ddd��dS#1swxYwYdS)NrrBr~r})rr�r�
)rDrrr�r(r6r7r�)rr
r=s   r�test_newlinezTestOpen.test_newline�s5���|�|�G�,�,�r�1��
�Y�Y�t�}�d�W�d�Y�
K�
K�	"�q�
�G�G�L�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�
�Y�Y�t�}�d�W�d�Y�
K�
K�	<�q����Q�[�[�]�]�\�N�;�;�;�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<s$�A#�#A'�*A'�*C�C�CN)r r!r"rvryr{r�r�r�r�r�r�rrrrqrqls�������6�6�6�63�3�3�6�6�6�8>�>�>� 	9�	9�	9�
9�
9�
9�
5�
5�
5�1�1�1�<�<�<�<�<rrqc����fd�}|S)Nc�J���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�sU����K�	�"�"�"�
,��x��0��0�0�� ��+�+�+�+��	� ��+�+�+�+���s	�3�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	�Zd
S)�TestCommandLinesThis is a simple test with gzipc�B�tj��5}t�|d���5}|�|j��ddd��n#1swxYwYtjdddf}t|ttt���5}|�
|�����\}}ddd��n#1swxYwYddd��n#1swxYwY|�|d��|�||j��dS)NrAr�-mr�-d��stdin�stdout�stderrr)
rr�rr5r6r:�sys�
executablerr�communicaterr7)r�bytes_io�	gzip_filer�proc�out�errs       r�test_decompress_stdin_stdoutz,TestCommandLine.test_decompress_stdin_stdouts���
�Z�\�\�	A�X����x�d��;�;�
+�y�����	�*�*�*�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+����
+�
+�
+�
+��>�4���5�D��t�4��T�B�B�B�
A�d��+�+�H�,=�,=�,?�,?�@�@���S�
A�
A�
A�
A�
A�
A�
A�
A�
A�
A�
A����
A�
A�
A�
A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A�	
����c�"�"�"�����d�i�(�(�(�(�(sX�C#�A�C#�A	�C#�A	� 5C#�+C�C#�C	�C#�C	�C#�#C'�*C'c�T�tj�td��}|�tj�|����t�|d���5}|�|j	��ddd��n#1swxYwYtddd|��\}}}ttj�td��d��5}|�|���|j	��ddd��n#1swxYwY|�
tj�|����|�|d	��|�|d
��|�|d
��dS)Nztestgzip.gzrA)r;r�rr��testgziprkrr)rH�pathru�TEMPDIRr��existsrr�r6r:r
r7r9r�)r�gzipname�fp�rcr�r��gunzipeds       r�test_decompress_infile_outfilez.TestCommandLine.test_decompress_infile_outfiles����7�<�<���7�7����������1�1�2�2�2�
�Y�Y�x�d�Y�
+�
+�	 �r��H�H�T�Y����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �'��f�d�H�E�E���C��
�"�'�,�,�w�
�3�3�T�
:�
:�	9�h����X�]�]�_�_�d�i�8�8�8�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9�	9����	9�	9�	9�	9�	
�������x�0�0�1�1�1�����Q��������c�"�"�"�����c�"�"�"�"�"s$�4B�B�"B�/.D)�)D-�0D-c���tdddd��\}}}|�d|�����|�|d��|�|d��dS)Nr�rr�zthisisatest.outs.filename doesn't end in .gz: 'thisisatest.out'ryr)rr7�strip�rr�r�r�s    r�$test_decompress_infile_outfile_errorz4TestCommandLine.test_decompress_infile_outfile_error"sm��,�T�6�4�AR�S�S���C�����J�C�I�I�K�K�X�X�X�����Q��������c�"�"�"�"�"rc�:�tjddf}t|ttt���5}|�|j��\}}ddd��n#1swxYwY|�|d��|�|dd�d��dS)Nr�rr�rr�r�)r�r�rrr�r:r7)rrr�r�r�s     r�test_compress_stdin_outfilez+TestCommandLine.test_compress_stdin_outfile(s����~�t�V�+��
�4�t�D��
>�
>�
>�	3�$��'�'��	�2�2�H�C��	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	
����c�"�"�"�����R�a�R��+�.�.�.�.�.s�A�A �#A c�(�tj�td��}|dz}|�tj�|����t
|d��5}|�|j��ddd��n#1swxYwYtdd|��\}}}|�
tj�|����|�|d��|�|d��dS)Nr��.gzrAr�rr)rHr�rur�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_default2s$������g�z�:�:��!�E�)����������1�1�2�2�2�
�.�$�
'�
'�	 �2��H�H�T�Y����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �(��f�n�E�E���C���������x�0�0�1�1�1�����c�"�"�"�����c�"�"�"�"�"s�-B�B�Bc� �dD�]�}|�|���5tj�td��}|dz}|�tj�|����t|d��5}|�|j	��ddd��n#1swxYwYtdd||��\}}}|�tj�|����|�|d��|�|d��tj
|��|�tj�|����ddd��n#1swxYwY���dS)	N)�--fast�--best)�compress_levelr�r�rAr�rr)r�rHr�rur�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_outfileAs���2�	;�	;�N����^��<�<�
;�
;�!#����g�z�!B�!B��)�E�1��� � ������!9�!9�:�:�:��.�$�/�/�(�2��H�H�T�Y�'�'�'�(�(�(�(�(�(�(�(�(�(�(����(�(�(�(� 0��f�n�n�]�]���C���������x� 8� 8�9�9�9�� � ��c�*�*�*�� � ��c�*�*�*��	�(�#�#�#�� � ������!9�!9�:�:�:�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;��	;�	;s7�A-F�	B0�$F�0B4�4F�7B4�8B=F�F	�F	c��tdddd��\}}}|�d|��|�|d��dS)Nr�rr�r�s8error: argument --best: not allowed with argument --fastr�rrLr7r�s    r�%test_compress_fast_best_are_exclusivez5TestCommandLine.test_compress_fast_best_are_exclusiveTsM��,�T�6�8�X�N�N���C���
�
�Q�SV�W�W�W�����c�"�"�"�"�"rc��tdddd��\}}}|�d|��|�|d��dS)Nr�rr�r�sAerror: argument -d/--decompress: not allowed with argument --fastrr�r�s    r�-test_decompress_cannot_have_flags_compressionz=TestCommandLine.test_decompress_cannot_have_flags_compressionYsM��,�T�6�8�T�J�J���C���
�
�Z�\_�`�`�`�����c�"�"�"�"�"rN)r r!r"r:r	r�r�r�r�r�r�r�r�r�r�rrrr�r�s������-�D�����
)�
)���
)�!� ��)�)�#�#�*�)�#� #�#�#����� � ��)�)�/�/�*�)���/�!� ��)�)�#�#�*�)�#�!� ��)�)�;�;�*�)�;�$#�#�#�
#�#�#�#�#rr��__main__)'�__doc__rgr�rrHrOr�r��unittest�
subprocessrr�test.supportrrrrr	�test.support.script_helperr
r�
import_modulerrDr�r��abspathr-r�r�r�TestCaser$r/rqr�r�r �mainrrr�<module>r�s5����
��������	�	�	�	�	�	�	�	�����
�
�
�
�
�
�
�
�����"�"�"�"�"�"�"�"�&�&�&�&�&�&�"�"�"�"�"�"�=�=�=�=�=�=�=�=�=�=�N�N�N�N�N�N�N�N�"�}�"�6�*�*��	��	��
�'�/�/�)�*�
+�
+�h�
6��&�&�&�&�&�2�:�&�&�&�(�(�(�(�(�x� �(�(�(�p/�p/�p/�p/�p/�x�p/�p/�p/�fE<�E<�E<�E<�E<�x�E<�E<�E<�P
�
�
�[#�[#�[#�[#�[#�h�'�[#�[#�[#�|�z����H�M�O�O�O�O�O��r