
    <e}                        	 d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZmZmZ d dlmZmZ  ej        d          ZdZd	Zej                            ej                  d
z   Z G d dej                  Z G d dej                  Z G d de          Z  G d de          Z!d Z" G d dej                  Z#e$dk    r ej%                     dS dS )    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                        e Zd Zd Zd Zd ZdS )UnseekableIOc                     dS )NF selfs    %/usr/lib/python3.11/test/test_gzip.pyseekablezUnseekableIO.seekable%   s    u    c                     t           j        NioUnsupportedOperationr   s    r   tellzUnseekableIO.tell(       %%r   c                     t           j        r   r   )r   argss     r   seekzUnseekableIO.seek+   r   r   N)__name__
__module____qualname__r   r   r   r   r   r   r   r   $   sA          & & && & & & &r   r   c                   (    e Zd Zej        Zd Zd ZdS )BaseTestc                 8    t          j        | j                   d S r   r   unlinkfilenamer   s    r   setUpzBaseTest.setUp2       '''''r   c                 8    t          j        | j                   d S r   r&   r   s    r   tearDownzBaseTest.tearDown5   r*   r   N)r    r!   r"   r   TESTFNr(   r)   r,   r   r   r   r$   r$   /   s:        H( ( (( ( ( ( (r   r$   c                   V   e Zd Zd5dZd Zd Zd Zd Zd Zd Z	d	 Z
d
 Z eed          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 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, Z-d- Z.d. Z/d/ Z0d0 Z1d1 Z2d2 Z3d3 Z4d4S )6TestGzipbc                    t          |          }t                              | j        d|z             5 }|                    |          }d d d            n# 1 swxY w Y   |                     |t          |                     t                              | j        d|z             5 }|                     |                                |           d d d            d S # 1 swxY w Y   d S )Nwr)bytesr   GzipFiler(   writeassertEquallenread)r   datamodeb_datafls         r   write_and_read_backzTestGzip.write_and_read_back:   s=   t]]4=#d(33 	qA	 	 	 	 	 	 	 	 	 	 	 	 	 	 	CKK(((]]4=#d(33 	/qQVVXXv...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s#   AAA&)CC #C c                    t                               | j        d          5 }|                    t          dz             |                                 |                                 t          t          d          r&t          j	        |                                           |
                                 d d d            n# 1 swxY w Y   |
                                 d S )Nwb2   fsync)r   r5   r(   r6   data1flushfilenohasattrosrC   closer   r=   s     r   
test_writezTestGzip.test_writeB   s    ]]4=$// 	1GGEBJ GGIIIHHJJJr7## %$$$GGIII	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
					s   BCC	Cc                    t          j        | j                  }t                              |d          5 }|                    t          dz             d d d            n# 1 swxY w Y   |                     |j        t                     t                              |d          5 }|                    t                     d d d            n# 1 swxY w Y   t                              |          5 }|
                                }d d d            n# 1 swxY w Y   |                     |t          dz             |                     |j        t                     d S )Nr2   rB   a3   )pathlibPathr(   r   r5   r6   rD   assertIsInstancenamestrr9   r7   )r   r(   r=   ds       r   "test_write_read_with_pathlike_filez+TestGzip.test_write_read_with_pathlike_fileP   s   <..]]8S)) 	 QGGEBJ	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 afc***]]8S)) 	QGGENNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	]]8$$ 	A	 	 	 	 	 	 	 	 	 	 	 	 	 	 	EBJ'''afc*****s5   AA#&A#%CCC1DDDc                    |                      t          t          dz                       t          t          t	          d                              }|                    dg d          }|                      |           d S )NrB      B)   rY      )shape)r?   
