Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_gzip.cpython-39.pyc

a

��g�x�@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
ddlmZmZddlmZmZe
�d�ZdZd	Zej�e
j�d
ZGdd�dej�ZGd
d�dej�ZGdd�de�Z Gdd�de�Z!dd�Z"Gdd�dej�Z#e$dk�re�%�dS)z!Test script for the gzip module.
�N)�PIPE�Popen)�support)�_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���selfrr�*/usr/local/lib/python3.9/test/test_gzip.py�seekable$szUnseekableIO.seekablecCs
tj�dS�N��io�UnsupportedOperationrrrr�tell'szUnseekableIO.tellcGs
tj�dSrr)r
�argsrrr�seek*szUnseekableIO.seekN)�__name__�
__module__�__qualname__rrrrrrrr
#sr
c@s"eZdZejZdd�Zdd�ZdS)�BaseTestcCst�|j�dSr�r�unlink�filenamerrrr�setUp1szBaseTest.setUpcCst�|j�dSrrrrrr�tearDown4szBaseTest.tearDownN)rrrr�TESTFNrrrrrrrr.src@szeZdZd]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\S)^�TestGzip�bcCs�t|�}t�|jd|��}|�|�}Wd�n1s:0Y|�|t|��t�|jd|�� }|�|��|�Wd�n1s�0YdS)N�w�r)�bytesr	�GzipFiler�write�assertEqual�len�read)r
�data�modeZb_data�f�lrrr�write_and_read_back9s(zTestGzip.write_and_read_backcCsxt�|jd��N}|�td�|��|��ttd�rFt�	|���|�
�Wd�n1sb0Y|�
�dS)N�wb�2�fsync)r	r&rr'�data1�flush�fileno�hasattr�osr2�close�r
r-rrr�
test_writeAs
&zTestGzip.test_writecCs�t�|j�}t�|d��}|�td�Wd�n1s<0Y|�|jt	�t�|d��}|�t�Wd�n1s�0Yt�|��}|�
�}Wd�n1s�0Y|�|td�|�|jt	�dS)Nr#r1�a�3)�pathlib�Pathrr	r&r'r3ZassertIsInstance�name�strr*r()r
rr-�drrr�"test_write_read_with_pathlike_fileOs,(&z+TestGzip.test_write_read_with_pathlike_filecCsB|�ttd��tttd���}|jdgd�d�}|�|�dS)Nr1��B)�rE�)�shape)r/�
memoryviewr3r%�range�cast)r
�mr+rrr�test_write_memoryview^szTestGzip.test_write_memoryviewcCs|�ttd��dS)Nr1)r/�	bytearrayr3rrrr�test_write_bytearraydszTestGzip.test_write_bytearraycCs|�t�dtd��dS)N�I�()r/�arrayr3rrrr�test_write_arraygszTestGzip.test_write_arrayc	Cs�t�|jd���}|�t��|�d�Wd�n1s:0Y|�t��|�g�Wd�n1sn0Y|�t�Wd�n1s�0Yt�|jd�� }|�|��t�Wd�n1s�0YdS)Nr0��rb)	r	r&r�assertRaises�	TypeErrorr'r3r(r*r9rrr�test_write_incompatible_typejs(((z%TestGzip.test_write_incompatible_typecCsR|��t�|jd��}|��}Wd�n1s40Y|�|td�dS)Nr$r1)r:r	r&rr*r(r3�r
r-rArrr�	test_readws&zTestGzip.test_readcCs�|��g}d}t�|jd��F}|��}|s.qV|�|�|t|�7}|�|��|�q Wd�n1sj0Y|�d�	|�t
d�dS)Nrr$�r1)r:r	r&r�read1�appendr)r(r�joinr3)r
Zblocks�nreadr-rArrr�
test_read1~s
0zTestGzip.test_read1�)�sizeZmemusecCs8tjtdd�}tjt�|�dd�}|�|�|�t�dS)Nr`��
compresslevelrT��fileobjr,)r	�compressr3r&r�BytesIOr(r*)r
ra�
compressedr-rrr�test_read_large�szTestGzip.test_read_largecCsx|��t�|jd�}|j}|�|j�|��|�|j�|�	t
��|�d�Wd�n1sf0Y|�	t
��|�d�Wd�n1s�0Y|�	t
��|�
�Wd�n1s�0Yt�|jd�}|j}|�|j�|��|�|j�|�	t
��|�d�Wd�n1�s60Y|�	t
��|��Wd�n1�sj0YdS)Nr$r`rr#rZ)r:r	r&rre�assertFalse�closedr8�
assertTruerU�
ValueErrorr*rrr'r4)r
r-rerrr�test_io_on_closed_object�s*((&*z!TestGzip.test_io_on_closed_objectcCs�|��t�|jd��}|�td�Wd�n1s:0Yt�|jd��}|��}Wd�n1sp0Y|�|tdtd�dS)N�ab�rTr1)	r:r	r&rr'�data2r*r(r3rXrrr�test_append�s,&zTestGzip.test_appendc	Cs�t�|jdd��}|�d�Wd�n1s00Ytdd�D]>}t�|jdd��}|�d�Wd�qD1sx0YqDt�|jd��.}d}|�d	�}||7}|s�q�q�Wd�n1s�0Y|�|d
�dS)Nr0�	�ar��rorTrZi s�aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)r	r&rr'rIr*r()r
r-�iZzgfile�contentsZztxtrrr�test_many_append�s(*
&zTestGzip.test_many_appendcCs�t�|jd��}|�td�Wd�n1s20Yt�|jd��$}|�|��td�Wd�n1st0Y|�t��t�|jd�Wd�n1s�0YdS)N�xbr1rT)	r	r&rr'r3r(r*rU�FileExistsErrorr9rrr�test_exclusive_write�s,2zTestGzip.test_exclusive_writec	Cs�|��t�|jd��H}t�|��}dd�|D�}Wd�n1sF0YWd�n1sd0Y|�|dtjdd��dS)NrTcSsg|]}|�qSrr)�.0�linerrr�
<listcomp>�rZz1TestGzip.test_buffered_reader.<locals>.<listcomp>r1T��keepends)	r:r	r&rr�BufferedReaderr(r3�
splitlines)r
r-r$�linesrrr�test_buffered_reader�s
JzTestGzip.test_buffered_readercCsv|��t�|jd��L}d}|�|�}|s4|dkr4qT|�t|�|k�|dd}qWd�n1sh0YdS)NrTrr`r1)r:r	r&r�readlinerlr))r
r-Zline_length�Lrrr�
test_readline�s
zTestGzip.test_readlinecCs�|��t�|jd��}|��}Wd�n1s40Yt�|jd��&}|�d�}|gkrNqdqNWd�n1sx0YdS)NrT�)r:r	r&r�	readlines)r
r-r�rrr�test_readlines�s&
zTestGzip.test_readlinescCs�|��t�|j��|}|��}|��}|s,q�|��}|�|�t|�dkrPd}nt|�}|�|�}|�	|d|�|�|�|�qWd�n1s�0YdS)N�
)
r:r	r&rrr�rr)r*r()r
r-ZoldposZline1Znewpos�amountZline2rrr�test_seek_read�s

zTestGzip.test_seek_readcCsn|��t�|j��2}|�d�|jddd�|�d�}Wd�n1sL0Y|�|tdd��dS)Nr�r`)�whence��)r:r	r&rr*rr(r3)r
r-�yrrr�test_seek_whences
(zTestGzip.test_seek_whencecCsXt�|jd��6}tddd�D]}|�|�|�d�qWd�n1sJ0YdS)Nr#rrC�sGZ
)r	r&rrIrr')r
r-�posrrr�test_seek_writes
zTestGzip.test_seek_writecCs�|��t�|jd�� }|�|jjd�Wd�n1s<0Yt�|j�t�|jd�� }|�|jjd�Wd�n1s�0YdS)Nr$rT�xry)	r:r	r&rr(Z	myfileobjr,rrr9rrr�	test_modes.zTestGzip.test_modec	Cs\dD]R}t�|j|��0}|�t|d��|�|j|j�Wd�q1sL0YqdS)N)r0rTr?)r	r&rrlr6r(r?)r
r,r-rrr�test_1647484%szTestGzip.test_1647484cCs^|��t�|jd��4}|�t|jd��|�|jj|j�Wd�n1sP0YdS)NrTr?)	r:r	r&rrlr6rer(r?r9rrr�test_paddedfile_getattr+sz TestGzip.test_paddedfile_getattrcCs�d}tj|jd|d��}|�t�Wd�n1s60Yt�|j��N}|�t|d��|�|j�|�	�}|�
|t�|�
|j|�Wd�n1s�0YdS)N��[r#��mtimer�)r	r&rr'r3rlr6ZassertIsNoner�r*r()r
r��fWrite�fReadZdataReadrrr�
test_mtime1s(zTestGzip.test_mtimec	Cs�d}tj|jd|d��}|�t�Wd�n1s60Yt|jd���:}|�d�}|�|d�|�d�}|�|d�z|j�d	�d
}d}Wnt	y�d}d
}Yn0|�d�}|�||�|�d�}	|�|	t
�d
|��|�d�}
|�|
d�|�d�}|�|d�|�t|��}|�||�|�
t�|j�jd�|�d�}
|�|
d�|�d�}|�|t
�d
tt���Wd�n1�s�0YdS)Nr�r#r�rT���r`�zLatin-1�rZrFz<i���rEs��d�)r	r&rr'r3�openr*r(�encode�UnicodeEncodeError�struct�packr)rr7�stat�st_size)r
r�r�r�ZidBytesZcmByteZexpectednameZ
expectedflagsZ	flagsByteZ
mtimeBytes�xflByteZosByteZ	nameBytesZ
crc32BytesZ
isizeBytesrrr�
test_metadata<s:(








zTestGzip.test_metadatacCstj|_|��dSr)rZTESTFN_ASCIIrr�rrrr�test_metadata_ascii_nameosz!TestGzip.test_metadata_ascii_namec	
Cs�gd�}d}|D]�\}}}|�|���tj|jd|d�}|�|�t�Wd�n1s\0Yt|jd��0}|�|�|�d�}|�	||�Wd�n1s�0YWd�q1s�0YqdS)N))�fastr`�)Zbestrsr�)Ztradeoff�r�rEr#rbrTr`)
�subTestr	r&rr'r3r�rr*r()	r
ZcasesZ	xflOffsetr?�levelZexpectedXflByter�r�r�rrr�test_compresslevel_metadatass(

z$TestGzip.test_compresslevel_metadatacCs�t�|jd��}|�d�Wd�n1s.0Yt�|jd�}|��z(|�Wd�n1sj0YWnty�Yn0|�d�z:t�|jd��}ddWd�n1s�0YWnty�Yn0|�d�dS)Nr0sxxxrTz4__enter__ on a closed file didn't raise an exceptionr`rz1/0 didn't raise an exception)r	r&rr'r8rmZfail�ZeroDivisionErrorr9rrr�test_with_open�s ("
*zTestGzip.test_with_opencCs�t�|jd��}|�td�Wd�n1s20Yt|jd��}|�d�Wd�n1sh0Yt�|jd��*}|��}|�|tdd�Wd�n1s�0YdS)Nr0r1ros2rTzIncorrect data in file)r	r&rr'r3r�r*r(rXrrr�test_zero_padded_file�s,(zTestGzip.test_zero_padded_filecCs|�ttjt��dSr)rl�
issubclassr	�BadGzipFile�OSErrorrrrr�test_gzip_BadGzipFile_exception�sz(TestGzip.test_gzip_BadGzipFile_exceptioncCs|t|jd��}|�td�Wd�n1s00Yt�|jd�� }|�tj|j�Wd�n1sn0YdS)Nr0r1r$)	r�rr'r3r	r&rUr�r�)r
�filerrr�test_bad_gzip_file�s,zTestGzip.test_bad_gzip_filecCs�td}t�}tj|dd��}|�|�Wd�n1s<0Y|��}t|�}tj|dd�� }|�|��|�Wd�n1s�0YdS)Nr1r0rdrT)r3r
r	r&r'�getvaluer(r*)r
�uncompressed�bufr-rhrrr�test_non_seekable_file�s(zTestGzip.test_non_seekable_filecCs�td}t�|jd��}|�|�Wd�n1s60Ydd�}t�|jd���}d|_d}|�D]<}|�|�}|dkr�q�|�|�t	|��|�|t	|�7}qh|�|�d	�d�|�|t	|��Wd�n1s�0YdS)
Nrur0csstddd�D]
}|VqqdS)N�r1r�)rI)�nrrr�sizes�sz!TestGzip.test_peek.<locals>.sizesrT�!rrZ�d)
r3r	r&rr'Zmax_read_chunk�peekr(r*r))r
r�r-r�r^r��srrr�	test_peek�s(

zTestGzip.test_peekc	Cs�td�d�jdd�}|��t�|jd��N}tj|dd�� }|�	|�
�|�Wd�n1sb0YWd�n1s�0YdS)Nr1�asciiTrr$��encoding)r3�decoder�r:r	r&rr�
TextIOWrapperr(r�)r
r�r-�trrr�test_textio_readlines�s
zTestGzip.test_textio_readlinesc	Cstt�|jtjtjB�}t�|d��>}tj|dd��}Wd�n1sH0YWd�n1sf0YdS)Nr0r#rd)r7r�r�O_WRONLY�O_CREAT�fdopenr	r&)r
�fdr-�grrr�test_fileobj_from_fdopen�sz!TestGzip.test_fileobj_from_fdopenc
Cs�t�|jd���t|jd���D}tj|dd�� }|�|jtj�Wd�n1sV0Ytj|dd�� }|�|jtj�Wd�n1s�0Ytj|dd�� }|�|jtj�Wd�n1s�0Ytj|dd�� }|�|jtj�Wd�n1�s0Y|�	t
��tj|dd�Wd�n1�sL0YWd�n1�sl0Yd	D]r}t|j|��N}tj|d
�� }|�|jtj�Wd�n1�s�0YWd�n1�s�0Y�qzdD]�}d|v�rt�|j�t|j|��~}|�
t��tj|d
�}Wd�n1�sH0Y|� |�|jtj�Wd�n1�s~0YWd�n1�s�0Y�q�dS)Nr0�r+br$rdr#r;r��z)rTr��re)r0rory)r	r&rr8r�r(r,ZREADZWRITErUrmrrZassertWarns�
FutureWarning)r
r-r�r,rrr�test_fileobj_mode�s0...0NT
,zTestGzip.test_fileobj_modecCs�|j}z|�d�}Wnty0|�d�Yn0t�|d��}|�td�Wd�n1sb0Yt�|d��$}|�|�	�td�Wd�n1s�0Yt�|d��$}|�|�	�td�Wd�n1s�0YdS)Nr�z%Temporary file name needs to be ASCIIr0r1rT)
rr�r�ZskipTestr	r&r'r3r(r*)r
Zstr_filenameZbytes_filenamer-rrr�test_bytes_filename�s,2zTestGzip.test_bytes_filenamecCsttjdtd�dd�}|�t|�tj�t�|�}tj|d�}|�	|�
d�d�dtj}|�|jj
��|d�dS)	z-Decompressed data buffering should be limitedr�g��>Arsrbr�r`z)Excessive amount of data was decompressedN)r	rf�intZ
assertLessr)r�DEFAULT_BUFFER_SIZErgr&r(r*ZassertLessEqual�_buffer�rawr)r
Zbomb�decompZ
max_decomprrr�test_decompress_limited	s

�z TestGzip.test_decompress_limitedc
Cs�ttfD]t}dD]j}tj|g|�R�}|�t|�t�tjt�	|�dd�� }|�|�
�|�Wd�q1sp0YqqdS)N�r)r`)r�)rsrTrd)r3rqr	rfr(�typer%r&rrgr*)r
r+r�datacr-rrr�
test_compressszTestGzip.test_compresscCs�d}ttfD]�}dD]�}|j||d���tj|g|�Rd|i�}|�t|�t�tjt	�
|�dd��(}|�d�|�|j|�Wd�n1s�0YWd�q1s�0YqqdS)Nr�r�)r+rr�rTrdr`)
r3rqr�r	rfr(r�r%r&rrgr*r�)r
r�r+rr�r-rrr�test_compress_mtimes
zTestGzip.test_compress_mtimec	Cs�ttfD]v}t��}tj|dd��}|�|�Wd�n1sB0Y|�t�|�	��|�t�
|�}|�t�|�|�qdS)Nr0rd)r3rqrrgr	r&r'r(�
decompressr�rf)r
r+r�r-r�rrr�test_decompress*s(
zTestGzip.test_decompressc	Cstd}t�|�dd�}tjt�|�d��}|�t|j�Wd�n1sP0Ytjt�|�d��6}|�	|�t
|��|�|�t|jd�Wd�n1s�0Ytdd�D]P}tjt�|d|��d�� }|�t|jd�Wd�q�1�s0Yq�dS)Nr1i����r�r`r�r�)r3r	rfr&rrgrU�EOFErrorr*r(r)rI)r
r+Z	truncatedr-rvrrr�test_read_truncated4s,.zTestGzip.test_read_truncatedcCsJd}tjt�|�d�� }|�|��d�Wd�n1s<0YdS)Ns��cQ�ExtraI-.2�Mxr�sTest)r	r&rrgr(r*)r
Zgzdatar-rrr�test_read_with_extraBszTestGzip.test_read_with_extracCsxt�|jd��}|�t�Wd�n1s.0Yt�|jd��}|jjj��Wd�n1sj0YdS)Nr0rT)	r	r�rr'r3r�r��_fpZprependr9rrr�test_prepend_errorJs(zTestGzip.test_prepend_errorN)r")1rrrr/r:rBrLrNrRrWrYr_rrrirnrrrxr{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�rrrrr!8sZ





