Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.133.107.136
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_gzip.cpython-310.pyc
o

`b�z�@s&dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
ddlmZddlmZmZddlmZmZe
�d�Zd	Zd
Zej�ej�dZGdd
�d
ej�ZGdd�dej�ZGdd�de�Z Gdd�de�Z!dd�Z"Gdd�dej�Z#e$dkr�e�%�dSdS)z!Test script for the gzip module.
�N)�PIPE�Popen)�
import_helper)�	os_helper)�_4G�
bigmemtest)�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@s$eZdZdd�Zdd�Zdd�ZdS)�UnseekableIOcCsdS)NF���selfrr�7/usr/local/python-3.10/lib/python3.10/test/test_gzip.py�seekable%szUnseekableIO.seekablecC�tj��N��io�UnsupportedOperationr
rrr�tell(�zUnseekableIO.tellcGrrr)r�argsrrr�seek+rzUnseekableIO.seekN)�__name__�
__module__�__qualname__rrrrrrrr$src@s"eZdZejZdd�Zdd�ZdS)�BaseTestcC�t�|j�dSr�r�unlink�filenamer
rrr�setUp2�zBaseTest.setUpcCrrrr
rrr�tearDown5r#zBaseTest.tearDownN)rrrr�TESTFNr!r"r$rrrrr/src@s�eZdZd_dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zee
dd�dd��Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!d>d?�Z"d@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,dTdU�Z-dVdW�Z.dXdY�Z/dZd[�Z0d\d]�Z1d^S)`�TestGzip�bcCs�t|�}t�|jd|��
}|�|�}Wd�n1swY|�|t|��t�|jd|��}|�|��|�Wd�dS1sGwYdS)N�w�r)�bytesr
�GzipFiler!�write�assertEqual�len�read)r�data�modeZb_data�f�lrrr�write_and_read_back:s�"�zTestGzip.write_and_read_backcCsxt�|jd��'}|�td�|��|��ttd�r#t�	|���|�
�Wd�n1s1wY|�
�dS)N�wb�2�fsync)r
r+r!r,�data1�flush�fileno�hasattr�osr7�close�rr2rrr�
test_writeBs

�zTestGzip.test_writecCs�t�|j�}t�|d��}|�td�Wd�n1swY|�|jt	�t�|d��
}|�t�Wd�n1s@wYt�|��}|�
�}Wd�n1sYwY|�|td�|�|jt	�dS)Nr(r6�a�3)�pathlib�Pathr!r
r+r,r8ZassertIsInstance�name�strr/r-)rr!r2�drrr�"test_write_read_with_pathlike_filePs��
�z+TestGzip.test_write_read_with_pathlike_filecCsB|�ttd��tttd���}|jdgd�d�}|�|�dS)Nr6��B)�rJ�)�shape)r4�
memoryviewr8r*�range�cast)r�mr0rrr�test_write_memoryview_szTestGzip.test_write_memoryviewcCs|�ttd��dS)Nr6)r4�	bytearrayr8r
rrr�test_write_bytearraye�zTestGzip.test_write_bytearraycCs|�t�dtd��dS)N�I�()r4�arrayr8r
rrr�test_write_arrayhszTestGzip.test_write_arrayc	Cs�t�|jd��A}|�t��
|�d�Wd�n1swY|�t��
|�g�Wd�n1s7wY|�t�Wd�n1sKwYt�|jd��}|�|��t�Wd�dS1skwYdS)Nr5��rb)	r
r+r!�assertRaises�	TypeErrorr,r8r-r/r>rrr�test_write_incompatible_typeks���"�z%TestGzip.test_write_incompatible_typecCsR|��t�|jd��}|��}Wd�n1swY|�|td�dS)Nr)r6)r?r
r+r!r/r-r8�rr2rFrrr�	test_readxs