memoryviewrD   r4   rangecast)r   mr:   s      r   test_write_memoryviewzTestGzip.test_write_memoryview_   sp      EBJ!7!7888uU3ZZ(())vvcv))  &&&&&r   c                 Z    |                      t          t          dz                       d S )NrB   )r?   	bytearrayrD   r   s    r   test_write_bytearrayzTestGzip.test_write_bytearraye   s(      52:!6!677777r   c                 f    |                      t          j        dt          dz                       d S )NI(   )r?   arrayrD   r   s    r   test_write_arrayzTestGzip.test_write_arrayh   s,      S%"*!=!=>>>>>r   c                    t                               | j        d          5 }|                     t                    5  |                    d           d d d            n# 1 swxY w Y   |                     t                    5  |                    g            d d d            n# 1 swxY w Y   |                    t                     d d d            n# 1 swxY w Y   t                               | j        d          5 }|                     |                                t                     d d d            d S # 1 swxY w Y   d S )NrA    rb)	r   r5   r(   assertRaises	TypeErrorr6   rD   r7   r9   rJ   s     r   test_write_incompatible_typez%TestGzip.test_write_incompatible_typek   s    ]]4=$// 	1""9--                ""9--                GGENNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ]]4=$// 	.1QVVXXu---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.sj   CACA"	"C%A"	&CB%C%B)	)C,B)	-CCC.D<<E E c                    |                                   t                              | j        d          5 }|                                }d d d            n# 1 swxY w Y   |                     |t          dz             d S )Nr3   rB   )rK   r   r5   r(   r9   r7   rD   r   r=   rT   s      r   	test_readzTestGzip.test_readx   s    ]]4=#.. 	!A	 	 	 	 	 	 	 	 	 	 	 	 	 	 	E"H%%%%%s   AAAc                    |                                   g }d}t                              | j        d          5 }	 |                                }|snP|                    |           |t          |          z  }|                     |                                |           g	 d d d            n# 1 swxY w Y   |                     d	                    |          t          dz             d S )Nr   r3   Tr   rB   )rK   r   r5   r(   read1appendr8   r7   r   joinrD   )r   blocksnreadr=   rT   s        r   
test_read1zTestGzip.test_read1   s   ]]4=#.. 	2!2GGII a   Q  51112 		2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	&))52:66666s   A)B//B36B3   )sizememusec                     t                               t          d          }t                               t	          j        |          d          }|                     |                    |          t                     d S )Nry   compresslevelrk   fileobjr;   )r   compressrD   r5   r   BytesIOr7   r9   )r   rz   
compressedr=   s       r   test_read_largezTestGzip.test_read_large   s^     ]]5]::
MM"*Z"8"8tMDDu-----r   c                    |                                   t                              | j        d          }|j        }|                     |j                   |                                 |                     |j                   | 	                    t                    5  |                    d           d d d            n# 1 swxY w Y   | 	                    t                    5  |                    d           d d d            n# 1 swxY w Y   | 	                    t                    5  |                                 d d d            n# 1 swxY w Y   t                              | j        d          }|j        }|                     |j                   |                                 |                     |j                   | 	                    t                    5  |                    d           d d d            n# 1 swxY w Y   | 	                    t                    5  |                                 d d d            d S # 1 swxY w Y   d S )Nr3   ry   r   r2   r   )rK   r   r5   r(   r   assertFalseclosedrI   
assertTruerl   
ValueErrorr9   r   r   r6   rE   )r   r=   r   s      r   test_io_on_closed_objectz!TestGzip.test_io_on_closed_object   s   
 	MM$---)(((				'''z** 	 	FF1III	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	 	FF1III	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	 	FFHHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 MM$---)(((				'''z** 	 	GGCLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	 	GGIII	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sZ   C  CC%DDD,EEE!HH
H(I

IIc                    |                                   t                              | j        d          5 }|                    t
          dz             d d d            n# 1 swxY w Y   t                              | j        d          5 }|                                }d d d            n# 1 swxY w Y   |                     |t          dz  t
          dz  z              d S )Nab   rk   rB   )	rK   r   r5   r(   r6   data2r9   r7   rD   rp   s      r   test_appendzTestGzip.test_append   s0   ]]4=$// 	 1GGEBJ	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  ]]4=$// 	1A	 	 	 	 	 	 	 	 	 	 	 	 	 	 	U2X%(344444s#   AA#&A#
B++B/2B/c                 D   t                               | j        dd          5 }|                    d           d d d            n# 1 swxY w Y   t	          dd          D ]P}t                               | j        dd          5 }|                    d           d d d            n# 1 swxY w Y   Qt                               | j        d          5 }d}	 |                    d
          }||z  }|sn	 d d d            n# 1 swxY w Y   |                     |d           d S )NrA   	      ar      r   rk   r   ry   i    s   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)r   r5   r(   r6   r]   r9   r7   )r   r=   izgfilecontentsztxts         r   test_many_appendzTestGzip.test_many_append   s    ]]4=$22 	aGGDMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	q# 	 	At}dA66 !               ]]4=$// 	#6H#{{4((D "U# #	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	8,,,,,s5   AAAB$$B(	+B(	"C??DDc                 &   t                               | j        d          5 }|                    t          dz             d d d            n# 1 swxY w Y   t                               | j        d          5 }|                     |                                t          dz             d d d            n# 1 swxY w Y   |                     t                    5  t                               | j        d           d d d            d S # 1 swxY w Y   d S )NxbrB   rk   )	r   r5   r(   r6   rD   r7   r9   rl   FileExistsErrorrJ   s     r   test_exclusive_writezTestGzip.test_exclusive_write   s   ]]4=$// 	 1GGEBJ	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 ]]4=$// 	31QVVXXurz222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3// 	/ 	/MM$-...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s5   AAA61B33B7:B7!DD
D
c                 r   |                                   t                              | j        d          5 }t	          j        |          5 }d |D             }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     |dt                              d          z             d S )Nrk   c                     g | ]}|S r   r   ).0lines     r   
<listcomp>z1TestGzip.test_buffered_reader.<locals>.<listcomp>   s    ,,,$,,,r   rB   Tkeepends)	rK   r   r5   r(   r   BufferedReaderr7   rD   
splitlines)r   r=   r3   liness       r   test_buffered_readerzTestGzip.test_buffered_reader   s&    	]]4=$// 	-1"1%% -,,!,,,- - - - - - - - - - - - - - -	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	U%5%5t%5%D%D DEEEEEs5   A:
A#A:#A'	'A:*A'	+A::A>A>c                 B   |                                   t                              | j        d          5 }d}	 |                    |          }|s|dk    rn/|                     t          |          |k               |dz   dz  }M	 d d d            d S # 1 swxY w Y   d S )Nrk   r   ry   rB   )rK   r   r5   r(   readliner   r8   )r   r=   line_lengthLs       r   test_readlinezTestGzip.test_readline   s     ]]4=$// 	51K5JJ{++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   ABBBc                 v   |                                   t                              | j        d          5 }|                                }d d d            n# 1 swxY w Y   t                              | j        d          5 }	 |                    d          }|g k    rn	 d d d            d S # 1 swxY w Y   d S )Nrk   ry      )rK   r   r5   r(   	readlines)r   r=   r   s      r   test_readlineszTestGzip.test_readlines   s+    ]]4=$// 	1A	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ]]4=$// 	"1"KK$$77E"!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s#   AAAB..B25B2c                 &   |                                   t                              | j                  5 }	 |                                }|                                }|sn|                                }|                    |           t          |          dk    rd}nt          |          }|                    |          }| 	                    |d |         |           |                    |           	 d d d            d S # 1 swxY w Y   d S )Nry   
   )
