Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_gzip.cpython-310.pyc
o

�9j�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�%/usr/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�mode�b_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�osr8�close�rr3r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(r7�a�3)�pathlib�Pathr!r
r+r,r9�assertIsInstance�name�strr/r-)rr!r3�drrr�"test_write_read_with_pathlike_filePs��
�z+TestGzip.test_write_read_with_pathlike_filecCsB|�ttd��tttd���}|jdgd�d�}|�|�dS)Nr7��B)�rL�)�shape)r5�
memoryviewr9r*�range�cast)r�mr0rrr�test_write_memoryview_szTestGzip.test_write_memoryviewcCs|�ttd��dS)Nr7)r5�	bytearrayr9r
rrr�test_write_bytearraye�zTestGzip.test_write_bytearraycCs|�t�dtd��dS)N�I�()r5�arrayr9r
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)Nr6��rb)	r
r+r!�assertRaises�	TypeErrorr,r9r-r/r?rrr�test_write_incompatible_typeks���"�z%TestGzip.test_write_incompatible_typecCsR|��t�|jd��}|��}Wd�n1swY|�|td�dS)Nr)r7)r@r
r+r!r/r-r9�rr3rHrrr�	test_readxs

�zTestGzip.test_readcCs�|��g}d}t�|jd��$}	|��}|sn|�|�|t|�7}|�|��|�qWd�n1s6wY|�d�	|�t
d�dS)Nrr)T�r7)r@r
r+r!�read1�appendr.r-r�joinr9)r�blocks�nreadr3rHrrr�
test_read1s
��	zTestGzip.test_read1�)�size�memusecCs8tjtdd�}tjt�|�dd�}|�|�|�t�dS)Nri��
compresslevelr\��fileobjr1)r
�compressr9r+r�BytesIOr-r/)rrj�
compressedr3r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)rirr(rb)r@r
r+r!ro�assertFalse�closedr>�
assertTruer]�
ValueErrorr/rrr,r:)rr3ror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�r\r7)	r@r
r+r!r,�data2r/r-r9r`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}|sYnqMWd�n1sdwY|�|d�dS)Nr6�	�ar��ryr\rbrii s�aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)r
r+r!r,rPr/r-)rr3�i�zgfile�contents�ztxtr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�xbr7r\)	r
r+r!r,r9r-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)Nr\cSsg|]}|�qSrr)�.0�linerrr�
<listcomp>�sz1TestGzip.test_buffered_reader.<locals>.<listcomp>r7T��keepends)	r@r
r+r!r�BufferedReaderr-r9�
splitlines)rr3r)�linesrrr�test_buffered_reader�s���zTestGzip.test_buffered_readercCsz|��t�|jd��(}d}	|�|�}|s|dkrn|�t|�|k�|dd}qWd�dS1s6wYdS)Nr\rrir7)r@r
r+r!�readlinervr.)rr3�line_length�Lrrr�
test_readline�s
�"�zTestGzip.test_readlinecCs�|��t�|jd��}|��}Wd�n1swYt�|jd��}	|�d�}|gkr2nq(Wd�dS1s>wYdS)Nr\ri�)r@r
r+r!�	readlines)rr3r�rrr�test_readlines�s
�

�"�zTestGzip.test_readlinescCs�|��t�|j��@}	|��}|��}|sn+|��}|�|�t|�dkr)d}nt|�}|�|�}|�	|d|�|�|�|�qWd�dS1sMwYdS)Nri�
)
r@r
r+r!rr�rr.r/r-)rr3�oldpos�line1�newpos�amount�line2rrr�test_seek_read�s"


�"�zTestGzip.test_seek_readcCsn|��t�|j��}|�d�|jddd�|�d�}Wd�n1s&wY|�|tdd��dS)Nr�ri)�whence��)r@r
r+r!r/rr-r9)rr3�yrrr�test_seek_whence
s
�zTestGzip.test_seek_whencecCsZt�|jd��}tddd�D]}|�|�|�d�qWd�dS1s&wYdS)Nr(rrJ�sGZ
)r
r+r!rPrr,)rr3�posrrr�test_seek_writes
�"�zTestGzip.test_seek_writecCs�|��t�|jd��}|�|jjd�Wd�n1swYt�|j�t�|jd��}|�|jjd�Wd�dS1sDwYdS)Nr)r\�xr�)	r@r
r+r!r-�	myfileobjr1rr r?rrr�	test_modes�"�zTestGzip.test_modec	Cs\dD])}t�|j|��}|�t|d��|�|j|j�Wd�n1s&wYqdS)N)r6r\rF)r
r+r!rvr<r-rF)rr1r3rrr�test_1647484&s���zTestGzip.test_1647484cCs`|��t�|jd��}|�t|jd��|�|jj|j�Wd�dS1s)wYdS)Nr\rF)	r@r
r+r!rvr<ror-rFr?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,r9rvr<�assertIsNoner�r/r-)rr��fWrite�fRead�dataReadr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�r\���ri�zLatin-1�rbrMz<i���rLs��d�)r
r+r!r,r9�openr/r-�encode�UnicodeEncodeError�struct�packr.rr=�stat�st_size)rr�r�r��idBytes�cmByte�expectedname�
expectedflags�	flagsByte�
mtimeBytes�xflByte�osByte�	nameBytes�
crc32Bytes�
isizeBytesrrr�
test_metadata=s@�

�





"�zTestGzip.test_metadatacCstj|_|��dSr)r�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))�fastri�)�bestr}r�)�tradeoff�r�rLr(rlr\ri)
�subTestr
r+r!r,r9r�rr/r-)	r�cases�	xflOffsetrF�level�expectedXflByter�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)Nr6sxxxr\z4__enter__ on a closed file didn't raise an exceptionrirz1/0 didn't raise an exception)r
r+r!r,r>rw�fail�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)Nr6r7rys2r\zIncorrect data in file)r
r+r!r,r9r�r/r-r`rrr�test_zero_padded_file�s��"�zTestGzip.test_zero_padded_filecCs|�ttjt��dSr)rv�
issubclassr
�BadGzipFile�OSErrorr
rrr�test_gzip_BadGzipFile_exception�rVz(TestGzip.test_gzip_BadGzipFile_exceptioncCs~t|jd��}|�td�Wd�n1swYt�|jd��}|�tj|j�Wd�dS1s8wYdS)Nr6r7r))	r�r!r,r9r
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)Nr7r6rnr\)r9rr
r+r,�getvaluer-r/)r�uncompressed�bufr3rrrrr�test_non_seekable_file�s�"�zTestGzip.test_non_seekable_filecCs�td}t�|jd��
}|�|�Wd�n1swYdd�}t�|jd��A}d|_d}|�D]}|�|�}|dkrAn|�|�t	|��|�|t	|�7}q4|�|�d	�d�|�|t	|��Wd�dS1sowYdS)
Nrr6css�	tddd�D]}|Vqq)NT�r7r�)rP)�nrrr�sizes�s
��z!TestGzip.test_peek.<locals>.sizesr\�!rrb�d)
r9r
r+r!r,�max_read_chunk�peekr-r/r.)rr�r3r�rgr��srrr�	test_peek�s"�

"�zTestGzip.test_peekc	Cs�td�d�jdd�}|��t�|jd��0}tj|dd��}|�	|�
�|�Wd�n1s1wYWd�dSWd�dS1sIwYdS)Nr7�asciiTr�r)��encoding)r9�decoder�r@r
r+r!r�
TextIOWrapperr-r�)rr�r3�trrr�test_textio_readlines�s��"�zTestGzip.test_textio_readlinesc	Cs�t�|jtjtjB�}t�|d��(}tj|dd��}Wd�n1s$wYWd�dSWd�dS1s<wYdS)Nr6r(rn)r=r�r!�O_WRONLY�O_CREAT�fdopenr
r+)r�fdr3�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)Nr6�r+br)rnr(rAr��z)r\r��ro)r6ryr�)r
r+r!r>r�r-r1�READ�WRITEr]rwrr �assertWarns�
FutureWarning)rr3r�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 ASCIIr6r7r\)
r!r�r��skipTestr
r+r,r9r-r/)r�str_filename�bytes_filenamer3r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��>Ar}rlrriz)Excessive amount of data was decompressedN)r
rp�int�
assertLessr.r�DEFAULT_BUFFER_SIZErqr+r-r/�assertLessEqual�_buffer�rawr)r�bomb�decomp�
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)ri)r�)r}r\rn)r9r{r
rpr-�typer*r+rrqr/)rr0r�datacr3r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�r\rnri)
r9r{r�r
rpr-rr*r+rrqr/r�)rr�r0rrr3rrr�test_compress_mtime s
������zTestGzip.test_compress_mtimec	Cs�ttfD];}t��}tj|dd��
}|�|�Wd�n1s!wY|�t�|�	��|�t�
|�}|�t�|�|�qdS)Nr6rn)r9r{rrqr
r+r,r-�
decompressr�rp)rr0r�r3rr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)Nr7i����rrir�r�)r9r
rpr+rrqr]�EOFErrorr/r-r.rP)rr0�	truncatedr3r�rrr�test_read_truncated5s�����zTestGzip.test_read_truncatedcCsLd}tjt�|�d��}|�|��d�Wd�dS1swYdS)Ns��cQ�ExtraI-.2�MxrsTest)r
r+rrqr-r/)r�gzdatar3rrr�test_read_with_extraCs"�zTestGzip.test_read_with_extracCszt�|jd��
}|�t�Wd�n1swYt�|jd��}|jjj��Wd�dS1s6wYdS)Nr6r\)	r
r�r!r,r9rr�_fp�prependr?rrr�test_prepend_errorKs�"�zTestGzip.test_prepend_errorcCsxt�dgd��}t|�|j}tjt��dd��}|�|�|�|�|�|�	�|�Wd�dS1s5wYdS)N�Q)rir��rMr�r(rn)
rYr.�itemsizer
r+rrqr-r,r)r�q�LENGTHr3rrr�test_issue44439Rs"�zTestGzip.test_issue44439N)r')2rrrr5r@rIrSrUrZr_rarhrrrsrxr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr	rrrrrrr"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)Nr7r6r\ryr�r��r9r
r�r!r,rr/r-r]r�rr �rr�r3�	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)Nr6r7ryrB)	rCrDr!r
r�r,r9r-r/)rr!r3r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)Nr7r(r\r)rAr�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�r7�
�wtr�r\�rt�atr��r9r��replacer=�linesepr
r�r!r,rr/r-�rr��uncompressed_rawr3r,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)Nr7r�r)r\r2r�)	r9r�r
rpr�rrqr-r/)r�uncompressed_bytes�uncompressed_strrrr3r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��/�^@�wbt�xbtr\zutf-8r��ignore)�errorsr0)�newline)r]r^r
r�rwr!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�r7r0r1zutf-16r�r\r2r4r7rrr�
test_encoding�s��"�zTestOpen.test_encodingcCs�t�|jd��
}|�d�Wd�n1swYtj|jdddd��}|�|��d�Wd�dS1s:wYdS)Nr6sfoo�barr2r�r?)r�r@�foobar)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�r7r1r0)r�rAr2�
)r9r�r
r�r!r,r-r�)rr�r3rrr�test_newline�s�"�zTestOpen.test_newlineN)rrrr-r.r/r9r<rBrCrErGr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)rLrM�rK)rLr�	decorator�sz.create_and_remove_directory.<locals>.decoratorr)rKrQrrPr�create_and_remove_directory�s	rRc@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)Nr6rn�-mr
�-d��stdin�stdout�stderrrb)
rrqr
r+r,r0�sys�
executablerr�communicater�r-)r�bytes_io�	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.gzr6)r1rTr
rU�testgzipr\rrb)r=�pathre�TEMPDIRrt�existsr
r�r,r0rr-r/rv)r�gzipname�fp�rcr`ra�gunzipedrrr�test_decompress_infile_outfile�s��z.TestCommandLine.test_decompress_infile_outfilecCs@tdddd�\}}}|�d|���|�|d�|�|d�dS)NrTr
rUzthisisatest.outs.filename doesn't end in .gz: 'thisisatest.out'rirb)r	r-�strip�rrir`rarrr�$test_decompress_infile_outfile_errorsz4TestCommandLine.test_decompress_infile_outfile_errorcCsptjddf}t|tttd��}|�|j�\}}Wd�n1s!wY|�|d�|�|dd�d�dS)NrTr
rVrbr�r�)rZr[rrr\r0r-)rrr_r`rar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)Nrc�.gzr6rTr
rb)r=rdrerertrfr�r,r0rrvr-)r�local_testgziprgrhrir`rar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_levelrcrpr6rTr
rb)r�r=rdrerertrfr�r,r0rrvr-�remove)rrurqrgrhrir`rarrr�test_compress_infile_outfile.s"�
���z,TestCommandLine.test_compress_infile_outfilecC�0tdddd�\}}}|�d|�|�|d�dS)NrTr
rsrts8error: argument --best: not allowed with argument --fastrb�r	�assertInr-rmrrr�%test_compress_fast_best_are_exclusiveA�z5TestCommandLine.test_compress_fast_best_are_exclusivecCrx)NrTr
rsrUsAerror: argument -d/--decompress: not allowed with argument --fastrbryrmrrr�-test_decompress_cannot_have_flags_compressionFr|z=TestCommandLine.test_decompress_cannot_have_flags_compressionN)rrrr0rbrRrerkrnrorrrwr{r}rrrrrS�s



rS�__main__)&�__doc__rYrNrr=rCr�rZ�unittest�
subprocessrr�test.supportrrrr�test.support.script_helperrr	�
import_moduler
r9r{rd�abspathr%rerqr�TestCaserr&r)rRrSr�mainrrrr�<module>s@

&	
\�

Youez - 2016 - github.com/yon3zu
LinuXploit