�zTestGzip.test_readcCs�|��g}d}t�|jd��$}	|��}|sq,|�|�|t|�7}|�|��|�qWd�n1s6wY|�d�	|�t
d�dS)Nrr)T�r6)r?r
r+r!�read1�appendr.r-r�joinr8)rZblocks�nreadr2rFrrr�
test_read1s
��	zTestGzip.test_read1�)�sizeZmemusecCs8tjtdd�}tjt�|�dd�}|�|�|�t�dS)Nrf��
compresslevelrZ��fileobjr1)r
�compressr8r+r�BytesIOr-r/)rrg�
compressedr2rrr�test_read_large�szTestGzip.test_read_largecCsv|��t�|jd�}|j}|�|j�|��|�|j�|�	t
��
|�d�Wd�n1s3wY|�	t
��
|�d�Wd�n1sMwY|�	t
��|�
�Wd�n1sfwYt�|jd�}|j}|�|j�|��|�|j�|�	t
��
|�d�Wd�n1s�wY|�	t
��
|��Wd�dS1s�wYdS)Nr)rfrr(r`)r?r
r+r!rk�assertFalse�closedr=�
assertTruer[�
ValueErrorr/rrr,r9)rr2rkrrr�test_io_on_closed_object�s4��
��
"�z!TestGzip.test_io_on_closed_objectcCs�|��t�|jd��}|�td�Wd�n1swYt�|jd��}|��}Wd�n1s8wY|�|tdtd�dS)N�ab�rZr6)	r?r
r+r!r,�data2r/r-r8r^rrr�test_append�s�
�zTestGzip.test_appendc	Cs�t�|jdd��
}|�d�Wd�n1swYtdd�D]}t�|jdd��
}|�d�Wd�n1s<wYq"t�|jd��}d}	|�d
�}||7}|sYqZqMWd�n1sdwY|�|d�dS)Nr5�	�ar��rurZr`rfi s�aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)r
r+r!r,rNr/r-)rr2�iZzgfile�contentsZztxtrrr�test_many_append�s$���
��zTestGzip.test_many_appendcCs�t�|jd��}|�td�Wd�n1swYt�|jd��}|�|��td�Wd�n1s:wY|�t��t�|jd�Wd�dS1sWwYdS)N�xbr6rZ)	r
r+r!r,r8r-r/r[�FileExistsErrorr>rrr�test_exclusive_write�s��"�zTestGzip.test_exclusive_writec	Cs�|��t�|jd��$}t�|��}dd�|D�}Wd�n1s#wYWd�n1s2wY|�|dtjdd��dS)NrZcSsg|]}|�qSrr)�.0�linerrr�
<listcomp>�sz1TestGzip.test_buffered_reader.<locals>.<listcomp>r6T��keepends)	r?r
r+r!r�BufferedReaderr-r8�
splitlines)rr2r)�linesrrr�test_buffered_reader�s���zTestGzip.test_buffered_readercCsz|��t�|jd��(}d}	|�|�}|s|dkrq+|�t|�|k�|dd}qWd�dS1s6wYdS)NrZrrfr6)r?r
r+r!�readlinerrr.)rr2Zline_length�Lrrr�
test_readline�s
�"�zTestGzip.test_readlinecCs�|��t�|jd��}|��}Wd�n1swYt�|jd��}	|�d�}|gkr2q3q(Wd�dS1s>wYdS)NrZrf�)r?r
r+r!�	readlines)rr2r�rrr�test_readlines�s
�

�"�zTestGzip.test_readlinescCs�|��t�|j��@}	|��}|��}|sqB|��}|�|�t|�dkr)d}nt|�}|�|�}|�	|d|�|�|�|�qWd�dS1sMwYdS)Nrf�
)
r?r
r+r!rr�rr.r/r-)rr2ZoldposZline1Znewpos�amountZline2rrr�test_seek_read�s"