rK   r   r5   r(   r   r   r   r8   r9   r7   )r   r=   oldposline1newposamountline2s          r   test_seek_readzTestGzip.test_seek_read   s3    ]]4=)) 	Q

#evu::b==FF ZZFv  ww777v $		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   CDD
D
c                 d   |                                   t                              | j                  5 }|                    d           |                    dd           |                    d          }d d d            n# 1 swxY w Y   |                     |t          dd                    d S )Nr   ry   )whence      )rK   r   r5   r(   r9   r   r7   rD   )r   r=   ys      r   test_seek_whencezTestGzip.test_seek_whence  s     ]]4=)) 	QFF2JJJFF2aF   r

A	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	E"R%L)))))s   ABB	Bc                     t                               | j        d          5 }t          ddd          D ],}|                    |           |                    d           -	 d d d            d S # 1 swxY w Y   d S )Nr2   r   rW      s   GZ
)r   r5   r(   r]   r   r6   )r   r=   poss      r   test_seek_writezTestGzip.test_seek_write  s    ]]4=#.. 	!!QR(( ! !s    !	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s   ?A..A25A2c                    |                                   t                              | j        d          5 }|                     |j        j        d           d d d            n# 1 swxY w Y   t          j        | j                   t                              | j        d          5 }|                     |j        j        d           d d d            d S # 1 swxY w Y   d S )Nr3   rk   xr   )	rK   r   r5   r(   r7   	myfileobjr;   r   r'   rJ   s     r   	test_modezTestGzip.test_mode  s:   ]]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Cc                    dD ]}}t                               | j        |          5 }|                     t	          |d                     |                     |j        | j                   d d d            n# 1 swxY w Y   ~d S )N)rA   rk   rR   )r   r5   r(   r   rG   r7   rR   )r   r;   r=   s      r   test_1647484zTestGzip.test_1647484&  s      	8 	8Dt}d33 8q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   AA55A9	<A9	c                 :   |                                   t                              | j        d          5 }|                     t          |j        d                     |                     |j        j        | j                   d d d            d S # 1 swxY w Y   d S )Nrk   rR   )	rK   r   r5   r(   r   rG   r   r7   rR   rJ   s     r   test_paddedfile_getattrz TestGzip.test_paddedfile_getattr,  s    ]]4=$// 	<1OOGAIv66777QY^T];;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s   ABBBc                 0   d}t                               | j        d|          5 }|                    t                     d d d            n# 1 swxY w Y   t                               | j                  5 }|                     t          |d                     |                     |j                   |	                                }| 
                    |t                     | 
                    |j        |           d d d            d S # 1 swxY w Y   d S )N[r2   mtimer   )r   r5   r(   r6   rD   r   rG   assertIsNoner   r9   r7   )r   r   fWritefReaddataReads        r   
test_mtimezTestGzip.test_mtime2  sg   ]]4=#u]== 	 LL	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 ]]4=)) 	1UOOGE733444ek***zz||HXu---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6BDDDc           
      p   d}t                               | j        d|          5 }|                    t                     d d d            n# 1 swxY w Y   t          | j        d          5 }|                    d          }|                     |d           |                    d          }|                     |d           	 | j                            d	          d
z   }d}n# t          $ r d}d
}Y nw xY w|                    d          }|                     ||           |                    d          }	|                     |	t          j        d|                     |                    d          }
|                     |
d           |                    d          }|                     |d           |                    t          |                    }|                     ||           |                    t          j        | j                  j        dz
             |                    d          }|                     |d           |                    d          }|                     |t          j        dt          t                                         d d d            d S # 1 swxY w Y   d S )Nr   r2   r   rk         ry      zLatin-1    r   rZ   z<i      rY   s   d)r   r5   r(   r6   rD   openr9   r7   encodeUnicodeEncodeErrorstructpackr8   r   rH   statst_size)r   r   r   r   idBytescmByteexpectednameexpectedflags	flagsByte
mtimeBytesxflByteosByte	nameBytes
crc32Bytes
isizeBytess                  r   test_metadatazTestGzip.test_metadata=  s   ]]4=#u]== 	 LL	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  $-&& +	H% jjmmGWk222ZZ]]FVW---(#}33I>>H '% ( ( (" '( 

1IY666AJZT5)A)ABBBjjmmGWg...ZZ]]FVW--- 

3|#4#455IY555 JJrwt}--59:::AJZ)9:::AJZT3u::)F)FGGGW+	H +	H +	H +	H +	H +	H +	H +	H +	H +	H +	H +	H +	H +	H +	H +	H +	H +	HsI   AAA,AJ+C$#J+$C52J+4C55F)J++J/2J/c                 P    t           j        | _        |                                  d S r   )r   TESTFN_ASCIIr(   r   r   s    r   test_metadata_ascii_namez!TestGzip.test_metadata_ascii_namep  s$    !.r   c                    g d}d}|D ]\  }}}|                      |          5  t                              | j        d|          }|5  |                    t
                     d d d            n# 1 swxY w Y   t          | j        d          5 }|                    |           |                    d          }| 	                    ||           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )N))fastry      )bestr   r   )tradeoff   r   rY   r2   r}   rk   ry   )
