403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_gzip.cpython-36.pyc
3

�w2_�k�@s dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
ddlmZmZddlmZe
jd�ZdZd	Zejje
j�d
ZGdd�dej�ZGd
d�dej�ZGdd�de�ZGdd�de�Z dd�Z!Gdd�dej�Z"ddd�Z#e$dk�re#dd�dS)z!Test script for the gzip module.
�N)�PIPE�Popen)�support)�_4G�
bigmemtest)�assert_python_ok�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
�3/opt/alt/python36/lib64/python3.6/test/test_gzip.py�seekable$szUnseekableIO.seekablecCs
tj�dS)N)�io�UnsupportedOperation)rr
r
r�tell'szUnseekableIO.tellcGs
tj�dS)N)rr)r�argsr
r
r�seek*szUnseekableIO.seekN)�__name__�
__module__�__qualname__r
rrr
r
r
rr	#sr	c@s"eZdZejZdd�Zdd�ZdS)�BaseTestcCstj|j�dS)N)r�unlink�filename)rr
r
r�setUp1szBaseTest.setUpcCstj|j�dS)N)rrr)rr
r
r�tearDown4szBaseTest.tearDownN)rrrr�TESTFNrrrr
r
r
rr.src@sReZdZdSdd�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+dRS)T�TestGzip�bcCsrt|�}tj|jd|��}|j|�}WdQRX|j|t|��tj|jd|��}|j|j�|�WdQRXdS)N�w�r)�bytesr�GzipFiler�write�assertEqual�len�read)r�data�modeZb_data�f�lr
r
r�write_and_read_back9szTestGzip.write_and_read_backc
Csdtj|jd��D}|jtd�|j�|j�ttd�rFtj	|j��|j
�WdQRX|j
�dS)N�wb�2�fsync)rr!rr"�data1�flush�fileno�hasattr�osr-�close)rr(r
r
r�
test_writeAs
zTestGzip.test_writecCs�tj|j�}tj|d��}|jtd�WdQRX|j|jt	�tj|d��}|jt�WdQRXtj|��}|j
�}WdQRX|j|td�|j|jt	�dS)Nrr,�a�3)�pathlib�Pathrrr!r"r.ZassertIsInstance�name�strr%r#)rrr(�dr
r
r�"test_write_read_with_pathlike_fileOsz+TestGzip.test_write_read_with_pathlike_filecCsD|jttd��tttd���}|jddddgd�}|j|�dS)Nr,��B��)�shape)r*�
memoryviewr.r �range�cast)r�mr&r
r
r�test_write_memoryview^szTestGzip.test_write_memoryviewcCs|jttd��dS)Nr,)r*�	bytearrayr.)rr
r
r�test_write_bytearraydszTestGzip.test_write_bytearraycCs|jtjdtd��dS)N�I�()r*�arrayr.)rr
r
r�test_write_arraygszTestGzip.test_write_arraycCs�tj|jd��P}|jt��|jd�WdQRX|jt��|jg�WdQRX|jt�WdQRXtj|jd��}|j|j�t�WdQRXdS)Nr+��rb)	rr!r�assertRaises�	TypeErrorr"r.r#r%)rr(r
r
r�test_write_incompatible_typejsz%TestGzip.test_write_incompatible_typecCs>|j�tj|jd��}|j�}WdQRX|j|td�dS)Nrr,)r4rr!rr%r#r.)rr(r;r
r
r�	test_readwszTestGzip.test_readcCs~|j�g}d}tj|jd��@}x8|j�}|s0P|j|�|t|�7}|j|j�|�q"WWdQRX|jdj	|�t
d�dS)Nrr�r,)r4rr!r�read1�appendr$r#r�joinr.)rZblocks�nreadr(r;r
r
r�
test_read1~s
zTestGzip.test_read1�)�sizeZmemusecCs8tjtdd�}tjtj|�dd�}|j|j|�t�dS)NrY)�
compresslevelrN)�fileobjr')r�compressr.r!r�BytesIOr#r%)rrZ�
compressedr(r
r
r�test_read_large�szTestGzip.test_read_largec%Cs|j�tj|jd�}|j}|j|j�|j�|j|j�|j	t
��|jd�WdQRX|j	t
��|jd�WdQRX|j	t
��|j
�WdQRXtj|jd�}|j}|j|j�|j�|j|j�|j	t
��|jd�WdQRX|j	t
��|j�WdQRXdS)NrrYrrrS)r4rr!rr\�assertFalse�closedr3�
assertTruerO�
ValueErrorr%rrr"r/)rr(r\r
r
r�test_io_on_closed_object�s*z!TestGzip.test_io_on_closed_objectcCsn|j�tj|jd��}|jtd�WdQRXtj|jd��}|j�}WdQRX|j|tdtd�dS)N�ab�rNr,)	r4rr!rr"�data2r%r#r.)rr(r;r
r
r�test_append�szTestGzip.test_appendcCs�tj|jdd��}|jd�WdQRXx8tdd�D]*}tj|jdd��}|jd�WdQRXq2Wtj|jd��(}d}x|jd	�}||7}|svPqvWWdQRX|j|dd
�dS)Nr+�	�ar��rfrNrSi ��)rr!rr"rCr%r#)rr(�iZzgfile�contentsZztxtr
r
r�test_many_append�s
zTestGzip.test_many_appendcCs~tj|jd��}|jtd�WdQRXtj|jd��}|j|j�td�WdQRX|jt��tj|jd�WdQRXdS)N�xbr,rN)	rr!rr"r.r#r%rO�FileExistsError)rr(r
r
r�test_exclusive_write�szTestGzip.test_exclusive_writecCsb|j�tj|jd��*}tj|��}dd�|D�}WdQRXWdQRX|j|dtjdd��dS)NrNcSsg|]}|�qSr
r
)�.0�liner
r
r�
<listcomp>�sz1TestGzip.test_buffered_reader.<locals>.<listcomp>r,T)�keepends)	r4rr!rr�BufferedReaderr#r.�
splitlines)rr(r�linesr
r
r�test_buffered_reader�s
"zTestGzip.test_buffered_readerc
Csh|j�tj|jd��H}d}x<|j|�}|r8|dkr8P|jt|�|k�|dd}qWWdQRXdS)NrNrrYr,)r4rr!r�readlinercr$)rr(Zline_length�Lr
r
r�
test_readline�s
zTestGzip.test_readlinecCsb|j�tj|jd��}|j�}WdQRXtj|jd�� }x|jd�}|gkr<Pq<WWdQRXdS)NrN�)r4rr!r�	readlines)rr(r}r
r
r�test_readlines�s
zTestGzip.test_readlinescCs�|j�tj|j��v}xn|j�}|j�}|s.P|j�}|j|�t|�dkrRd}nt|�}|j|�}|j	|d|�|�|j|�qWWdQRXdS)N�
)
r4rr!rrr|rr$r%r#)rr(ZoldposZline1ZnewposZamountZline2r
r
r�test_seek_read�s