�"�zTestGzip.test_seek_readcCsn|��t�|j��}|�d�|jddd�|�d�}Wd�n1s&wY|�|tdd��dS)Nr�rf)�whence��)r?r
r+r!r/rr-r8)rr2�yrrr�test_seek_whence
s
�zTestGzip.test_seek_whencecCsZt�|jd��}tddd�D]}|�|�|�d�qWd�dS1s&wYdS)Nr(rrH�sGZ
)r
r+r!rNrr,)rr2�posrrr�test_seek_writes
�"�zTestGzip.test_seek_writecCs�|��t�|jd��}|�|jjd�Wd�n1swYt�|j�t�|jd��}|�|jjd�Wd�dS1sDwYdS)Nr)rZ�xr)	r?r
r+r!r-Z	myfileobjr1rr r>rrr�	test_modes�"�zTestGzip.test_modec	Cs\dD])}t�|j|��}|�t|d��|�|j|j�Wd�n1s&wYqdS)N)r5rZrD)r
r+r!rrr;r-rD)rr1r2rrr�test_1647484&s���zTestGzip.test_1647484cCs`|��t�|jd��}|�t|jd��|�|jj|j�Wd�dS1s)wYdS)NrZrD)	r?r
r+r!rrr;rkr-rDr>rrr�test_paddedfile_getattr,s
"�z TestGzip.test_paddedfile_getattrcCs�d}tj|jd|d��
}|�t�Wd�n1swYt�|j��(}|�t|d��|�|j�|�	�}|�
|t�|�
|j|�Wd�dS1sQwYdS)N��[r(��mtimer�)r
r+r!r,r8rrr;ZassertIsNoner�r/r-)rr��fWrite�fReadZdataReadrrr�
test_mtime2s�"�zTestGzip.test_mtimec	Cs�d}tj|jd|d��
}|�t�Wd�n1swYt|jd���}|�d�}|�|d�|�d�}|�|d�z|j�d	�d
}d}Wn
t	yVd}d
}Ynw|�d�}|�||�|�d�}	|�|	t
�d
|��|�d�}
|�|
d�|�d�}|�|d�|�t|��}|�||�|�
t�|j�jd�|�d�}
|�|
d�|�d�}|�|t
�d
tt���Wd�dS1s�wYdS)Nr�r(r�rZ���rf�zLatin-1�r`rKz<i���rJs��d�)r
r+r!r,r8�openr/r-�encode�UnicodeEncodeError�struct�packr.rr<�stat�st_size)rr�r�r�ZidBytesZcmByteZexpectednameZ
expectedflagsZ	flagsByteZ
mtimeBytes�xflByteZosByteZ	nameBytesZ
crc32BytesZ
isizeBytesrrr�
test_metadata=s@�

�





"�zTestGzip.test_metadatacCstj|_|��dSr)rZTESTFN_ASCIIr!r�r
rrr�test_metadata_ascii_namepsz!TestGzip.test_metadata_ascii_namec	
Cs�gd�}d}|D]`\}}}|�|��Ntj|jd|d�}|�
|�t�Wd�n1s.wYt|jd��}|�|�|�d�}|�	||�Wd�n1sTwYWd�n1scwYqdS)N))�fastrf�)Zbestryr�)Ztradeoff�r�rJr(rhrZrf)
�subTestr
r+r!r,r8r�rr/r-)	r�casesZ	xflOffsetrD�levelZexpectedXflByter�r�r�rrr�test_compresslevel_metadatats"�

�����z$TestGzip.test_compresslevel_metadatacCs�t�|jd��
}|�d�Wd�n1swYt�|jd�}|��z|�Wd�n1s5wYWn	tyDYnw|�d�zt�|jd��}ddWd�n1sawYWn
tyqYdSw|�d�dS)Nr5sxxxrZz4__enter__ on a closed file didn't raise an exceptionrfrz1/0 didn't raise an exception)r
r+r!r,r=rsZfail�ZeroDivisionErrorr>rrr�test_with_open�s.����

���zTestGzip.test_with_opencCs�t�|jd��}|�td�Wd�n1swYt|jd��
}|�d�Wd�n1s4wYt�|jd��}|��}|�|tdd�Wd�dS1sYwYdS)Nr5r6rus2rZzIncorrect data in file)r
r+r!r,r8r�r/r-r^rrr�test_zero_padded_file�s��"�zTestGzip.test_zero_padded_filecCs|�ttjt��dSr)rr�
issubclassr
�BadGzipFile�OSErrorr
rrr�test_gzip_BadGzipFile_exception�rTz(TestGzip.test_gzip_BadGzipFile_exceptioncCs~t|jd��}|�td�Wd�n1swYt�|jd��}|�tj|j�Wd�dS1s8wYdS)Nr5r6r))	r�r!r,r8r
r+r[r�r�)r�filerrr�test_bad_gzip_file�s�"�zTestGzip.test_bad_gzip_filecCs�td}t�}tj|dd��
}|�|�Wd�n1swY|��}t|�}tj|dd��}|�|��|�Wd�dS1sFwYdS)Nr6r5rjrZ)r8rr
r+r,�getvaluer-r/)r�uncompressed�bufr2rnrrr�test_non_seekable_file�s�"�zTestGzip.test_non_seekable_filecCs�td}t�|jd��
}|�|�Wd�n1swYdd�}t�|jd��A}d|_d}|�D]}|�|�}|dkrAqS|�|�t	|��|�|t	|�7}q4|�|�d	�d�|�|t	|��Wd�dS1sowYdS)
Nr{r5css�	tddd�D]}|Vqq)NT�r6r�)rN)�nrrr�sizes�s
��z!TestGzip.test_peek.<locals>.sizesrZ�!rr`�d)
r8r
r+r!r,Zmax_read_chunk�peekr-r/r.)rr�r2r�rdr��srrr�	test_peek�s"�

"�zTestGzip.test_peekc	Cs�td�d�jdd�}|��t�|jd��0}tj|dd��}|�	|�
�|�Wd�n1s1wYWd�dSWd�dS1sIwYdS)Nr6�asciiTr�r)��encoding)r8�decoder�r?r
r+r!r�
TextIOWrapperr-r�)rr�r2�trrr�test_textio_readlines�s��"�zTestGzip.test_textio_readlinesc	Cs�t�|jtjtjB�}t�|d��(}tj|dd��}Wd�n1s$wYWd�dSWd�dS1s<wYdS)Nr5r(rj)r<r�r!�O_WRONLY�O_CREAT�fdopenr
r+)r�fdr2�grrr�test_fileobj_from_fdopen�s��"�z!TestGzip.test_fileobj_from_fdopenc
Cs�t�|jd���t|jd���}tj|dd��}|�|jtj�Wd�n1s*wYtj|dd��}|�|jtj�Wd�n1sIwYtj|dd��}|�|jtj�Wd�n1shwYtj|dd��}|�|jtj�Wd�n1s�wY|�	t
��tj|dd�Wd�n1s�wYWd�n1s�wYd	D]6}t|j|��&}tj|d
��}|�|jtj�Wd�n1s�wYWd�n1s�wYq�dD]Z}d|vr�t�|j�t|j|��?}|�
t��tj|d
�}Wd�n	1�swY|�|�|jtj�Wd�n	1�s7wYWd�n	1�sGwYq�dS)Nr5�r+br)rjr(r@r��z)rZr��rk)r5rur)r
r+r!r=r�r-r1ZREADZWRITEr[rsrr ZassertWarns�
FutureWarning)rr2r�r1rrr�test_fileobj_mode�sR�����������������zTestGzip.test_fileobj_modecCs�|j}z|�d�}Wnty|�d�Ynwt�|d��}|�td�Wd�n1s1wYt�|d��}|�|�	�td�Wd�n1sQwYt�|d��}|�|�	�td�Wd�dS1srwYdS)Nr�z%Temporary file name needs to be ASCIIr5r6rZ)
r!r�r�ZskipTestr
r+r,r8r-r/)rZstr_filenameZbytes_filenamer2rrr�test_bytes_filename�s���"�zTestGzip.test_bytes_filenamecCsttjdtd�dd�}|�t|�tj�t�|�}tj|d�}|�	|�
d�d�dtj}|�|jj
��|d�dS)	z-Decompressed data buffering should be limitedr�g��>Aryrhr�rfz)Excessive amount of data was decompressedN)r
rl�intZ
assertLessr.r�DEFAULT_BUFFER_SIZErmr+r-r/ZassertLessEqual�_buffer�rawr)rZbomb�decompZ
max_decomprrr�test_decompress_limited
s