subTestr   r5   r(   r6   rD   r   r   r9   r7   )	r   cases	xflOffsetrR   levelexpectedXflByter   r   r   s	            r   test_compresslevel_metadataz$TestGzip.test_compresslevel_metadatat  s   
 
 

 	.3 	? 	?*T5/d## ? ?t}cOO ( (LL'''( ( ( ( ( ( ( ( ( ( ( ( ( ( ($-.. ?%JJy)))#jjmmG$$Wo>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ?	? ? ? ? ? ? ? ? ? ? ? ? ? ? ?	? 	?sZ   %C4	A0$C40A44C47A48C4ACC4C!!C4$C!%C44C8	;C8	c                 T   t                               | j        d          5 }|                    d           d d d            n# 1 swxY w Y   t                               | j        d          }|                                 	 |5  	 d d d            n# 1 swxY w Y   |                     d           n# t          $ r Y nw xY w	 t                               | j        d          5 }ddz   d d d            n# 1 swxY w Y   |                     d           d S # t          $ r Y d S w xY w)NrA   s   xxxrk   z4__enter__ on a closed file didn't raise an exceptionry   r   z1/0 didn't raise an exception)r   r5   r(   r6   rI   failr   ZeroDivisionErrorrJ   s     r   test_with_openzTestGzip.test_with_open  s   ]]4=$// 	1GGFOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	MM$-..					N                
 IILMMMM  	 	 	D		7t}d33 q!              
 II566666 ! 	 	 	DD	s}   AA
AB4 BB4 BB4 BB4 4
C C D %C7+D 7C;;D >C;?D 
D'&D'c                    t                               | j        d          5 }|                    t          dz             d d d            n# 1 swxY w Y   t          | j        d          5 }|                    d           d d d            n# 1 swxY w Y   t                               | j        d          5 }|                                }|                     |t          dz  d           d d d            d S # 1 swxY w Y   d S )NrA   rB   r   s2                                                     rk   zIncorrect data in file)r   r5   r(   r6   rD   r   r9   r7   rp   s      r   test_zero_padded_filezTestGzip.test_zero_padded_file  s   ]]4=$// 	 1GGEBJ	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  $-&& 	"!GGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" ]]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 	Fs5   AAA+BBB84C99C= C=c                 j    |                      t          t          j        t                               d S r   )r   
issubclassr   BadGzipFileOSErrorr   s    r   test_gzip_BadGzipFile_exceptionz(TestGzip.test_gzip_BadGzipFile_exception  s'    
4#3W==>>>>>r   c                 V   t          | j        d          5 }|                    t          dz             d d d            n# 1 swxY w Y   t                              | j        d          5 }|                     t          j        |j                   d d d            d S # 1 swxY w Y   d S )NrA   rB   r3   )	r   r(   r6   rD   r   r5   rl   r  r   )r   files     r   test_bad_gzip_filezTestGzip.test_bad_gzip_file  s!   $-&& 	#$JJurz"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#]]4=#.. 	@$d.???	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s#   A  AA+&BB"%B"c                    t           dz  }t                      }t                              |d          5 }|                    |           d d d            n# 1 swxY w Y   |                                }t          |          }t                              |d          5 }|                     |                                |           d d d            d S # 1 swxY w Y   d S )NrB   rA   r   rk   )rD   r   r   r5   r6   getvaluer7   r9   )r   uncompressedbufr=   r   s        r   test_non_seekable_filezTestGzip.test_non_seekable_file  s=   rznn]]3T]22 	"aGGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"\\^^
:&&]]3T]22 	5aQVVXX|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Cc           	         t           dz  }t                              | j        d          5 }|                    |           d d d            n# 1 swxY w Y   d }t                              | j        d          5 }d|_        d} |            D ]g}|                    |          }|dk    r nI|                     |                    t          |                    |           |t          |          z  }h|                     |                    d          d           |                     |t          |                     d d d            d S # 1 swxY w Y   d S )	Nr   rA   c               3   :   K   	 t          ddd          D ]} | V  )NT   rB   r   )r]   )ns    r   sizesz!TestGzip.test_peek.<locals>.sizes  s6      q"b))  AGGGGr   rk   !   r   r   d   )
rD   r   r5   r(   r6   max_read_chunkpeekr7   r9   r8   )r   r  r=   r  rw   r  ss          r   	test_peekzTestGzip.test_peek  s   s{]]4=$// 	"1GGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"	 	 	
 ]]4=$// 
	71!AEUWW    FF1II88E  A333QQVVC[[#...UC$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;CEEEc                    t           dz                      d                              d          }|                                  t                              | j        d          5 }t          j        |d          5 }| 	                    |
                                |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )NrB   asciiTr   r3   encoding)rD   decoder   rK   r   r5   r(   r   TextIOWrapperr7   r   )r   r   r=   ts       r   test_textio_readlineszTestGzip.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
2B6	6C
9B6	:C

CCc                 .   t          j        | j        t           j        t           j        z            }t          j        |d          5 }t                              |d          5 }	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )NrA   r2   r   )rH   r   r(   O_WRONLYO_CREATfdopenr   r5   )r   fdr=   gs       r   test_fileobj_from_fdopenz!TestGzip.test_fileobj_from_fdopen  s     WT]BK"*$<==Yr4   	Aqs33 q              	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s6   B
$A2&B
2A6	6B
9A6	:B