zTestGzip.test_seek_readcCsZ|j�tj|j��(}|jd�|jddd�|jd�}WdQRX|j|tdd��dS)Nr�rY)�whence��)r4rr!rr%rr#r.)rr(�yr
r
r�test_seek_whences
zTestGzip.test_seek_whencecCsHtj|jd��0}x(tddd�D]}|j|�|jd�qWWdQRXdS)Nrrr=�sGZ
)rr!rrCrr")rr(�posr
r
r�test_seek_writes
zTestGzip.test_seek_writecCsl|j�tj|jd��}|j|jjd�WdQRXtj|j�tj|jd��}|j|jjd�WdQRXdS)NrrN�xrq)	r4rr!rr#Z	myfileobjr'rr)rr(r
r
r�	test_modeszTestGzip.test_modecCsLxFdD]>}tj|j|��&}|jt|d��|j|j|j�WdQRXqWdS)Nr+rNr9)r+rN)rr!rrcr1r#r9)rr'r(r
r
r�test_1647484%s
zTestGzip.test_1647484cCsJ|j�tj|jd��*}|jt|jd��|j|jj|j�WdQRXdS)NrNr9)	r4rr!rrcr1r\r#r9)rr(r
r
r�test_paddedfile_getattr+sz TestGzip.test_paddedfile_getattrcCs�d}tj|jd|d��}|jt�WdQRXtj|j��D}|jt|d��|j|j�|j	�}|j
|t�|j
|j|�WdQRXdS)Ni�[r)�mtimer�)rr!rr"r.rcr1ZassertIsNoner�r%r#)rr��fWrite�fReadZdataReadr
r
r�
test_mtime1szTestGzip.test_mtimecCsPd}tj|jd|d��}|jt�WdQRXt|jd���}|jd�}|j|d�|jd�}|j|d�|jd�}|j|d�|jd	�}|j|tj	d
|��|jd�}|j|d�|jd�}	|j|	d�|jj
d
�d}
|jt|
��}|j||
�|jt
j|j�jd�|jd	�}|j|d�|jd	�}
|j|
tj	d
tt���WdQRXdS)Ni�[r)r�rN�s�rY�r@z<i���zLatin-1�r?s��d�)rr!rr"r.�openr%r#�structZpack�encoder$rr2�stat�st_size)rr�r�r�ZidBytesZcmByteZ	flagsByteZ
mtimeBytesZxflByteZosByteZexpectedZ	nameBytesZ
crc32BytesZ
isizeBytesr
r
r�
test_metadata<s0