�z TestGzip.test_decompress_limitedc
Cs�ttfD]:}dD]5}tj|g|�R�}|�t|�t�tjt�	|�dd��}|�|�
�|�Wd�n1s8wYqqdS)N�r)rf)r�)ryrZrj)r8rwr
rlr-�typer*r+rrmr/)rr0r�datacr2rrr�
test_compresss����zTestGzip.test_compresscCs�d}ttfD]X}dD]S}|j||d��Btj|g|�Rd|i�}|�t|�t�tjt	�
|�dd��}|�d�|�|j|�Wd�n1sIwYWd�n1sXwYq
qdS)Nr�r�)r0rr�rZrjrf)
r8rwr�r
rlr-r�r*r+rrmr/r�)rr�r0rr�r2rrr�test_compress_mtime s
������zTestGzip.test_compress_mtimec	Cs�ttfD];}t��}tj|dd��
}|�|�Wd�n1s!wY|�t�|�	��|�t�
|�}|�t�|�|�qdS)Nr5rj)r8rwrrmr
r+r,r-�
decompressr�rl)rr0r�r2r�rrr�test_decompress+s�
�zTestGzip.test_decompressc	Cstd}t�|�dd�}tjt�|�d��}|�t|j�Wd�n1s(wYtjt�|�d��}|�	|�t
|��|�|�t|jd�Wd�n1sTwYtdd�D]'}tjt�|d|��d��}|�t|jd�Wd�n1s�wYq^dS)Nr6i����r�rfr�r�)r8r
rlr+rrmr[�EOFErrorr/r-r.rN)rr0Z	truncatedr2r|rrr�test_read_truncated5s�����zTestGzip.test_read_truncatedcCsLd}tjt�|�d��}|�|��d�Wd�dS1swYdS)Ns��cQ�ExtraI-.2�Mxr�sTest)r
r+rrmr-r/)rZgzdatar2rrr�test_read_with_extraCs"�zTestGzip.test_read_with_extracCszt�|jd��
}|�t�Wd�n1swYt�|jd��}|jjj��Wd�dS1s6wYdS)Nr5rZ)	r
r�r!r,r8r�r��_fpZprependr>rrr�test_prepend_errorKs�"�zTestGzip.test_prepend_errorcCsxt�dgd��}t|�|j}tjt��dd��}|�|�|�|�|�|�	�|�Wd�dS1s5wYdS)N�Q)rfr��rKr�r(rj)
rWr.�itemsizer
r+rrmr-r,r)r�qZLENGTHr2rrr�test_issue44439Rs"�zTestGzip.test_issue44439N)r')2rrrr4r?rGrQrSrXr]r_rerrrortrxr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr&9s^





3