3

r!c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestOpencCstd}t�|jd��}|�|�Wd�n1s60Yt|jd��*}t�|���}|�||�Wd�n1s|0Yt�|jd�� }|�|��|�Wd�n1s�0Yt�|jd��}|�|�Wd�n1s�0Yt|jd��.}t�|���}|�||d�Wd�n1�s>0Y|�t	��t�|jd�Wd�n1�sx0Yt
�|j�t�|jd��}|�|�Wd�n1�s�0Yt|jd��*}t�|���}|�||�Wd�n1�s0YdS)Nr1r0rTror�ry�r3r	r�rr'r�r*r(rUrzrr�r
r�r-�	file_datarrr�test_binary_modesRs*(*.(0.*zTestOpen.test_binary_modescCs�t�|j�}t�|d��}|�td�Wd�n1s<0Yt�|d��}|�t�Wd�n1sr0Yt�|��$}|�|��td�Wd�n1s�0YdS)Nr0r1ror<)	r=r>rr	r�r'r3r(r*)r
rr-rrr�test_pathlike_filems,(zTestOpen.test_pathlike_filecCstd}t�|jd��}|�|�Wd�n1s60Yt|jd��*}t�|���}|�||�Wd�n1s|0Yt�|jd�� }|�|��|�Wd�n1s�0Yt�|jd��}|�|�Wd�n1s�0Yt|jd��.}t�|���}|�||d�Wd�n1�s>0Y|�t	��t�|jd�Wd�n1�sx0Yt
�|j�t�|jd��}|�|�Wd�n1�s�0Yt|jd��*}t�|���}|�||�Wd�n1�s0YdS)Nr1r#rTr$r;r�r�r�r�rrr�test_implicit_binary_modesvs*(*.(0.*z#TestOpen.test_implicit_binary_modescCsnt�d�d}|�dtj�}t�|jd��}|�|�Wd�n1sJ0Yt|jd��0}t�	|�
���d�}|�||�Wd�n1s�0Yt�|jd�� }|�|�
�|�Wd�n1s�0Yt�|jd��}|�|�Wd�n1�s0Yt|jd��4}t�	|�
���d�}|�||d�Wd�n1�s`0YdS)	Nr�r1�
�wtrT�rtZatr��r3r��replacer7�linesepr	r�rr'r�r*r(�r
r�Zuncompressed_rawr-r�rrr�test_text_modes�s(*.*zTestOpen.test_text_modescCs�td}|�d�}t�|�}t�t�|�d�� }|�|��|�Wd�n1sT0Yt�t�|�d�� }|�|��|�Wd�n1s�0Yt�t�|�d�� }|�|��|�Wd�n1s�0YdS)Nr1r�r$rTr�)	r3r�r	rfr�rrgr(r*)r
Zuncompressed_bytesZuncompressed_strrhr-rrr�test_fileobj�s

..zTestOpen.test_fileobjcCs`|�t��t�d�Wd�n1s*0Y|�t��t�|jd�Wd�n1sb0Y|�t��t�|jd�Wd�n1s�0Y|�t��"tj|jddd�Wd�n1s�0Y|�t��"tj|jddd�Wd�n1�s0Y|�t��"tj|jdd	d
�Wd�n1�sR0YdS)Ngw��/�^@ZwbtZxbtrTzutf-8r��ignore)�errorsr���newline)rUrVr	r�rmrrrrr�test_bad_params�s(,,02zTestOpen.test_bad_paramscCs�t�d�d}|�dtj�}tj|jddd��}|�|�Wd�n1sN0Yt|jd��0}t�	|�
���d�}|�||�Wd�n1s�0Ytj|jddd�� }|�|�
�|�Wd�n1s�0YdS)	Nr�r1r�r�zutf-16r�rTr�r�r�rrr�
test_encoding�s(*zTestOpen.test_encodingcCs�t�|jd��}|�d�Wd�n1s.0Ytj|jdddd�� }|�|��d�Wd�n1sr0YdS)Nr0sfoo�barr�r�r)r�rZfoobar)r	r�rr'r(r*r9rrr�test_encoding_error_handler�s
(z$TestOpen.test_encoding_error_handlercCs�t�d�d}tj|jddd��}|�|�Wd�n1s@0Ytj|jddd��"}|�|��|g�Wd�n1s�0YdS)Nr�r1r�r�rr��
)r3r�r	r�rr'r(r�)r
r�r-rrr�test_newline�s
(zTestOpen.test_newlineN)rrrr�r�r�r�r�rrrrrrrrr�Qs	r�cs�fdd�}|S)Ncst�����fdd��}|S)Nc	s6t���z�|i|��Wt���St���0dSr)r7�makedirsr�rmtree)r�kwargs)�	directory�functionrr�wrapper�s