zTestGzip.test_metadatac#Cs�tj|jd��}|jd�WdQRXtj|jd�}|j�y|�WdQRXWntk
rbYnX|jd�y&tj|jd��}ddWdQRXWntk
r�YnX|jd�dS)Nr+sxxxrNz4__enter__ on a closed file didn't raise an exceptionrYrz1/0 didn't raise an exception)rr!rr"r3rdZfail�ZeroDivisionError)rr(r
r
r�test_with_openis 
zTestGzip.test_with_opencCs�tj|jd��}|jtd�WdQRXt|jd��}|jdd�WdQRXtj|jd�� }|j�}|j|tdd�WdQRXdS)Nr+r,rfr�rNzIncorrect data in file)rr!rr"r.r�r%r#)rr(r;r
r
r�test_zero_padded_file~szTestGzip.test_zero_padded_filecCsptd}t�}tj|dd��}|j|�WdQRX|j�}t|�}tj|dd��}|j|j�|�WdQRXdS)Nr,r+)r\r'rN)r.r	rr!r"�getvaluer#r%)r�uncompressed�bufr(r_r
r
r�test_non_seekable_file�szTestGzip.test_non_seekable_filecCs�td}tj|jd��}|j|�WdQRXdd�}tj|jd��x}d|_d}xD|�D]:}|j|�}|dkrnP|j|jt	|��|�|t	|�7}qVW|j|jd	�d�|j|t	|��WdQRXdS)
Nrlr+css&x xtddd�D]
}|VqWqWdS)N�r,r�)rC)�nr
r
r�sizes�sz!TestGzip.test_peek.<locals>.sizesrN�!rrS�d)
r.rr!rr"Zmax_read_chunk�peekr#r%r$)rr�r(r�rWr��sr
r
r�	test_peek�s
zTestGzip.test_peekcCsftdjd�jdd�}|j�tj|jd��0}tj|dd��}|j	|j
�|�WdQRXWdQRXdS)Nr,�asciiT)rwr)�encoding)r.�decoderyr4rr!rr�
TextIOWrapperr#r�)rrzr(�tr
r
r�test_textio_readlines�s
zTestGzip.test_textio_readlinescCsLtj|jtjtjB�}tj|d�� }tj|dd��}WdQRXWdQRXdS)Nr+r)r\r')r2r�r�O_WRONLY�O_CREAT�fdopenrr!)r�fdr(�gr
r
r�test_fileobj_from_fdopen�sz!TestGzip.test_fileobj_from_fdopenc<Cs�tj|jd�j�t|jd���}tj|dd��}|j|jtj�WdQRXtj|dd��}|j|jtj�WdQRXtj|dd��}|j|jtj�WdQRXtj|dd��}|j|jtj�WdQRX|j	t
��tj|dd�WdQRXWdQRXxNd
D]F}t|j|��.}tj|d
��}|j|jtj�WdQRXWdQRX�q�WxddD]\}d|k�rftj|j�t|j|��.}tj|d
��}|j|jtj�WdQRXWdQRX�qLWdS)Nr+�r+br)r\r'rr5r��zrN)r\rfrq)rNr�)r+rfrq)
rr!rr3r�r#r'ZREADZWRITErOrdrr)rr(r�r'r
r
r�test_fileobj_mode�s,"
*

zTestGzip.test_fileobj_modec!Cs�|j}y|jd�}Wntk
r2|jd�YnXtj|d��}|jtd�WdQRXtj|d��}|j|j	�td�WdQRXtj|d��}|j|j	�td�WdQRXdS)Nr�z%Temporary file name needs to be ASCIIr+r,rN)
rr��UnicodeEncodeErrorZskipTestrr!r"r.r#r%)rZstr_filenameZbytes_filenamer(r
r
r�test_bytes_filename�szTestGzip.test_bytes_filenamecCsttjdtd�dd�}|jt|�tj�tj|�}tj|d�}|j	|j
d�d�dtj}|j|jj
j�|d�dS)	z-Decompressed data buffering should be limitedr�g��>Arj)r[)r\rYz)Excessive amount of data was decompressedN)rr]�intZ
assertLessr$r�DEFAULT_BUFFER_SIZEr^r!r#r%ZassertLessEqual�_buffer�rawr)rZbombZdecompZ
max_decompr
r
r�test_decompress_limited�s