BBc                    t                               | j        d                                           t	          | j        d          5 }t                               |d          5 }|                     |j        t           j                   d d d            n# 1 swxY w Y   t                               |d          5 }|                     |j        t           j                   d d d            n# 1 swxY w Y   t                               |d          5 }|                     |j        t           j                   d d d            n# 1 swxY w Y   t                               |d          5 }|                     |j        t           j                   d d d            n# 1 swxY w Y   | 	                    t                    5  t                               |d           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d	D ]}t	          | j        |          5 }t                               |
          5 }|                     |j        t           j                   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   dD ]}d|v rt          j        | j                   t	          | j        |          5 }|                     t                    5  t                               |
          }d d d            n# 1 swxY w Y   |5  |                     |j        t           j                   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )NrA   r+br3   r   r2   rM   r   z)rk   r+  r   )rA   r   r   )r   r5   r(   rI   r   r7   r;   READWRITErl   r   r   r'   assertWarnsFutureWarning)r   r=   r(  r;   s       r   test_fileobj_modezTestGzip.test_fileobj_mode  s   dmT**00222$-'' 
	31qs33 4q  3334 4 4 4 4 4 4 4 4 4 4 4 4 4 4qs33 5q  4445 5 5 5 5 5 5 5 5 5 5 5 5 5 5qs33 5q  4445 5 5 5 5 5 5 5 5 5 5 5 5 5 5qs33 5q  4445 5 5 5 5 5 5 5 5 5 5 5 5 5 5"":.. 3 3ac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 	8DdmT** 8a]]1]-- 8$$QVTY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 	9Dd{{ ///dmT** 9a%%m44 1 1a00A1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 9$$QVTZ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0C4	4H7C4	8H&E	=H	E	HE	H0&F"H"F&	&H)F&	*HG0$H0G4	4H7G4	8HHH+J&I9-J9I==J I=JJ	J	M+-L	M+LM+LM+"&MM+MM+MM++M/	2M/	c                    | j         }	 |                    d          }n%# t          $ r |                     d           Y nw xY wt                              |d          5 }|                    t          dz             d d d            n# 1 swxY w Y   t                              |d          5 }|                     |	                                t          dz             d d d            n# 1 swxY w Y   t                              |d          5 }|                     |	                                t          dz             d d d            d S # 1 swxY w Y   d S )Nr  z%Temporary file name needs to be ASCIIrA   rB   rk   )
r(   r   r   skipTestr   r5   r6   rD   r7   r9   )r   str_filenamebytes_filenamer=   s       r   test_bytes_filenamezTestGzip.test_bytes_filename  s   }	C)0099NN! 	C 	C 	CMMABBBBB	C]]>400 	 AGGEBJ	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 ]]>400 	3AQVVXXurz222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 ]]<.. 	3!QVVXXurz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3C01EEEc                    	 t                               dt          d          z  d          }|                     t	          |          t
          j                   t          j        |          }t                               |          }| 	                    |
                    d          d           dt
          j        z   }|                     |j        j                                        |d           d S )Nr   g    >Ar   r}   r-  ry   z)Excessive amount of data was decompressed)r   r   int
assertLessr8   r   DEFAULT_BUFFER_SIZEr   r5   r7   r9   assertLessEqual_bufferrawr   )r   bombdecomp
max_decomps       r   test_decompress_limitedz TestGzip.test_decompress_limited
  s    ;}}USXX-Q}??D		2#9:::z$t,,Q/////