�z?create_and_remove_directory.<locals>.decorator.<locals>.wrapper)�	functools�wraps)r
r�r)r
r�	decorator�sz.create_and_remove_directory.<locals>.decoratorr)rrrrr�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����}tj|dd��}|�|j�Wd�n1s:0Ytjdddf}t|t	t	t	d��"}|�
|���\}}Wd�n1s�0YWd�n1s�0Y|�|d�|�||j�dS)Nr0rd�-mr	�-d��stdin�stdout�stderrrZ)
rrgr	r&r'r+�sys�
executablerr�communicater�r()r
Zbytes_ioZ	gzip_filer�proc�out�errrrr�test_decompress_stdin_stdout�s
*Nz,TestCommandLine.test_decompress_stdin_stdoutcCs�tj�td�}|�tj�|��tj|dd��}|�|j	�Wd�n1sP0Yt
ddd|�\}}}ttj�td�d��"}|�|��|j	�Wd�n1s�0Y|�
tj�|��|�|d	�|�|d
�|�|d
�dS)Nztestgzip.gzr0)r,rr	r�testgziprTrrZ)r7�pathr]�TEMPDIRrj�existsr	r�r'r+rr(r*rl)r
�gzipname�fp�rcrr Zgunzipedrrr�test_decompress_infile_outfile�s*0z.TestCommandLine.test_decompress_infile_outfilecCs@tdddd�\}}}|�d|���|�|d�|�|d�dS)Nrr	rzthisisatest.outs.filename doesn't end in .gz: 'thisisatest.out'r`rZ)rr(�strip�r
r(rr rrr�$test_decompress_infile_outfile_errorsz4TestCommandLine.test_decompress_infile_outfile_errorcCsptjddf}t|tttd�� }|�|j�\}}Wd�n1sB0Y|�|d�|�|dd�d�dS)Nrr	rrZr�r�)rrrrrr+r()r
rrrr rrr�test_compress_stdin_outfiles
.z+TestCommandLine.test_compress_stdin_outfilecCs�tj�td�}|d}|�tj�|��t|d��}|�|j�Wd�n1sT0Yt	dd|�\}}}|�
tj�|��|�|d�|�|d�dS)Nr"�.gzr0rr	rZ)r7r#r]r$rjr%r�r'r+rrlr()r
�local_testgzipr&r'r(rr rrr�$test_compress_infile_outfile_defaults*z4TestCommandLine.test_compress_infile_outfile_defaultc
Cs�dD]�}|j|d���tj�td�}|d}|�tj�|��t|d��}|�|j	�Wd�n1sj0Yt
dd||�\}}}|�tj�|��|�|d�|�|d�t�
|�|�tj�|��Wd�q1s�0YqdS)	N)�--fast�--best)�compress_levelr"r.r0rr	rZ)r�r7r#r]r$rjr%r�r'r+rrlr(�remove)r
r3r/r&r'r(rr rrr�test_compress_infile_outfile$s*
z,TestCommandLine.test_compress_infile_outfilecCs0tdddd�\}}}|�d|�|�|d�dS)Nrr	r1r2s8error: argument --best: not allowed with argument --fastrZ�rZassertInr(r+rrr�%test_compress_fast_best_are_exclusive7sz5TestCommandLine.test_compress_fast_best_are_exclusivecCs0tdddd�\}}}|�d|�|�|d�dS)Nrr	r1rsAerror: argument -d/--decompress: not allowed with argument --fastrZr6r+rrr�-test_decompress_cannot_have_flags_compression<sz=TestCommandLine.test_decompress_cannot_have_flags_compressionN)rrrr+r!rr$r)r,r-r0r5r7r8rrrrr�s



r�__main__)&�__doc__rQrrr7r=r�rZunittest�
subprocessrr�testrZtest.supportrrZtest.support.script_helperrr�
import_moduler	r3rqr#�abspathr r$rgr
ZTestCaserr!r�rrr�mainrrrr�<module>s:

	
\


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