z TestGzip.test_decompress_limitedcCs|xvttgD]j}xdfdddgD]T}tj|f|��}|jt|�t�tjtj	|�dd��}|j|j
�|�WdQRXqWq
WdS)	NrY�rjrN)r\r')rY)r�)rj)r.rhrr]r#�typer r!rr^r%)rr&r�datacr(r
r
r�
test_compress�szTestGzip.test_compresscCstxnttfD]b}tj�}tj|dd��}|j|�WdQRX|jtj|j	��|�tj
|�}|jtj|�|�q
WdS)Nr+)r\r')r.rhrr^rr!r"r#�
decompressr�r])rr&r�r(r�r
r
r�test_decompress�s
zTestGzip.test_decompresscCs�td}tj|�dd�}tjtj|�d��}|jt|j�WdQRXtjtj|�d��,}|j	|jt
|��|�|jt|jd�WdQRXxHtdd�D]:}tjtj|d|��d��}|jt|jd�WdQRXq�WdS)Nr,r?)r\rYr�r�i����)r.rr]r!rr^rO�EOFErrorr%r#r$rC)rr&Z	truncatedr(rnr
r
r�test_read_truncatedszTestGzip.test_read_truncatedc
Cs6d}tjtj|�d��}|j|j�d�WdQRXdS)Ns��cQ�ExtraI-.2�Mx)r\sTest)rr!rr^r#r%)rZgzdatar(r
r
r�test_read_with_extraszTestGzip.test_read_with_extracCsPtj|jd��}|jt�WdQRXtj|jd��}|jjjj�WdQRXdS)Nr+rN)	rr�rr"r.r�r�Z_fpZprepend)rr(r
r
r�test_prepend_errorszTestGzip.test_prepend_errorN)r),rrrr*r4r<rFrHrLrQrRrXrrr`rerirprsr{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r8sN



-

rc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestOpenc;Csltd}tj|jd��}|j|�WdQRXt|jd�� }tj|j��}|j||�WdQRXtj|jd��}|j|j�|�WdQRXtj|jd��}|j|�WdQRXt|jd��$}tj|j��}|j||d�WdQRX|jt	��tj|jd�WdQRXt
j|j�tj|jd��}|j|�WdQRXt|jd�� }tj|j��}|j||�WdQRXdS)Nr,r+rNrfr�rq)r.rr�rr"r�r%r#rOrrrr)rr�r(�	file_datar
r
r�test_binary_modess*zTestOpen.test_binary_modescCs�tj|j�}tj|d��}|jtd�WdQRXtj|d��}|jt�WdQRXtj|��}|j|j�td�WdQRXdS)Nr+r,rfr6)	r7r8rrr�r"r.r#r%)rrr(r
r
r�test_pathlike_file9szTestOpen.test_pathlike_filec;Csltd}tj|jd��}|j|�WdQRXt|jd�� }tj|j��}|j||�WdQRXtj|jd��}|j|j�|�WdQRXtj|jd��}|j|�WdQRXt|jd��$}tj|j��}|j||d�WdQRX|jt	��tj|jd�WdQRXt
j|j�tj|jd��}|j|�WdQRXt|jd�� }tj|j��}|j||�WdQRXdS)Nr,rrNrr5r�r�)r.rr�rr"r�r%r#rOrrrr)rr�r(r�r
r
r�test_implicit_binary_modesBs*z#TestOpen.test_implicit_binary_modesc'Cstjd�d}|jdtj�}tj|jd��}|j|�WdQRXt|jd��&}tj	|j
��jd�}|j||�WdQRXtj|jd��}|j|j
�|�WdQRXtj|jd��}|j|�WdQRXt|jd��*}tj	|j
��jd�}|j||d�WdQRXdS)	Nr�r,�
�wtrN�rtZatr�)r.r��replacer2�lineseprr�rr"r�r%r#)rr��uncompressed_rawr(r�r
r
r�test_text_modes^szTestOpen.test_text_modescCs�td}|jd�}tj|�}tjtj|�d��}|j|j�|�WdQRXtjtj|�d��}|j|j�|�WdQRXtjtj|�d��}|j|j�|�WdQRXdS)Nr,r�rrNr�)	r.r�rr]r�rr^r#r%)rZuncompressed_bytesZuncompressed_strr_r(r
r
r�test_fileobjns

zTestOpen.test_fileobjc/Cs�|jt��tjd�WdQRX|jt��tj|jd�WdQRX|jt��tj|jd�WdQRX|jt��tj|jddd�WdQRX|jt��tj|jddd�WdQRX|jt��tj|jdd	d
�WdQRXdS)Ngw��/�^@ZwbtZxbtrNzutf-8)r��ignore)�errorsr�)�newline)rOrPrr�rdr)rr
r
r�test_bad_paramsyszTestOpen.test_bad_paramscCs�tjd�d}|jdtj�}tj|jddd��}|j|�WdQRXt|jd��&}tj	|j
��jd�}|j||�WdQRXtj|jddd��}|j|j
�|�WdQRXdS)	Nr�r,r�r�zutf-16)r�rNr�)r.r�r�r2r�rr�rr"r�r%r#)rr�r�r(r�r
r
r�
test_encoding�szTestOpen.test_encodingcCsXtj|jd��}|jd�WdQRXtj|jdddd��}|j|j�d�WdQRXdS)Nr+sfoo�barr�r�r�)r�r�Zfoobar)rr�rr"r#r%)rr(r
r
r�test_encoding_error_handler�s
z$TestOpen.test_encoding_error_handlercCsjtjd�d}tj|jddd��}|j|�WdQRXtj|jddd��}|j|j�|g�WdQRXdS)Nr�r,r�r�)r�r��
)r.r�rr�rr"r#r�)rr�r(r
r
r�test_newline�s
zTestOpen.test_newlineN)rrrr�r�r�r�r�r�r�r�r�r
r
r
rr�s	r�cs�fdd�}|S)Ncstj����fdd��}|S)Ncs&tj��z
�||�Stj��XdS)N)r2�makedirsrZrmtree)r�kwargs)�	directory�functionr
r�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�r�r
)r�r�create_and_remove_directory�s	r�c@sPeZdZdZdd�Zee�dd��Zdd�Zee�dd	��Z	ee�d
d��Z
dS)
�TestCommandLinesThis is a simple test with gzipcCs�tj��h}tj|dd��}|j|j�WdQRXtjdddf}t|t	t	t	d��}|j
|j��\}}WdQRXWdQRX|j|d�|j||j�dS)Nr+)r\r'z-mrz-d)�stdin�stdout�stderrrS)
rr^rr!r"r&�sys�
executablerr�communicater�r#)rZbytes_ioZ	gzip_filer�proc�out�errr
r
r�test_decompress_stdin_stdout�s
&z,TestCommandLine.test_decompress_stdin_stdoutcCs�tjjtd�}|jtjj|��tj|dd��}|j|j	�WdQRXt
ddd|�\}}}ttjjtd�d��}|j|j�|j	�WdQRX|j
tjj|��|j|d	�|j|d
�|j|d
�dS)Nztestgzip.gzr+)r'z-mrz-d�testgziprNrrS)r2�pathrV�TEMPDIRra�existsrr�r"r&rr#r%rc)r�gzipname�fp�rcr�r�Zgunzipedr
r
r�test_decompress_infile_outfile�sz.TestCommandLine.test_decompress_infile_outfilecCs<tdddd�\}}}|jd|�|j|d�|j|d�dS)Nz-mrz-dzthisisatest.outsfilename doesn't end in .gz:rrS)rZassertInr#)rr�r�r�r
r
r�$test_decompress_infile_outfile_error�sz4TestCommandLine.test_decompress_infile_outfile_errorcCs\tjddf}t|tttd��}|j|j�\}}WdQRX|j|d�|j|dd�d�dS)Nz-mr)r�r�r�rSr�s�)r�r�rrr�r&r#)rrr�r�r�r
r
r�test_compress_stdin_outfile�s
z+TestCommandLine.test_compress_stdin_outfilecCs�tjjtd�}|d}|jtjj|��t|d��}|j|j�WdQRXt	dd|�\}}}|j
tjj|��|j|d�|j|d�|j|d�dS)Nr�z.gzr+z-mrrrS)r2r�rVr�rar�r�r"r&rrcr#)rZlocal_testgzipr�r�r�r�r�r
r
r�test_compress_infile_outfile�sz,TestCommandLine.test_compress_infile_outfileN)rrrr&r�r�r�r�r�rrr
r
r
rr��s	r�cCstjttt�dS)N)rZrun_unittestrr�r�)�verboser
r
r�	test_main�sr�__main__T)r)N)%�__doc__rKr�rr2r7r�r�Zunittest�
subprocessrrZtestrZtest.supportrrZtest.support.script_helperr�
import_modulerr.rhr��abspathrr�r^r	ZTestCaserrr�r�r�rrr
r
r
r�<module>s:

h	
@



Youez - 2016 - github.com/yon3zu
LinuXploit