r&c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestOpencCstd}t�|jd��
}|�|�Wd�n1swYt|jd��}t�|���}|�||�Wd�n1s>wYt�|jd��}|�|��|�Wd�n1s]wYt�|jd��
}|�|�Wd�n1sywYt|jd��}t�|���}|�||d�Wd�n1s�wY|�t	��t�|jd�Wd�n1s�wYt
�|j�t�|jd��
}|�|�Wd�n1s�wYt|jd��}t�|���}|�||�Wd�dS1�swYdS)Nr6r5rZrur�r�r8r
r�r!r,r�r/r-r[r�rr �rr�r2�	file_datarrr�test_binary_modes\s:�������$�zTestOpen.test_binary_modescCs�t�|j�}t�|d��}|�td�Wd�n1swYt�|d��
}|�t�Wd�n1s9wYt�|��}|�|��td�Wd�dS1sYwYdS)Nr5r6rurA)	rBrCr!r
r�r,r8r-r/)rr!r2rrr�test_pathlike_filews��"�zTestOpen.test_pathlike_filecCstd}t�|jd��
}|�|�Wd�n1swYt|jd��}t�|���}|�||�Wd�n1s>wYt�|jd��}|�|��|�Wd�n1s]wYt�|jd��
}|�|�Wd�n1sywYt|jd��}t�|���}|�||d�Wd�n1s�wY|�t	��t�|jd�Wd�n1s�wYt
�|j�t�|jd��
}|�|�Wd�n1s�wYt|jd��}t�|���}|�||�Wd�dS1�swYdS)Nr6r(rZr)r@r�r�r�r�rrr�test_implicit_binary_modes�s:�������$�z#TestOpen.test_implicit_binary_modescCsxt�d�d}|�dtj�}tj|jddd��
}|�|�Wd�n1s'wYt|jd��}t�	|�
���d�}|�||�Wd�n1sMwYtj|jddd��}|�|�
�|�Wd�n1snwYtj|jddd��
}|�|�Wd�n1s�wYt|jd��}t�	|�
���d�}|�||d	�Wd�dS1s�wYdS)
Nr�r6�
�wtr�rZ�rtZatr��r8r��replacer<�linesepr
r�r!r,r�r/r-�rr�Zuncompressed_rawr2r�rrr�test_text_modes�s&����"�zTestOpen.test_text_modescCs�td}|�d�}t�|�}t�t�|�d��}|�|��|�Wd�n1s*wYt�t�|�d��}|�|��|�Wd�n1sKwYtjt�|�ddd��}|�|��|�Wd�dS1sowYdS)Nr6r�r)rZrr�)	r8r�r
rlr�rrmr-r/)rZuncompressed_bytesZuncompressed_strrnr2rrr�test_fileobj�s