V^/4466
7	9 	9 	9 	9 	9r   c                    t           t          fD ]}dD ]}t          j        |g|R  }|                     t          |          t                     t                              t          j	        |          d          5 }|                     |
                                |           d d d            n# 1 swxY w Y   d S )Nr   )ry   )r   )r   rk   r   )rD   r   r   r   r7   typer4   r5   r   r   r9   )r   r:   r   datacr=   s        r   test_compresszTestGzip.test_compress  s    EN 	5 	5D. 5 5d2T222  ee444]]2:e+<+<4]HH 5A$$QVVXXt4445 5 5 5 5 5 5 5 5 5 5 5 5 5 55	5 	5s   =)B22B69B6c           	         d}t           t          fD ]}dD ]}|                     ||          5  t          j        |g|R d|i}|                     t          |          t                     t                              t          j
        |          d          5 }|                    d           |                     |j        |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )Nr   rD  )r:   r   r   rk   r   ry   )rD   r   r   r   r   r7   rE  r4   r5   r   r   r9   r   )r   r   r:   r   rF  r=   s         r   test_compress_mtimezTestGzip.test_compress_mtime   sy   EN 	9 	9D. 9 9\\t$\77 9 9 M$CCCCUCCE$$T%[[%888rz%/@/@tLL 9PQ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5C2c                 `   dD ]}|                      |          5  t                              t          d|          }t                              t          d|          }|                     t          |           |                     t          |           d d d            n# 1 swxY w Y   d S )N)r   *   r   r   )r~   r   ry   )r   r   r   rD   assertInassertNotIn)r   r   
nocompressyescompresss       r   test_compress_correct_levelz$TestGzip.test_compress_correct_level+  s     	5 	5EE** 5 5!]]5]OO
"mmE%mPPeZ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                    t           t          fD ]}t          j                    }t                              |d          5 }|                    |           d d d            n# 1 swxY w Y   |                     t                              |	                                          |           t          
                    |          }|                     t                              |          |           d S )NrA   r   )rD   r   r   r   r   r5   r6   r7   
decompressr  r   )r   r:   r  r=   rF  s        r   test_decompresszTestGzip.test_decompress4  s   EN 	; 	;D*,,Cs66 !              T__S\\^^<<dCCCMM$''ET__U33T::::	; 	;s    A""A&	)A&	c                     t                               t                    }|                     t          t           j        |d d                    d S )Nr   r   rD   rl   EOFErrorrR  r   compressed_datas     r   !test_decompress_truncated_trailerz*TestGzip.test_decompress_truncated_trailer>  <    --..(DO_SbS5IJJJJJr   c                     t                               t                    }|                     t          t           j        |d d                    d S )NrV  rX  s     r   test_decompress_missing_trailerz(TestGzip.test_decompress_missing_trailerB  r[  r   c                 b   t           dz  }t                              |          d d         }t                              t	          j        |                    5 }|                     t          |j                   d d d            n# 1 swxY w Y   t                              t	          j        |                    5 }| 	                    |                    t          |                    |           |                     t          |j        d           d d d            n# 1 swxY w Y   t          dd          D ]p}t                              t	          j        |d |                             5 }|                     t          |j        d           d d d            n# 1 swxY w Y   qd S )NrB   r]  r-  ry   r   r   )rD   r   r   r5   r   r   rl   rW  r9   r7   r8   r]   )r   r:   	truncatedr=   r   s        r   test_read_truncatedzTestGzip.test_read_truncatedF  s   RxMM$'',	]]2:i#8#8]99 	0Qh///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0]]2:i#8#8]99 	3QQVVCII..555h222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 q" 	7 	7Arz)BQB-'@'@AA 7Q!!(AFA6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7s7   !BBB?AD##D'*D'5"F##F'	*F'	c                     d}t                               t          j        |                    5 }|                     |                                d           d d d            d S # 1 swxY w Y   d S )Ns   cQ ExtraI-. 2Mx   r-  s   Test)r   r5   r   r   r7   r9   )r   gzdatar=   s      r   test_read_with_extrazTestGzip.test_read_with_extraT  s    < ]]2:f#5#5]66 	0!QVVXXw///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s   )A&&A*-A*c                 b   t                               | j        d          5 }|                    t                     d d d            n# 1 swxY w Y   t                               | j        d          5 }|j        j        j                                         d d d            d S # 1 swxY w Y   d S )NrA   rk   )	r   r   r(   r6   rD   r=  r>  _fpprependrJ   s     r   test_prepend_errorzTestGzip.test_prepend_error\  s	   YYt}d++ 	qGGENNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	YYt}d++ 	(qIM%%'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s#   AAA3$B$$B(+B(c                    t          j         dg d          }t          |          |j        z  }t                              t          j                    d          5 }|                     |                    |          |           |                     |	                                |           d d d            d S # 1 swxY w Y   d S )NQ)ry   r      rZ   r  r2   r   )
rg   r8   itemsizer   r5   r   r   r7   r6   r   )r   qLENGTHr=   s       r   test_issue44439zTestGzip.test_issue44439c  s    K___--Q!*$]]2:<<c]:: 	/aQWWQZZ000QVVXXv...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   AB;;B?B?N)r0   )5r    r!   r"   r?   rK   rU   r`   rc   rh   rn   rq   rx   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)  r2  r7  rB  rG  rI  rP  rS  rZ  r^  ra  rd  rh  ro  r   r   r   r/   r/   9   s       / / / /  
+ 
+ 
+' ' '8 8 8? ? ?. . .& & &7 7 7 ZS###. . $#.  85 5 5- - -&/ / /	F 	F 	F
5 
5 
5
" 
" 
"  &* * *! ! !5 5 58 8 8< < <	1 	1 	11H 1H 1Hf  ? ? ?(7 7 7*
F 
F 
F? ? ?@ @ @5 5 57 7 7,7 7 7  9 9 94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( ( (/ / / / /r   r/   c                   D    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )TestOpenc                     t           dz  }t                              | j        d          5 }|                    |           d d d            n# 1 swxY w Y   t          | j        d          5 }t                              |                                          }|                     ||           d d d            n# 1 swxY w Y   t                              | j        d          5 }|                     |                                |           d d d            n# 1 swxY w Y   t                              | j        d          5 }|                    |           d d d            n# 1 swxY w Y   t          | j        d          5 }t                              |                                          }|                     ||dz             d d d            n# 1 swxY w Y   |                     t                    5  t                              | j        d           d d d            n# 1 swxY w Y   t          j        | j                   t                              | j        d          5 }|                    |           d d d            n# 1 swxY w Y   t          | j        d          5 }t                              |                                          }|                     ||           d d d            d S # 1 swxY w Y   d S )NrB   rA   rk   r   r   r   rD   r   r   r(   r6   rR  r9   r7   rl   r   r   r'   r   r  r=   	file_datas       r   test_binary_modeszTestOpen.test_binary_modesm  sd   rzYYt}d++ 	"qGGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"$-&& 	6!11IY555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 YYt}d++ 	5qQVVXX|444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 YYt}d++ 	"qGGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"$-&& 	:!11IYq(8999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: // 	+ 	+IIdmT***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+'''YYt}d++ 	"qGGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"$-&& 	6!11I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-AB<<C C ')DD #D E))E-0E-	AGG"G !H--H14H11JJJ3ALL
Lc                 8   t          j        | j                  }t                              |d          5 }|                    t          dz             d d d            n# 1 swxY w Y   t                              |d          5 }|                    t                     d d d            n# 1 swxY w Y   t                              |          5 }|                     |                                t          dz             d d d            d S # 1 swxY w Y   d S )NrA   rB   r   rN   )	rO   rP   r(   r   r   r6   rD   r7   r9   )r   r(   r=   s      r   test_pathlike_filezTestOpen.test_pathlike_file  s   <..YYx&& 	 !GGEBJ	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 YYx&& 	!GGENNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	YYx   	3AQVVXXurz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3B01DDDc                     t           dz  }t                              | j        d          5 }|                    |           d d d            n# 1 swxY w Y   t          | j        d          5 }t                              |                                          }|                     ||           d d d            n# 1 swxY w Y   t                              | j        d          5 }|                     |                                |           d d d            n# 1 swxY w Y   t                              | j        d          5 }|                    |           d d d            n# 1 swxY w Y   t          | j        d          5 }t                              |                                          }|                     ||dz             d d d            n# 1 swxY w Y   |                     t                    5  t                              | j        d           d d d            n# 1 swxY w Y   t          j        | j                   t                              | j        d          5 }|                    |           d d d            n# 1 swxY w Y   t          | j        d          5 }t                              |                                          }|                     ||           d d d            d S # 1 swxY w Y   d S )NrB   r2   rk   r3   rM   r   r   rs  rt  s       r   test_implicit_binary_modesz#TestOpen.test_implicit_binary_modes  sd   rzYYt}c** 	"aGGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"$-&& 	6!11IY555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 YYt}c** 	5aQVVXX|444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 YYt}c** 	"aGGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"$-&& 	:!11IYq(8999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: // 	* 	*IIdmS)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*'''YYt}c** 	"aGGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"$-&& 	6!11IY555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6rw  c                    t                               d          dz  }|                    dt          j                  }t
                              | j        dd          5 }|                    |           d d d            n# 1 swxY w Y   t          | j        d          5 }t
          	                    |
                                                              d          }|                     ||           d d d            n# 1 swxY w Y   t
                              | j        dd          5 }|                     |
                                |           d d d            n# 1 swxY w Y   t
                              | j        dd          5 }|                    |           d d d            n# 1 swxY w Y   t          | j        d          5 }t
          	                    |
                                                              d          }|                     ||d	z             d d d            d S # 1 swxY w Y   d S )