��"�zTestOpen.test_fileobjcCs^|�t��
t�d�Wd�n1swY|�t��t�|jd�Wd�n1s1wY|�t��t�|jd�Wd�n1sMwY|�t��tj|jddd�Wd�n1skwY|�t��tj|jddd�Wd�n1s�wY|�t��tj|jdd	d
�Wd�dS1s�wYdS)Ngw��/�^@ZwbtZxbtrZzutf-8r��ignore)�errorsr)�newline)r[r\r
r�rsr!r
rrr�test_bad_params�s$�����"�zTestOpen.test_bad_paramscCs�t�d�d}|�dtj�}tj|jddd��
}|�|�Wd�n1s'wYt|jd��}t�	|�
���d�}|�||�Wd�n1sMwYtj|jddd��}|�|�
�|�Wd�dS1sowYdS)	Nr�r6rrzutf-16r�rZrrr	rrr�
test_encoding�s��"�zTestOpen.test_encodingcCs�t�|jd��
}|�d�Wd�n1swYtj|jdddd��}|�|��d�Wd�dS1s:wYdS)Nr5sfoo�barrr�r)r�r
Zfoobar)r
r�r!r,r-r/r>rrr�test_encoding_error_handler�s�"�z$TestOpen.test_encoding_error_handlercCs�t�d�d}tj|jdddd��
}|�|�Wd�n1s!wYtj|jdddd��}|�|��|g�Wd�dS1sEwYdS)Nr�r6rr)r�rr�
)r8r�r
r�r!r,r-r�)rr�r2rrr�test_newline�s�"�zTestOpen.test_newlineN)rrrrrrr
rrrrrrrrrr�[s	r�cs�fdd�}|S)Ncst�����fdd��}|S)Nc	s2t���z
�|i|��Wt���St���wr)r<�makedirsr�rmtree)r�kwargs)�	directory�functionrr�wrapper�s
z?create_and_remove_directory.<locals>.decorator.<locals>.wrapper)�	functools�wraps)rr�r)rr�	decorator�sz.create_and_remove_directory.<locals>.decoratorr)rrrrr�create_and_remove_directory�s	rc@speZdZdZdd�Zee�dd��Zdd�Zee�dd	��Z	ee�d
d��Z
ee�dd
��Zdd�Zdd�Z
dS)�TestCommandLinesThis is a simple test with gzipc	Cs�t���M}tj|dd��}|�|j�Wd�n1swYtjdddf}t|t	t	t	d��}|�
|���\}}Wd�n1sEwYWd�n1sTwY|�|d�|�||j�dS)Nr5rj�-mr
�-d��stdin�stdout�stderrr`)
rrmr
r+r,r0�sys�
executablerr�communicater�r-)rZbytes_ioZ	gzip_filer�proc�out�errrrr�test_decompress_stdin_stdout�s
����z,TestCommandLine.test_decompress_stdin_stdoutcCs�tj�td�}|�tj�|��tj|dd��}|�|j	�Wd�n1s(wYt
ddd|�\}}}ttj�td�d��}|�|��|j	�Wd�n1sUwY|�
tj�|��|�|d	�|�|d
�|�|d
�dS)Nztestgzip.gzr5)r1r r
r!�testgziprZrr`)r<�pathrc�TEMPDIRrp�existsr
r�r,r0rr-r/rr)r�gzipname�fp�rcr*r+Zgunzipedrrr�test_decompress_infile_outfile�s��z.TestCommandLine.test_decompress_infile_outfilecCs@tdddd�\}}}|�d|���|�|d�|�|d�dS)Nr r
r!zthisisatest.outs.filename doesn't end in .gz: 'thisisatest.out'rfr`)r	r-�strip�rr3r*r+rrr�$test_decompress_infile_outfile_errorsz4TestCommandLine.test_decompress_infile_outfile_errorcCsptjddf}t|tttd��}|�|j�\}}Wd�n1s!wY|�|d�|�|dd�d�dS)Nr r
r"r`r�r�)r&r'rrr(r0r-)rrr)r*r+rrr�test_compress_stdin_outfiles�z+TestCommandLine.test_compress_stdin_outfilecCs�tj�td�}|d}|�tj�|��t|d��}|�|j�Wd�n1s*wYt	dd|�\}}}|�
tj�|��|�|d�|�|d�dS)Nr-�.gzr5r r
r`)r<r.rcr/rpr0r�r,r0rrrr-)r�local_testgzipr1r2r3r*r+rrr�$test_compress_infile_outfile_defaults�z4TestCommandLine.test_compress_infile_outfile_defaultc
Cs�dD]t}|j|d��dtj�td�}|d}|�tj�|��t|d��}|�|j	�Wd�n1s5wYt
dd||�\}}}|�tj�|��|�|d�|�|d�t�
|�|�tj�|��Wd�n1sqwYqdS)	N)�--fast�--best)�compress_levelr-r9r5r r
r`)r�r<r.rcr/rpr0r�r,r0rrrr-�remove)rr>r:r1r2r3r*r+rrr�test_compress_infile_outfile.s"�
���z,TestCommandLine.test_compress_infile_outfilecC�0tdddd�\}}}|�d|�|�|d�dS)Nr r
r<r=s8error: argument --best: not allowed with argument --fastr`�r	ZassertInr-r6rrr�%test_compress_fast_best_are_exclusiveA�z5TestCommandLine.test_compress_fast_best_are_exclusivecCrA)Nr r
r<r!sAerror: argument -d/--decompress: not allowed with argument --fastr`rBr6rrr�-test_decompress_cannot_have_flags_compressionFrDz=TestCommandLine.test_decompress_cannot_have_flags_compressionN)rrrr0r,rr/r4r7r8r;r@rCrErrrrr�s



r�__main__)&�__doc__rWrrr<rBr�r&Zunittest�
subprocessrrZtest.supportrrrrZtest.support.script_helperrr	�
import_moduler
r8rwr.�abspathr%r/rmrZTestCaserr&r�rrr�mainrrrr�<module>s@

&	
\�
© 2025 GrazzMean