Nr  rB   
wtr  rk   rtatr   rD   r  replacerH   linesepr   r   r(   r6   rR  r9   r7   r   r  uncompressed_rawr=   ru  s        r   test_text_modeszTestOpen.test_text_modes  s   ||G,,r1'//bjAAYYt}dWY== 	"GGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"$-&& 	:!1188AAIY(8999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: YYt}dWY== 	5QVVXX|444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5YYt}dWY== 	"GGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"$-&& 	>!1188AAIY(81(<===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s\    BB	B"ADDD1)E&&E*-E*F55F9<F9AH;;H?H?c                    t           dz  }|                    d          }t                              |          }t                              t          j        |          d          5 }|                     |                                |           d d d            n# 1 swxY w Y   t                              t          j        |          d          5 }|                     |                                |           d d d            n# 1 swxY w Y   t                              t          j        |          dd          5 }|                     |                                |           d d d            d S # 1 swxY w Y   d S )NrB   r  r3   rk   r  r  )	rD   r  r   r   r   r   r   r7   r9   )r   uncompressed_bytesuncompressed_strr   r=   s        r   test_fileobjzTestOpen.test_fileobj  s   "RZ-44W==]]#566
YYrz*--s33 	;qQVVXX'9:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;YYrz*--t44 	;QVVXX'9:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;YYrz*--tgYFF 	9!QVVXX'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9E= E=c                    |                      t                    5  t                              d           d d d            n# 1 swxY w Y   |                      t                    5  t                              | j        d           d d d            n# 1 swxY w Y   |                      t                    5  t                              | j        d           d d d            n# 1 swxY w Y   |                      t                    5  t                              | j        dd           d d d            n# 1 swxY w Y   |                      t                    5  t                              | j        dd           d d d            n# 1 swxY w Y   |                      t                    5  t                              | j        dd	
           d d d            d S # 1 swxY w Y   d S )Ngw/^@wbtxbtrk   zutf-8r  ignore)errorsr}  )newline)rl   rm   r   r   r   r(   r   s    r   test_bad_paramszTestOpen.test_bad_params  s   y)) 	 	IIg	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	, 	,IIdmU+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,z** 	, 	,IIdmU+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,z** 	= 	=IIdmTGI<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=z** 	< 	<IIdmT(I;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<z** 	9 	9IIdmT4I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          dz  }|                    dt          j                  }t
                              | j        dd          5 }|                    |           d d d            n# 1 swxY w Y   t          | j        d          5 }t
          	                    |
                                                              d          }|                     ||           d d d            n# 1 swxY w Y   t
                              | j        dd          5 }|                     |
                                |           d d d            d S # 1 swxY w Y   d S )	Nr  rB   r}  r~  zutf-16r  rk   r  r  r  s        r   test_encodingzTestOpen.test_encoding  s   ||G,,r1'//bjAAYYt}dXY>> 	"!GGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"$-&& 	:!1188BBIY(8999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: YYt}dXY>> 	5!QVVXX|444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s7    BB	B"ADDD1)E''E+.E+c                 h   t                               | j        d          5 }|                    d           d d d            n# 1 swxY w Y   t                               | j        ddd          5 }|                     |                                d           d d d            d S # 1 swxY w Y   d S )NrA   s   foobarr  r  r  )r  r  foobar)r   r   r(   r6   r7   r9   rJ   s     r   test_encoding_error_handlerz$TestOpen.test_encoding_error_handler  s   YYt}d++ 	#qGGM"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#YYt}dWXYNN 	1QVVXXx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          dz  }t                              | j        ddd          5 }|                    |           d d d            n# 1 swxY w Y   t                              | j        ddd          5 }|                     |                                |g           d d d            d S # 1 swxY w Y   d S )Nr  rB   r~  r}  )r  r  r  )rD   r  r   r   r(   r6   r7   r   )r   r  r=   s      r   test_newlinezTestOpen.test_newline  s5   ||G,,r1YYt}dWdYKK 	"qGGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"YYt}dWdYKK 	<qQ[[]]\N;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s$   A##A'*A'*CCCN)r    r!   r"   rv  ry  r{  r  r  r  r  r  r  r   r   r   rq  rq  l  s        6 6 663 3 36 6 68> > > 	9 	9 	99 9 9
5 
5 
51 1 1< < < < <r   rq  c                       fd}|S )Nc                 J     t          j                    fd            }|S )Nc                      t          j                   	  | i |t          j                   S # t          j                   w xY wr   )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>    		"	"	, 	, 	, 	, 	, 
#	"	, r   r   )r  r  s   ` r   create_and_remove_directoryr    s$         r   c                   
   e Zd ZdZ e            d             Z ee          d             Zd Z	 e             ee          d                         Z
 ee          d             Z ee          d             Zd Zd	 Zd
S )TestCommandLines   This is a simple test with gzipc                 B   t          j                    5 }t                              |d          5 }|                    | j                   d d d            n# 1 swxY w Y   t          j        dddf}t          |t          t          t                    5 }|
                    |                                          \  }}d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     |d           |                     || j                   d S )NrA   r   -mr   -dstdinstdoutstderrr   )r   r   r   r5   r6   r:   sys
executabler   r   communicater  r7   )r   bytes_io	gzip_filer   procouterrs          r   test_decompress_stdin_stdoutz,TestCommandLine.test_decompress_stdin_stdout  s   Z\\ 	AXxd;; +y	***+ + + + + + + + + + + + + + + >45Dt4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"""di(((((sX   C#AC#A	C#A	 5C#+C C#C	C#C	C##C'*C'c                 T   t           j                            t          d          }|                     t           j                            |                     t                              |d          5 }|                    | j	                   d d d            n# 1 swxY w Y   t          ddd|          \  }}}t          t           j                            t          d          d          5 }|                     |                                | j	                   d d d            n# 1 swxY w Y   |                     t           j                            |                     |                     |d	           |                     |d
           |                     |d
           d S )Nztestgzip.gzrA   )r;   r  r   r  testgziprk   r   r   )rH   pathru   TEMPDIRr   existsr   r   r6   r:   r
   r7   r9   r   )r   gzipnamefprcr  r  gunzipeds          r   test_decompress_infile_outfilez.TestCommandLine.test_decompress_infile_outfile  s   7<<7711222YYxdY++ 	 rHHTY	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 'fdHEEC"',,w
33T:: 	9hX]]__di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$   4BB"B/.D))D-0D-c                     t          dddd          \  }}}|                     d|                                           |                     |d           |                     |d           d S )Nr  r   r  zthisisatest.outs.   filename doesn't end in .gz: 'thisisatest.out'ry   r   )r   r7   stripr   r  r  r  s       r   $test_decompress_infile_outfile_errorz4TestCommandLine.test_decompress_infile_outfile_error"  sm    ,T64ARSSCJCIIKKXXXQc"""""r   c                 :   t           j        ddf}t          |t          t          t                    5 }|                    | j                  \  }}d d d            n# 1 swxY w Y   |                     |d           |                     |d d         d           d S )Nr  r   r  r   r   r   )r  r  r   r   r  r:   r7   )r   r   r  r  r  s        r   test_compress_stdin_outfilez+TestCommandLine.test_compress_stdin_outfile(  s     ~tV+4tD>>> 	3$''	22HC	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	c"""RaR+.....s   AA #A c                 (   t           j                            t          d          }|dz   }|                     t           j                            |                     t          |d          5 }|                    | j                   d d d            n# 1 swxY w Y   t          dd|          \  }}}| 
                    t           j                            |                     |                     |d           |                     |d           d S )Nr  .gzrA   r  r   r   )rH   r  ru   r  r   r  r   r6   r:   r
   r   r7   )r   local_testgzipr  r  r  r  r  s          r   $test_compress_infile_outfile_defaultz4TestCommandLine.test_compress_infile_outfile_default2  s$   gz::!E)11222.$'' 	 2HHTY	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  (fnEECx00111c"""c"""""s   -BBBc                     dD ]}|                      |          5  t          j                            t          d          }|dz   }|                     t          j                            |                     t          |d          5 }|                    | j	                   d d d            n# 1 swxY w Y   t          dd||          \  }}}|                     t          j                            |                     |                     |d           |                     |d           t          j        |           |                     t          j                            |                     d d d            n# 1 swxY w Y   d S )	N)--fast--best)compress_levelr  r  rA   r  r   r   )r   rH   r  ru   r  r   r  r   r6   r:   r
   r   r7   remove)r   r  r  r  r  r  r  r  s           r   test_compress_infile_outfilez,TestCommandLine.test_compress_infile_outfileA  s   2 	; 	;N^<< ; ;!#gz!B!B)E1  !9!9:::.$// (2HHTY'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (  0fnn]]Cx 8 8999  c***  c***	(###  !9!9:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;	; 	;s7   A-F	B0$F0B44F7B48B=FF	F	c                     t          dddd          \  }}}|                     d|           |                     |d           d S )Nr  r   r  r  s8   error: argument --best: not allowed with argument --fastr   r   rL  r7   r  s       r   %test_compress_fast_best_are_exclusivez5TestCommandLine.test_compress_fast_best_are_exclusiveT  sM    ,T68XNNCQSVWWWc"""""r   c                     t          dddd          \  }}}|                     d|           |                     |d           d S )Nr  r   r  r  sA   error: argument -d/--decompress: not allowed with argument --fastr   r  r  s       r   -test_decompress_cannot_have_flags_compressionz=TestCommandLine.test_decompress_cannot_have_flags_compressionY  sM    ,T68TJJCZ\_```c"""""r   N)r    r!   r"   r:   r	   r  r  r  r  r  r  r  r  r  r  r   r   r   r  r    s       -D
) 
) 
) ! ))# # *)# # # #   ))/ / *) / ! ))# # *)# ! )); ; *);$# # #
# # # # #r   r  __main__)&rg   r  r   rH   rO   r   r  unittest
subprocessr   r   test.supportr   r   r   r   r	   test.support.script_helperr
   r   import_moduler   rD   r   r  abspathr-   r  r   r   TestCaser$   r/   rq  r  r  r    mainr   r   r   <module>r     s0        				 				   



  " " " " " " " " & & & & & & " " " " " " = = = = = = = = = = N N N N N N N N"}"6**		 '//)*
+
+h
6& & & & &2: & & &( ( ( ( (x  ( ( (p/ p/ p/ p/ p/x p/ p/ p/fE< E< E< E< E<x E< E< E<P
 
 
[# [# [# [# [#h' [# [# [#| zHMOOOOO r   