+
    Bi                     6   R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
HtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHtHt ^ RIHtHt ]P.                  ! R4      t]P.                  ! R	4      tR
tRt]P8                  P;                  ]P<                  4      R,           t ! R R]P@                  4      t! ! R R]PD                  4      t# ! R R]#4      t$ ! R R]#4      t%R t& ! R R]PD                  4      t'](R8X  d   ]PR                  ! 4        R# R# )z!Test script for the gzip module.
N)PIPEPopen)catch_unraisable_exception)import_helper)	os_helper)_4G
bigmemtestrequires_subprocess)assert_python_okassert_python_failuregzipzlibsy     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                   2   a  ] tR t^'t o R tR tR tRtV tR# )UnseekableIOc                    R # )F selfs   &%/usr/lib/python3.14/test/test_gzip.pyseekableUnseekableIO.seekable(   s        c                "    \         P                  hNioUnsupportedOperationr   s   &r   tellUnseekableIO.tell+       %%%r   c                "    \         P                  hr   r   )r   argss   &*r   seekUnseekableIO.seek.   r   r   r   N)	__name__
__module____qualname____firstlineno__r   r   r"   __static_attributes____classdictcell____classdict__s   @r   r   r   '   s     && &r   r   c                   D   a  ] tR t^2t o ]P
                  tR tR tRt	V t
R# )BaseTestc                F    \         P                  ! V P                  4       R # r   r   unlinkfilenamer   s   &r   setUpBaseTest.setUp5       'r   c                F    \         P                  ! V P                  4       R # r   r/   r   s   &r   tearDownBaseTest.tearDown8   r4   r   r   N)r$   r%   r&   r'   r   TESTFNr1   r2   r6   r(   r)   r*   s   @r   r-   r-   2   s     H(( (r   r-   c                     a  ] tR t^<t o R?R ltR tR tR tR tR t	R t
R tR	 tR
 tR t]! ]^R7      R 4       tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!R t"R t#R  t$R! t%R" t&R# t'R$ t(R% t)R& t*R' t+R( t,R) t-R* t.R+ t/R, t0R- t1R. t2R/ t3R0 t4R1 t5R2 t6R3 t7R4 t8R5 t9R6 t:R7 t;R8 t<R9 t=R: t>R; t?R< t@R=tAV tBR># )@TestGzipc                   \        V4      p\        P                  V P                  R V,           4      ;_uu_ 4       pVP	                  V4      pRRR4       V P                  X\        V4      4       \        P                  V P                  RV,           4      ;_uu_ 4       pV P                  VP                  4       V4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)wNr)bytesr   GzipFiler1   writeassertEquallenread)r   datamodeb_datafls   &&&   r   write_and_read_backTestGzip.write_and_read_back=   s    t]]4==#d(33qA 4CK(]]4==#d(33qQVVXv. 43 43 433s   C
!C
C	C.	c                   \         P                  V P                  R 4      ;_uu_ 4       pVP                  \        ^2,          4       VP                  4        VP                  4        \        \        R4      '       d%   \        P                  ! VP                  4       4       VP                  4        RRR4       XP                  4        R#   + '       g   i     L"; i)wbfsyncN)r   r?   r1   r@   data1flushfilenohasattrosrM   closer   rG   s   & r   
test_writeTestGzip.test_writeE   s~    ]]4==$//1GGEBJ GGIHHJr7##$GGI 0 	
	 0/s   BC

C	c                v   \         P                  ! V P                  4      p\        P	                  VR 4      ;_uu_ 4       pVP                  \        ^2,          4       RRR4       V P                  XP                  \        4       V P                  VP                  V P                  4       \        P	                  VR4      ;_uu_ 4       pVP                  \        4       RRR4       \        P	                  V4      ;_uu_ 4       pVP                  4       pRRR4       V P                  X\        ^3,          4       V P                  VP                  \        4       V P                  VP                  V P                  4       R#   + '       g   i     EL.; i  + '       g   i     L; i  + '       g   i     L; i)r<   Na)r   FakePathr1   r   r?   r@   rN   assertIsInstancenamestrrA   rC   )r   r1   rG   ds   &   r   "test_write_read_with_pathlike_file+TestGzip.test_write_read_with_pathlike_fileS   s
   %%dmm4]]8S))QGGEBJ *affc*/]]8S))QGGEN *]]8$$A %EBJ'affc*/ *)) *)$$s#   FFF(F	F%	(F8	c                    V P                  \        \        ^2,          4      4       \        \        \	        R4      4      4      pVP                  R. ROR7      pV P                  V4       R# )2      B)shapeN)   re      )rI   
memoryviewrN   r>   rangecast)r   mrD   s   &  r   test_write_memoryviewTestGzip.test_write_memoryviewd   sL      EBJ!78uU3Z()vvcv)  &r   c                P    V P                  \        \        ^2,          4      4       R# )ra   N)rI   	bytearrayrN   r   s   &r   test_write_bytearrayTestGzip.test_write_bytearrayj   s      52:!67r   c                h    V P                  \        P                  ! R \        ^(,          4      4       R# )IN)rI   arrayrN   r   s   &r   test_write_arrayTestGzip.test_write_arraym   s      S%"*!=>r   c           	        \         P                  V P                  R 4      ;_uu_ 4       pV P                  \        4      ;_uu_ 4        VP                  R4       RRR4       V P                  \        4      ;_uu_ 4        VP                  . 4       RRR4       VP                  \        4       RRR4       \         P                  V P                  R4      ;_uu_ 4       pV P                  VP                  4       \        4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)rL    Nrb)	r   r?   r1   assertRaises	TypeErrorr@   rN   rA   rC   rT   s   & r   test_write_incompatible_type%TestGzip.test_write_incompatible_typep   s     ]]4==$//1""9-- .""9-- .GGEN 0 ]]4==$//1QVVXu- 0/ .--- 0/ 0//sG   D2D	%D2>D	D2%EDD2D/*D22E	E	c                   V P                  4        \        P                  V P                  R 4      ;_uu_ 4       pVP	                  4       pRRR4       V P                  X\        ^2,          4       R#   + '       g   i     L/; i)r=   N)rU   r   r?   r1   rC   rA   rN   r   rG   r]   s   &  r   	test_readTestGzip.test_read}   sP    ]]4==#..!A /E"H% /.s   A11B	c                   V P                  4        . p^ p\        P                  V P                  R4      ;_uu_ 4       p VP	                  4       pV'       g   MEVP                  V4       V\        V4      ,          pV P                  VP                  4       V4       K_  RRR4       V P                  RP                  V4      \        ^2,          4       R#   + '       g   i     L>; i)    r=   Nr   )rU   r   r?   r1   read1appendrB   rA   r   joinrN   )r   blocksnreadrG   r]   s   &    r   
test_read1TestGzip.test_read1   s    ]]4==#..!GGIa Q  51 / 	&)52:6 /.s   CACC#	c                   \         P                  ! R4      p\        P                  V P                  R4      ;_uu_ 4       pVP                  V4       RRR4       \        \        V4      4      p\        P                  V P                  R4      ;_uu_ 4       pVP                  V4      pRRR4       V P                  X\        V4      4       V P                  W14       R#   + '       g   i     L; i  + '       g   i     LQ; i
   rL   Nr=   i   )
rR   urandomr   r?   r1   r@   rn   rB   readintorA   )r   
large_datarG   bufnbytess   &    r   test_readintoTestGzip.test_readinto   s    ZZ
+
]]4==$//1GGJ 0 J(]]4==#..!ZZ_F /Z1) 0/ /.s   CC0C-	0D 	c                   \         P                  ! R4      p\        P                  V P                  R4      ;_uu_ 4       pVP                  V4       RRR4       ^ p\        \        V4      4      p\        V4      p\        P                  V P                  R4      ;_uu_ 4       p\        ^4       FH  pVP                  WSR 4      pV'       g    M,W7,          pV P                  VP                  4       V4       KJ  	  RRR4       V P                  WA4       V P                  X^4       R#   + '       g   i     L; i  + '       g   i     LH; ir   )rR   r   r   r?   r1   r@   rn   rB   rg   rh   	readinto1rA   r   assertGreater)r   r   rG   r   r   memviewcountr   s   &       r   test_readinto1TestGzip.test_readinto1   s    ZZ
+
]]4==$//1GGJ 0 J(S/]]4==#..!sWV_5  51 $ / 	)5!$ 0/ /.s   D'"AD:'D7	:E
	)sizememusec                    \         P                  \        ^R7      p\         P                  \        P
                  ! V4      RR7      pV P                  VP                  V4      \        4       R# )   compresslevelrx   fileobjrE   N)r   compressrN   r?   r   BytesIOrA   rC   )r   r   
compressedrG   s   &&  r   test_read_largeTestGzip.test_read_large   sI     ]]5]:
MM"**Z"8tMDu-r   c                   V P                  4        \        P                  V P                  R 4      pVP                  pV P                  VP                  4       VP                  4        V P                  VP                  4       V P                  \        4      ;_uu_ 4        VP                  ^4       RRR4       V P                  \        4      ;_uu_ 4        VP                  ^ 4       RRR4       V P                  \        4      ;_uu_ 4        VP                  4        RRR4       \        P                  V P                  R4      pVP                  pV P                  VP                  4       VP                  4        V P                  VP                  4       V P                  \        4      ;_uu_ 4        VP                  R4       RRR4       V P                  \        4      ;_uu_ 4        VP                  4        RRR4       R#   + '       g   i     EL_; i  + '       g   i     EL<; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     R# ; i)r=   Nr<   r   )rU   r   r?   r1   r   assertFalseclosedrS   
assertTruery   
ValueErrorrC   r"   r   r@   rO   )r   rG   r   s   &  r   test_io_on_closed_object!TestGzip.test_io_on_closed_object   sw   
 	MM$---))(		'z**FF1I +z**FF1I +z**FFH + MM$---))(		'z**GGCL +z**GGI +* +******** +****s<    HHH06I-IH	H-	0I	I	I(	c                   V P                  4        \        P                  V P                  R 4      ;_uu_ 4       pVP	                  \
        ^,          4       RRR4       \        P                  V P                  R4      ;_uu_ 4       pVP                  4       pRRR4       V P                  X\        ^2,          \
        ^,          ,           4       R#   + '       g   i     L; i  + '       g   i     LT; i)abNrx   )	rU   r   r?   r1   r@   data2rC   rA   rN   r~   s   &  r   test_appendTestGzip.test_append   s    ]]4==$//1GGEBJ 0 ]]4==$//1A 0U2X%(34 0/ 0/s   CC#C 	#C3	c                   \         P                  V P                  R ^	4      ;_uu_ 4       pVP                  R4       RRR4       \	        ^ ^4       FF  p\         P                  V P                  R^	4      ;_uu_ 4       pVP                  R4       RRR4       KH  	  \         P                  V P                  R4      ;_uu_ 4       pRp VP                  R4      pWE,          pV'       d   K$   RRR4       T P                  XR4       R#   + '       g   i     L; i  + '       g   i     K  ; i  + '       g   i     LK; i)rL      aNr   rx   r   i    s   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)r   r?   r1   r@   rh   rC   rA   )r   rG   izgfilecontentsztxts   &     r   test_many_appendTestGzip.test_many_append   s     ]]4==$22aGGDM 3q#At}}dA66! 76 
 ]]4==$//6H{{4( tU 0 	8, 32 766 0/s)   D<D"D-)D-D	D*-D=	c                X   \         P                  V P                  R 4      ;_uu_ 4       pVP                  \        ^2,          4       RRR4       \         P                  V P                  R4      ;_uu_ 4       pV P                  VP                  4       \        ^2,          4       RRR4       V P                  \        4      ;_uu_ 4        \         P                  V P                  R 4       RRR4       R#   + '       g   i     L; i  + '       g   i     Lk; i  + '       g   i     R# ; i)xbNrx   )	r   r?   r1   r@   rN   rA   rC   ry   FileExistsErrorrT   s   & r   test_exclusive_writeTestGzip.test_exclusive_write   s    ]]4==$//1GGEBJ 0]]4==$//1QVVXurz2 0//MM$--. 0/	 0//////s#   C26,D!D2D	D	D)	c           	        V P                  4        \        P                  V P                  R 4      ;_uu_ 4       p\        P
                  ! V4      ;_uu_ 4       pV Uu. uF  q3NK  	  ppRRR4       RRR4       V P                  X^2\        P                  RR7      ,          4       R# u upi   + '       g   i     LL; i  + '       g   i     LW; i)rx   NTkeepends)	rU   r   r?   r1   r   BufferedReaderrA   rN   
splitlines)r   rG   r=   lineliness   &    r   test_buffered_readerTestGzip.test_buffered_reader   s     	]]4==$//1""1%%*+,!$!, & 0 	U%5%5t%5%D DE - &% 0/s5   C B-	
B('B-	)C (B-	-B=8C  C	c                V   V P                  4        \        P                  V P                  R 4      ;_uu_ 4       p^ p VP	                  V4      pV'       g	   V^ 8w  d   M/V P                  \        V4      V8*  4       V^,           ^2,          pKQ  RRR4       R#   + '       g   i     R# ; irx   N)rU   r   r?   r1   readliner   rB   )r   rG   line_lengthLs   &   r   test_readlineTestGzip.test_readline  sy     ]]4==$//1KJJ{+[A-uA+ 56*Q"4 0///s   B7BB(	c                   V P                  4        \        P                  V P                  R 4      ;_uu_ 4       pVP	                  4       pRRR4       \        P                  V P                  R 4      ;_uu_ 4       p VP	                  ^4      pV. 8X  g   K   RRR4       R#   + '       g   i     L_; i  + '       g   i     R# ; ir   )rU   r   r?   r1   	readlines)r   rG   r   s   &  r   test_readlinesTestGzip.test_readlines  s     ]]4==$//1A 0 ]]4==$//1KK$7E 0/ 0/ 0//s   B!:B4B4!B1	4C	c                   V P                  4        \        P                  V P                  4      ;_uu_ 4       p VP	                  4       pVP                  4       pV'       g   MxVP	                  4       pVP                  V4       \        V4      ^
8  d   ^
pM\        V4      pVP                  V4      pV P                  VRV V4       VP                  V4       K  RRR4       R#   + '       g   i     R# ; i)r   N)
rU   r   r?   r1   r   r   r"   rB   rC   rA   )r   rG   oldposline1newposamountline2s   &      r   test_seek_readTestGzip.test_seek_read  s     ]]4==))Q

evu:b=F ZFv  w7v *)))s   )C%"A9C%%C6	c                P   V P                  4        \        P                  V P                  4      ;_uu_ 4       pVP	                  ^
4       VP                  ^
^R7       VP	                  ^
4      pRRR4       V P                  X\        R,          4       R#   + '       g   i     L/; i)r   )whenceN:      N)rU   r   r?   r1   rC   r"   rA   rN   )r   rG   ys   &  r   test_seek_whenceTestGzip.test_seek_whence2  so     ]]4==))QFF2JFF2aF r
A * 	E%L)	 *)s   6BB%	c                    \         P                  V P                  R 4      ;_uu_ 4       p\        ^ R^4       F%  pVP	                  V4       VP                  R4       K'  	  RRR4       R#   + '       g   i     R# ; i)r<   rb   s   GZ
N)r   r?   r1   rh   r"   r@   )r   rG   poss   &  r   test_seek_writeTestGzip.test_seek_write<  sR    ]]4==#..!QR(s  ) /...s   7A**A;	c                   V P                  4        \        P                  V P                  R 4      ;_uu_ 4       pV P	                  VP
                  P                  R4       RRR4       \        P                  ! V P                  4       \        P                  V P                  R4      ;_uu_ 4       pV P	                  VP
                  P                  R4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r=   rx   Nxr   )	rU   r   r?   r1   rA   	myfileobjrE   r   r0   rT   s   & r   	test_modeTestGzip.test_modeC  s    ]]4==#..!Q[[--t4 /']]4==#..!Q[[--t4 /. /. /..s   'C!0'C4!C1	4D	c                   R Fl  p\         P                  V P                  V4      ;_uu_ 4       pV P                  VR4       V P	                  VP
                  V P                  4       RRR4       Kn  	  R#   + '       g   i     K  ; i)rL   r[   N)rL   rx   )r   r?   r1   assertHasAttrrA   r[   )r   rE   rG   s   &  r   test_1647484TestGzip.test_1647484K  s]     Dt}}d33q""1f-  7 43 !333s   9A55Bc                H   V P                  4        \        P                  V P                  R 4      ;_uu_ 4       pV P	                  VP
                  R4       V P                  VP
                  P                  V P                  4       RRR4       R#   + '       g   i     R# ; i)rx   r[   N)rU   r   r?   r1   r   r   rA   r[   rT   s   & r   test_paddedfile_getattr TestGzip.test_paddedfile_getattrQ  sb    ]]4==$//1qyy&1QYY^^T]]; 0///s   ABB!	c                &   R p\         P                  V P                  RVR7      ;_uu_ 4       pVP                  \        4       RRR4       \         P                  V P                  4      ;_uu_ 4       pV P                  VR4       V P                  VP                  4       VP                  4       pV P                  V\        4       V P                  VP                  V4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)[r<   mtimeNr   )
r   r?   r1   r@   rN   r   assertIsNoner   rC   rA   )r   r   fWritefReaddataReads   &    r   
test_mtimeTestGzip.test_mtimeW  s    ]]4==#u]==LL >]]4==))Uug.ekk*zz|HXu-U[[%0 *) >=)))s   C,2A0C?,C<	?D	c                    R p\         P                  V P                  RVR7      ;_uu_ 4       pVP                  \        4       RRR4       \        V P                  R4      ;_uu_ 4       pVP                  ^4      pV P                  VR4       VP                  ^4      pV P                  VR4        V P                  P                  R4      R,           pRpVP                  ^4      pV P                  W4       VP                  ^4      p	V P                  V	\        P                  ! R
V4      4       VP                  ^4      p
V P                  V
R4       VP                  ^4      pV P                  VR4       VP                  \        V4      4      pV P                  W4       VP                  \        P                  ! V P                  4      P                   ^,
          4       VP                  ^4      pV P                  VR4       VP                  ^4      pV P                  V\        P                  ! R
\        \        4      4      4       RRR4       R#   + '       g   i     EL; i  \         d	    R	pRp ELi ; i  + '       g   i     R# ; i)r   r<   r   Nrx         zLatin-1    r   z<i      s   d)r   r?   r1   r@   rN   openrC   rA   encodeUnicodeEncodeErrorstructpackrB   r"   rR   statst_size)r   r   r   r   idBytescmByteexpectednameexpectedflags	flagsByte
mtimeBytesxflByteosByte	nameBytes
crc32Bytes
isizeBytess   &              r   test_metadataTestGzip.test_metadatab  s   ]]4==#u]==LL > $--&&% jjmGWk2ZZ]FVW-(#}}33I>H '
 

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

3|#45IY5 JJrwwt}}-559:AJZ)9:AJZT3u:)FGW '& >== & (" '( '&&s=   I)AI<1$I&E3I<I#	&I95I<8I99I<<J	c                P    \         P                  V n        V P                  4        R # r   )r   TESTFN_ASCIIr1   r  r   s   &r   test_metadata_ascii_name!TestGzip.test_metadata_ascii_name  s    !..r   c           
     ,   . ROp^pV F  w  r4pV P                  V4      ;_uu_ 4        \        P                  V P                  RVR7      pV;_uu_ 4        VP	                  \
        4       RRR4       \        V P                  R4      ;_uu_ 4       pVP                  V4       VP                  ^4      pV P                  W4       RRR4       RRR4       K  	  R#   + '       g   i     Lx; i  + '       g   i     L1; i  + '       g   i     EK
  ; i)fastr<   r   Nrx   ))r  r      )best	   r  )tradeoff   r  )
subTestr   r?   r1   r@   rN   r  r"   rC   rA   )	r   cases	xflOffsetr[   levelexpectedXflByter   r   r  s	   &        r   test_compresslevel_metadata$TestGzip.test_compresslevel_metadata  s    

 	.3*T/d##t}}cOVLL' $--..%JJy)#jjmG$$W> /	 $# /4 V..	 $##s;   -DC+&D4C.DC+&D.C>9DDc                   \         P                  V P                  R 4      ;_uu_ 4       pVP                  R4       RRR4       \         P                  V P                  R4      pVP	                  4         V;_uu_ 4         RRR4       V P                  R4        \         P                  V P                  R 4      ;_uu_ 4       p^^ ,           RRR4       V P                  R4       R#   + '       g   i     L; i  + '       g   i     L; i  \         d     Li ; i  + '       g   i     LZ; i  \         d     R# i ; i)rL   s   xxxNrx   z4__enter__ on a closed file didn't raise an exceptionz1/0 didn't raise an exception)r   r?   r1   r@   rS   failr   ZeroDivisionErrorrT   s   & r   test_with_openTestGzip.test_with_open  s    ]]4==$//1GGFO 0MM$--.			N 
 IILM	7t}}d33q! 4
 II56# 0/
  		
 43  		s_   C'4
D >C: D (D1 
DD1 'C7	:D
	D DDD.	)D1 1E ?E c                B   \         P                  V P                  R 4      ;_uu_ 4       pVP                  \        ^2,          4       RRR4       \        V P                  R4      ;_uu_ 4       pVP                  R4       RRR4       \         P                  V P                  R4      ;_uu_ 4       pVP                  4       pV P                  V\        ^2,          R4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)rL   Nr   rx   zIncorrect data in files2                                                     )r   r?   r1   r@   rN   r  rC   rA   r~   s   &  r   test_zero_padded_fileTestGzip.test_zero_padded_file  s    ]]4==$//1GGEBJ 0 $--&&!GGL! ' ]]4==$//1AQ
,DE 0/ 0/ '& 0//s#   C',C:./D'C7	:D
	D	c                N    V P                  \        P                  \        4       R # r   )assertIsSubclassr   BadGzipFileOSErrorr   s   &r   test_gzip_BadGzipFile_exception(TestGzip.test_gzip_BadGzipFile_exception  s    d..8r   c                   \        V P                  R 4      ;_uu_ 4       pVP                  \        ^2,          4       RRR4       \        P                  V P                  R4      ;_uu_ 4       pV P                  \        P                  VP                  4       RRR4       R#   + '       g   i     Lm; i  + '       g   i     R# ; i)rL   Nr=   )	r  r1   r@   rN   r   r?   ry   r4  r   )r   files   & r   test_bad_gzip_fileTestGzip.test_bad_gzip_file  sv    $--&&$JJurz" ']]4==#..$d..? /. '&...s   B!,+B4!B1	4C	c                   \         ^2,          p\        4       p\        P                  VRR7      ;_uu_ 4       pVP	                  V4       RRR4       VP                  4       p\        V4      p\        P                  VRR7      ;_uu_ 4       pV P                  VP                  4       V4       RRR4       R#   + '       g   i     Lu; i  + '       g   i     R# ; i)ra   rL   r   Nrx   )rN   r   r   r?   r@   getvaluerA   rC   )r   uncompressedr   rG   r   s   &    r   test_non_seekable_fileTestGzip.test_non_seekable_file  s    rzn]]3T]22aGGL! 3\\^
:&]]3T]22aQVVX|4 32	 32 322s   B6!C	6C		C	c           
        \         ^,          p\        P                  V P                  R4      ;_uu_ 4       pVP	                  V4       RRR4       R p\        P                  V P                  R4      ;_uu_ 4       p^!Vn        ^ pV! 4        FY  pVP                  V4      pVR8X  d    M@V P                  VP                  \        V4      4      V4       V\        V4      ,          pK[  	  V P                  VP                  ^d4      R4       V P                  V\        V4      4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)   rL   Nc               3   @   "    \        ^^2^
4       F  p V x  K	  	  K  5i)T)rh   )ns    r   sizes!TestGzip.test_peek.<locals>.sizes  s      q"b)AG *s   rx   r   )
rN   r   r?   r1   r@   max_read_chunkpeekrA   rC   rB   )r   r>  rG   rE  r   rD  ss   &      r   	test_peekTestGzip.test_peek  s    s{]]4==$//1GGL! 0	
 ]]4==$//1!AEWFF1I8  A3Q  QVVC[#.UC$56 0/ 0/ 0//s   D/;B*E/D?	E	c           	        \         ^2,          P                  R4      P                  RR7      pV P                  4        \        P                  V P                  R4      ;_uu_ 4       p\        P                  ! VRR7      ;_uu_ 4       pV P                  VP                  4       V4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)ra   asciiTr   r=   encodingN)rN   decoder   rU   r   r?   r1   r   TextIOWrapperrA   r   )r   r   rG   ts   &   r   test_textio_readlinesTestGzip.test_textio_readlines  s    ##G,777F]]4==#..!!!!g66!  6 7 /.66 /..s$   %!C!B9	'C9C	CC	c           	        \        V P                  R 4      ;_uu_ 4       p\        P                  VRR7      ;_uu_ 4       pVP	                  R4       V P                  VP                  VP                  4       V P                  VP                  4       VP                  4       4       V P                  VP                  \        P                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  R4       RRR4       V P                  XP                  R4       V P                  VP                  VP                  4       V P                  \         VP                  4       V P                  VP                  \        P                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  4       R4       RRR4       \        V P                  R4      ;_uu_ 4       p\        P                  VRR7      ;_uu_ 4       pVP	                  R	4       V P                  VP                  VP                  4       V P                  VP                  4       VP                  4       4       V P                  VP                  \        P                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  R4       RRR4       V P                  XP                  R4       V P                  VP                  VP                  4       V P                  \         VP                  4       V P                  VP                  \        P                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  4       R4       RRR4       \        V P                  R
4      ;_uu_ 4       p\        P                  VRR7      ;_uu_ 4       pVP	                  R4       V P                  VP                  VP                  4       V P                  VP                  4       VP                  4       4       V P                  VP                  \        P                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  R4       RRR4       V P                  XP                  R4       V P                  VP                  VP                  4       V P                  \         VP                  4       V P                  VP                  \        P                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  4       R4       RRR4       \        V P                  R4      ;_uu_ 4       p\        P                  VRR7      ;_uu_ 4       pV P                  VP#                  4       R4       V P                  VP                  VP                  4       V P                  VP                  4       VP                  4       4       V P                  VP                  \        P$                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  R4       RRR4       V P                  XP                  R4       V P                  VP                  VP                  4       V P                  \         VP                  4       V P                  VP                  \        P$                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP                  4       R4       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     R# ; i)r   r   r      oneFTNrL   r<      twor   rX      threerx   r=      twothree)r  r1   r   r?   r@   rA   r[   rP   rE   WRITEassertIsreadablewritabler   r   ry   AttributeErrorrC   READ)r   rawrG   s   &  r   test_fileobj_with_nameTestGzip.test_fileobj_with_name  s$   $--&&#s55  2  SZZ\:  4ajjlE2ajjlD1ajjlD1ahh. 6 MM!((D)QVVSXX.nahh7QVVTZZ0MM!**,.MM!**,-MM!**,-! '$ $--&&#s55  2  SZZ\:  4ajjlE2ajjlD1ajjlD1ahh. 6 MM!((D)QVVSXX.nahh7QVVTZZ0MM!**,.MM!**,-MM!**,-! '$ $--&&#s55!  2  SZZ\:  4ajjlE2ajjlD1ajjlD1ahh. 6 MM!((D)QVVSXX.nahh7QVVTZZ0MM!**,.MM!**,-MM!**,-! '$ $--&&#s55  ;7  2  SZZ\:  3ajjlD1ajjlE2ajjlD1ahh. 6 MM!((D)QVVSXX.nahh7QVVTYY/MM!**,-MM!**,.MM!**,-! '&k 655 '&&& 655 '&&& 655 '&&& 655 '&&s    d>Dd*	C4d>% e&De	C4e&+ fDe:	C4f1 f6Df"	,C4f6*d;5	d>>e	e#	e&&e7	:f	ff	"f3-	f66g	c           	     F   \         P                  ! V P                  \         P                  \         P                  ,          \         P
                  ,          4      p\         P                  ! VR 4      ;_uu_ 4       p\        P                  VRR7      ;_uu_ 4       pVP                  R4       V P                  VP                  R4       V P                  VP                  4       VP                  4       4       RRR4       V P                  XP                  R4       V P                  VP                  R4       V P                  \         VP                  4       RRR4       \         P                  ! V P                  \         P                  \         P                  ,          \         P"                  ,          4      p\         P                  ! VR4      ;_uu_ 4       p\        P                  VRR7      ;_uu_ 4       pVP                  R	4       V P                  VP                  R4       V P                  VP                  4       VP                  4       4       RRR4       V P                  XP                  R4       V P                  \         VP                  4       RRR4       \         P                  ! V P                  \         P                  \         P                  ,          \         P$                  ,          4      p\         P                  ! VR
4      ;_uu_ 4       p\        P                  VRR7      ;_uu_ 4       pVP                  R4       V P                  VP                  R4       V P                  VP                  4       VP                  4       4       RRR4       V P                  XP                  R4       V P                  \         VP                  4       RRR4       \         P                  ! V P                  \         P&                  4      p\         P                  ! VR4      ;_uu_ 4       p\        P                  VRR7      ;_uu_ 4       pV P                  VP)                  4       R4       V P                  VP                  R4       V P                  VP                  4       VP                  4       4       RRR4       V P                  XP                  R4       V P                  \         VP                  4       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     R# ; i)r   r   r   rV  rw   NTrL   r<   rW  r   rX   rX  rx   r=   rY  )rR   r  r1   O_WRONLYO_CREATO_EXCLfdopenr   r?   r@   rA   r[   rP   r[  r   ry   r^  O_TRUNCO_APPENDO_RDONLYrC   )r   fdr`  rG   s   &   r   test_fileobj_from_fdopen!TestGzip.test_fileobj_from_fdopenH  sz    WWT]]BKK"**$<ryy$HIYYr4  Cs55  ,  SZZ\: 6 MM!((D)QVVR(nahh7 ! WWT]]BKK"**$<rzz$IJYYr4  Cs55  ,  SZZ\: 6 QVVR(nahh7 ! WWT]]BKK"**$<r{{$JKYYr4  Cs55!  ,  SZZ\: 6 QVVR(nahh7 ! WWT]]BKK0YYr4  Cs55  ;7  ,  SZZ\: 6 QVVR(nahh7 ! 7 655 !   655 !   655 !   65 !  s   9 TAT	5A T U 5AT,	AU  U(5AU	AU(+ VA+U<	6AVT	TT)	,T=7	U  U	U%	U((U9	<VVV 	c           
        V P                  \        P                  R 4       V P                  \        P                  R4       \        P	                  V P
                  R4      P                  4        \        V P
                  R4      ;_uu_ 4       p\        P	                  VRR7      ;_uu_ 4       pV P                  VP                  \        P                  4       RRR4       \        P	                  VRR7      ;_uu_ 4       pV P                  VP                  \        P                  4       RRR4       \        P	                  VRR7      ;_uu_ 4       pV P                  VP                  \        P                  4       RRR4       \        P	                  VRR7      ;_uu_ 4       pV P                  VP                  \        P                  4       RRR4       V P                  \        4      ;_uu_ 4        \        P	                  VR	R7       RRR4       RRR4       R F{  p\        V P
                  V4      ;_uu_ 4       p\        P	                  VR
7      ;_uu_ 4       pV P                  VP                  \        P                  4       RRR4       RRR4       K}  	  R F  pRV9   d!   \        P                  ! V P
                  4       \        V P
                  V4      ;_uu_ 4       pV P                  \        4      ;_uu_ 4        \        P	                  VR
7      pRRR4       X;_uu_ 4        V P                  VP                  \        P                  4       RRR4       RRR4       K  	  R#   + '       g   i     EL; i  + '       g   i     ELa; i  + '       g   i     EL#; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELg; i  + '       g   i     EK  ; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     EK  ; i)rx   rL   r+br=   r   Nr<   rX   r   zr   )rx   ro  )rL   r   r   )rA   r   r_  rZ  r?   r1   rS   r  rE   ry   r   r   r0   assertWarnsFutureWarning)r   rG   grE   s   &   r   test_fileobj_modeTestGzip.test_fileobj_modep  s   D)T*dmmT*002$--''1qs33q  3 4qs33q  4 4qs33q  4 4qs33q  4 4"":..ac2 / (  DdmmT**a]]1]--$$QVVTYY7 . +*   %Dd{  /dmmT**a%%m44a0A 5Q$$QVVTZZ8  +* % 433333333333... ('' .-- +** 54Q +**s    O-+M.	'O?+N	*'O+N	<'O#+N*	%O3N>	O>O:+O&O:&P5PP5-+P"P5.M?9	ON	ON'!	O*N;5	O>O		OO#	&O71	O::PPP5"P2-P55Qc                4   V P                   p\        P                  ! V4      p\        P	                  VR 4      ;_uu_ 4       pVP                  \        ^2,          4       RRR4       V P                  XP                  V4       \        P	                  VR4      ;_uu_ 4       pV P                  VP                  4       \        ^2,          4       RRR4       V P                  VP                  V4       \        P	                  VR4      ;_uu_ 4       pV P                  VP                  4       \        ^2,          4       RRR4       V P                  VP                  V4       R#   + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     LU; irL   Nrx   )
r1   rR   fsencoder   r?   r@   rN   rA   r[   rC   )r   str_filenamebytes_filenamerG   s   &   r   test_bytes_filenameTestGzip.test_bytes_filename  s    }}\2]]>400AGGEBJ 10]]>400AQVVXurz2 10]]<..!QVVXurz2 /. 100 10 /.s$   E  ,E4,F E1	4F	F	c                	   \         P                  ! 4       p\        P                  VR R7      ;_uu_ 4       pVP	                  \
        ^2,          4       V P                  VP                  R4       V P                  \         P                  VP                  4       V P                  VP                  \        P                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP!                  4       R4       V P                  VP"                  R4       RRR4       V P                  XP"                  R4       V P                  VP                  R4       V P                  \$        VP                  4       V P                  VP                  \        P                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP!                  4       R4       VP'                  ^ 4       \        P                  VRR7      ;_uu_ 4       pV P                  VP)                  4       \
        ^2,          4       V P                  VP                  R4       V P                  \         P                  VP                  4       V P                  VP                  \        P*                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP!                  4       R4       V P                  VP"                  R4       RRR4       V P                  VP"                  R4       V P                  VP                  R4       V P                  \$        VP                  4       V P                  VP                  \        P*                  4       V P                  VP                  4       R4       V P                  VP                  4       R4       V P                  VP!                  4       R4       R#   + '       g   i     EL'; i  + '       g   i     EL	; i)rL   r   rw   FTNrx   )r   r   r   r?   r@   rN   rA   r[   ry   r   rP   rE   rZ  r[  r\  r]  r   r   r^  r"   rC   r_  )r   biorG   s   &  r   test_fileobj_without_name"TestGzip.test_fileobj_without_name  s   jjl]]3T]22aGGEBJQVVR(b55qxx@QVVTZZ0MM!**,.MM!**,-MM!**,-MM!((E* 3 	ahh%$.!((3,ajjlE*ajjlD)ajjlD)]]3T]22aQVVXurz2QVVR(b55qxx@QVVTYY/MM!**,-MM!**,.MM!**,-MM!((E* 3 	ahh%$.!((3+ajjlD)ajjlE*ajjlD)C 322$ 322s   D	QDQ0Q-	0R	c           	     .   V P                   R ,           p\        V P                   R4      ;_uu_ 4       p\        P                  W!RR7      ;_uu_ 4       pVP	                  \
        ^2,          4       V P                  VP                  V4       RRR4       RRR4       \        V P                   R4      ;_uu_ 4       p\        P                  W!RR7      ;_uu_ 4       pV P                  VP                  4       \
        ^2,          4       V P                  VP                  V4       RRR4       RRR4       \        P                  V P                   R4      ;_uu_ 4       pV P                  VP                  4       \
        ^2,          4       V P                  VP                  V P                   4       RRR4       R#   + '       g   i     EL3; i  + '       g   i     EL?; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)newrL   )r   r1   rE   Nrx   )	r1   r  r   r?   r@   rN   rA   r[   rC   )r   	filename2r   rG   s   &   r   test_fileobj_and_filename"TestGzip.test_fileobj_and_filename  sU   MME)	4==$''7mmGdmKKqGGEBJQVVY/ L ( 4==$''7mmGdmKKqQVVXurz2QVVY/ L (
 ]]4==$//1QVVXurz2QVVT]]3 0/ LKK (''
 LK ('
 0//sU    G	9F5	G	9 G0AG	!G0AH5G 	G		G	G-(G00H 	H	c                   \         P                  R\        R4      ,          ^	R7      pV P                  \	        V4      \
        P                  4       \
        P                  ! V4      p\         P                  VR7      pV P                  VP                  ^4      R4       ^\
        P                  ,           pV P                  VP                  P                  P                  4       VR4       R# )z-Decompressed data buffering should be limitedr  g    >Ar   rq  z)Excessive amount of data was decompressedN)r   r   int
assertLessrB   r   DEFAULT_BUFFER_SIZEr   r?   rA   rC   assertLessEqual_bufferr`  r   )r   bombdecomp
max_decomps   &   r   test_decompress_limited TestGzip.test_decompress_limited  s    }}USX-Q}?D	2#9#9:zz$t,Q////
V^^//446
7	9r   c           	        \         \        3 F  pR F  p\        P                  ! V.VO5!  pV P	                  \        V4      \        4       \        P                  \        P                  ! V4      RR7      ;_uu_ 4       pV P	                  VP                  4       V4       RRR4       K  	  K  	  R#   + '       g   i     K  ; i)r   rx   r   Nr   )r   )r"  )r   )rN   r   r   r   rA   typer>   r?   r   r   rC   )r   rD   r!   datacrG   s   &    r   test_compressTestGzip.test_compress  s    END.d2T2  ee4]]2::e+<4]HHA$$QVVXt4 IH / # IHHs   ?!B2	2Cc                   R p\         \        3 F  pR F  pV P                  W#R7      ;_uu_ 4        \        P                  ! V.VO5RV/ pV P                  \        V4      \        4       \        P                  \        P                  ! V4      RR7      ;_uu_ 4       pVP                  ^4       V P                  VP                  V4       RRR4       RRR4       K  	  K  	  R#   + '       g   i     L"; i  + '       g   i     K  ; i)r   )rD   r!   r   rx   r   Nr  )rN   r   r#  r   r   rA   r  r>   r?   r   r   rC   r   )r   r   rD   r!   r  rG   s   &     r   test_compress_mtimeTestGzip.test_compress_mtime  s    END.\\t\77 MM$CCUCE$$T%[%8rzz%/@tLLPQq	((%8 M 87 / #
 ML 877s$   A-C9	.C&C9	&C61C9	9D
c                   \         P                  \        ^ R7      p\         P                  \        4      pV P                  W4       \         P                  \        RR7      pV P	                  W4       \         P                  \        P                  ! V4      RR7      ;_uu_ 4       pVP                  ^4       V P                  VP                  ^4       RRR4       R#   + '       g   i     R# ; i)r   r   Nrx   r   )r   r   rN   rA   assertNotEqualr?   r   r   rC   r   r   )r   r  datac2datac3rG   s   &    r   test_compress_mtime_default$TestGzip.test_compress_mtime_default  s    e1-u%'uD1E*]]2::f#5D]AAQFF1Iqww* BAAAs   %.CC.	c           	     N   R F  pV P                  VR7      ;_uu_ 4        \        P                  \        ^ VR7      p\        P                  \        ^VR7      pV P	                  \        V4       V P                  \        V4       RRR4       K  	  R#   + '       g   i     K  ; i)r   r   r   r   Nr   *   )r#  r   r   rN   assertInassertNotIn)r   r   
nocompressyescompresss   &   r   test_compress_correct_level$TestGzip.test_compress_correct_level  su    EE**!]]5]O
"mmE%mPeZ0  4	 +* ***s   A%BB$c           
         R Fs  pV P                  VR7      ;_uu_ 4        \        P                  \        ^VR7      pV P	                  \
        P                  ! RVR,          4      V^3R4       RRR4       Ku  	  R#   + '       g   i     K  ; i)r   r   r  z<IxB:rf   r   Nz:Gzip header does not properly set either mtime or OS byte.Nr  )r#  r   r   rN   rA   r  unpack)r   r   r   s   &  r   test_issue112346TestGzip.test_issue112346  sm    EE**==au=M  MM&(4.9CLP +* ***s   AA<<Bc                   \         \        3 F  p\        P                  ! 4       p\        P                  VR R7      ;_uu_ 4       pVP                  V4       RRR4       V P                  \        P                  VP                  4       4      V4       \        P                  V4      pV P                  \        P                  V4      V4       K  	  R#   + '       g   i     L; i)rL   r   N)rN   r   r   r   r   r?   r@   rA   
decompressr=  r   )r   rD   r   rG   r  s   &    r   test_decompressTestGzip.test_decompress  s    END**,Cs66! 7T__S\\^<dCMM$'ET__U3T: #66s   CC!c                    \         P                  \        4      pV P                  \        \         P
                  VR R 4       R # )Nr   r   rN   ry   EOFErrorr  r   compressed_datas   & r   !test_decompress_truncated_trailer*TestGzip.test_decompress_truncated_trailer  -    --.(DOO_Sb5IJr   c                    \         P                  \        4      pV P                  \        \         P
                  VR R 4       R # )Nr  r  s   & r   test_decompress_missing_trailer(TestGzip.test_decompress_missing_trailer  r  r   c           	     l   \         ^2,          p\        P                  V4      RR p\        P                  \        P
                  ! V4      R7      ;_uu_ 4       pV P                  \        VP                  4       RRR4       \        P                  \        P
                  ! V4      R7      ;_uu_ 4       pV P                  VP                  \        V4      4      V4       V P                  \        VP                  ^4       RRR4       \        ^^
4       Fb  p\        P                  \        P
                  ! VRV 4      R7      ;_uu_ 4       pV P                  \        VP                  ^4       RRR4       Kd  	  R#   + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     K  ; i)ra   Nrq  r  )rN   r   r   r?   r   r   ry   r  rC   rA   rB   rh   )r   rD   	truncatedrG   r   s   &    r   test_read_truncatedTestGzip.test_read_truncated  s   RxMM$',	]]2::i#8]99Qh/ :]]2::i#8]99QQVVCI.5h2 : q"Arzz)BQ-'@AAQ!!(AFFA6 BA  :9999
 BAAs%   !E;3AF"F";F	F	"F3c                    R p\         P                  \        P                  ! V4      R7      ;_uu_ 4       pV P	                  VP                  4       R4       RRR4       R#   + '       g   i     R# ; i)s   cQ ExtraI-. 2Mx   rq  s   TestN)r   r?   r   r   rA   rC   )r   gzdatarG   s   &  r   test_read_with_extraTestGzip.test_read_with_extra-  sL    < ]]2::f#5]66!QVVXw/ 7666s   !A  A1	c                   \         P                  V P                  R 4      ;_uu_ 4       pVP                  \        4       RRR4       \         P                  V P                  R4      ;_uu_ 4       pVP
                  P                  P                  P                  4        RRR4       R#   + '       g   i     Lq; i  + '       g   i     R# ; irx  )	r   r  r1   r@   rN   r  r`  _fpprependrT   s   & r   test_prepend_errorTestGzip.test_prepend_error5  su    YYt}}d++qGGEN ,YYt}}d++qIIMM%%' ,+ ,++++s   B(//B;(B8	;C	c                   \         P                   ! R . RO4      p\        V4      VP                  ,          p\        P	                  \
        P                  ! 4       RR7      ;_uu_ 4       pV P                  VP                  V4      V4       V P                  VP                  4       V4       RRR4       R#   + '       g   i     R# ; i)Qr<   r   N)r         rf      )
rs   rB   itemsizer   r?   r   r   rA   r@   r   )r   qLENGTHrG   s   &   r   test_issue44439TestGzip.test_issue44439<  s|    KK_-Q!**$]]2::<c]::aQWWQZ0QVVXv. ;:::s   (AB44C	c                   \         P                  ! 4       pR p\        P                  VRR7      ;_uu_ 4       pVP	                  V4       VP                  4        VP                  4       pRRR4       VP                  4       pV P                  \        P                  V4      V4       V P                  \        4      ;_uu_ 4        \        P                  X4       RRR4       \        P                  \        P                  ) R7      p\         P                  ! X4      p\        P                  V4       VP                  VP                  4       4      pV P                  Wr4       R#   + '       g   i     EL; i  + '       g   i     L; i)   important message here.r<   r   N)wbits)r   r   r   r?   r@   rO   r=  rA   r  ry   r  r   decompressobj	MAX_WBITS_read_gzip_headerrC   )r   bmessagerG   partial_data	full_datar]   read_messages   &       r   test_flush_flushes_compressor&TestGzip.test_flush_flushes_compressorD  s   JJL,]]13]//1GGGGGI::<L 0 JJL	3W= x((OOL) )dnn_5JJ|$q!||AFFH-/ 0// )(s   2E#E7#E4	7F	c                    ! R  R4      p\         P                  ! 4       pV! 4       p\        P                  VRR7      ;_uu_ 4       pW4n        VP                  4        VP                  ^24       VP                  ^dR7       RRR4       \        P                  ^2^dR.pV P                  VP                  V4       R#   + '       g   i     LB; i)c                   6   a  ] tR tRt o R tR tRR ltRtV tR# )1TestGzip.test_flush_modes.<locals>.FakeCompressori\  c                    . V n         R # r   modesr   s   &r   __init__:TestGzip.test_flush_modes.<locals>.FakeCompressor.__init__]  s	    
r   c                    R # r   r   )r   rD   s   &&r   r   :TestGzip.test_flush_modes.<locals>.FakeCompressor.compress_  s    r   c                <    V P                   P                  V4       R # r  )r  r   )r   rE   s   &&r   rO   7TestGzip.test_flush_modes.<locals>.FakeCompressor.flusha  s    

!!$'r   r  N))	r$   r%   r&   r'   r  r   rO   r(   r)   r*   s   @r   FakeCompressorr  \  s       r   r  r<   r   )	zlib_modeNr  )
r   r   r   r?   r   rO   r   Z_SYNC_FLUSHrA   r  )r   r  r  fcrG   expected_modess   &     r   test_flush_modesTestGzip.test_flush_modesY  s    	 	 JJL]]13]//1JGGIGGBKGGcG"	 0 	
 	>2 0/s   :B::C
	c                   \         P                  ! 4       pR p\        P                  VRR7      ;_uu_ 4       pVP	                  V4       VP                  \        V4      4       VP	                  V4       RRR4       VP                  4       pV P                  \        P                  V4      V^,          4       R#   + '       g   i     LN; i)r  r<   r   N)
r   r   r   r?   r@   r"   rB   r=  rA   r  )r   r  r  rG   rD   s   &    r   test_write_seek_writeTestGzip.test_write_seek_writet  s     JJL,]]13]//1GGGFF3w< GGG 0 zz|.!< 0/s   =B::C
	c           	        \        4       ;_uu_ 4       pV P                  \        4      ;_uu_ 4        \        P	                  \
        P                  ! 4       R R7       \        P                  ! 4        V P                  VP                  4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r<   r   N)r   rr  ResourceWarningr   r?   r   r   gccollectr   
unraisable)r   cms   & r   test_refloop_unraisable TestGzip.test_refloop_unraisable  sq    
 ())R!!/22bjjl=

!!"--0 3 *)22 *))s#   B1AB	B1B.)B11C	)r1   N)r  )Cr$   r%   r&   r'   rI   rU   r^   rk   ro   rt   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-  r0  r6  r:  r?  rJ  rS  ra  rl  ru  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r(   r)   r*   s   @r   r:   r:   <   sR    /0"'8?.&7
*%( S#. $.85-&/	F
5
"&*!58<	11Hf?(7*
F9@57,7G.R&8P98/#*J4
95	9	+5	;KK70(/0*36
=	1 	1r   r:   c                   V   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tRtV tR# )TestOpeni  c                   \         ^2,          p\        P                  V P                  R4      ;_uu_ 4       pVP	                  V4       RRR4       \        V P                  R4      ;_uu_ 4       p\        P                  VP                  4       4      pV P                  W14       RRR4       \        P                  V P                  R4      ;_uu_ 4       pV P                  VP                  4       V4       RRR4       \        P                  V P                  R4      ;_uu_ 4       pVP	                  V4       RRR4       \        V P                  R4      ;_uu_ 4       p\        P                  VP                  4       4      pV P                  W1^,          4       RRR4       V P                  \        4      ;_uu_ 4        \        P                  V P                  R4       RRR4       \        P                  ! V P                  4       \        P                  V P                  R4      ;_uu_ 4       pVP	                  V4       RRR4       \        V P                  R4      ;_uu_ 4       p\        P                  VP                  4       4      pV P                  W14       RRR4       R#   + '       g   i     ELf; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELf; i  + '       g   i     EL4; i  + '       g   i     L; i  + '       g   i     R# ; i)ra   rL   Nrx   r   r   rN   r   r  r1   r@   r  rC   rA   ry   r   r   r0   r   r>  rG   	file_datas   &   r   test_binary_modesTestOpen.test_binary_modes  s   rzYYt}}d++qGGL! ,$--&&!1IY5 ' YYt}}d++qQVVX|4 , YYt}}d++qGGL! ,$--&&!1IYq(89 ' //IIdmmT* 0'YYt}}d++qGGL! ,$--&&!1IY5 '&) ,++&&& ,++ ,++&&& 0// ,+&&&_   J%.5J9!K$K!<K5=!L	.L&5L0%J6	9K
	K	!K2	5L		L	L-	0M	c                >   \         P                  ! V P                  4      p\        P	                  VR 4      ;_uu_ 4       pVP                  \        ^2,          4       RRR4       V P                  XP                  V P                  4       \        P	                  VR4      ;_uu_ 4       pVP                  \        4       RRR4       V P                  VP                  V P                  4       \        P	                  V4      ;_uu_ 4       pV P                  VP                  4       \        ^3,          4       RRR4       V P                  VP                  V P                  4       R#   + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     L_; i)rL   Nr   )
r   rY   r1   r   r  r@   rN   rA   r[   rC   )r   r1   rG   s   &  r   test_pathlike_fileTestOpen.test_pathlike_file  s    %%dmm4YYx&&!GGEBJ '/YYx&&!GGEN '/YYx  AQVVXurz2 !/ '&& '& ! s#   E%(E9	,F%E6	9F		F	c                   \         ^2,          p\        P                  V P                  R4      ;_uu_ 4       pVP	                  V4       RRR4       \        V P                  R4      ;_uu_ 4       p\        P                  VP                  4       4      pV P                  W14       RRR4       \        P                  V P                  R4      ;_uu_ 4       pV P                  VP                  4       V4       RRR4       \        P                  V P                  R4      ;_uu_ 4       pVP	                  V4       RRR4       \        V P                  R4      ;_uu_ 4       p\        P                  VP                  4       4      pV P                  W1^,          4       RRR4       V P                  \        4      ;_uu_ 4        \        P                  V P                  R4       RRR4       \        P                  ! V P                  4       \        P                  V P                  R4      ;_uu_ 4       pVP	                  V4       RRR4       \        V P                  R4      ;_uu_ 4       p\        P                  VP                  4       4      pV P                  W14       RRR4       R#   + '       g   i     ELf; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELf; i  + '       g   i     EL4; i  + '       g   i     L; i  + '       g   i     R# ; i)ra   r<   Nrx   r=   rX   r   r  r  s   &   r   test_implicit_binary_modes#TestOpen.test_implicit_binary_modes  s   rzYYt}}c**aGGL! +$--&&!1IY5 ' YYt}}c**aQVVX|4 + YYt}}c**aGGL! +$--&&!1IYq(89 ' //IIdmmS) 0'YYt}}c**aGGL! +$--&&!1IY5 '&) +**&&& +** +**&&& 0// +*&&&r  c                   \         P                  R 4      ^2,          pVP                  R\        P                  4      p\
        P                  V P                  RR R7      ;_uu_ 4       pVP                  V4       RRR4       \        V P                  R4      ;_uu_ 4       p\
        P                  VP                  4       4      P                  R 4      pV P                  WB4       RRR4       \
        P                  V P                  RR R7      ;_uu_ 4       pV P                  VP                  4       V4       RRR4       \
        P                  V P                  RR R7      ;_uu_ 4       pVP                  V4       RRR4       \        V P                  R4      ;_uu_ 4       p\
        P                  VP                  4       4      P                  R 4      pV P                  WB^,          4       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL/; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)rM  
wtrN  Nrx   rtatrN   rP  replacerR   linesepr   r  r1   r@   r  rC   rA   r   r>  uncompressed_rawrG   r	  s   &    r   test_text_modesTestOpen.test_text_modes  s~   ||G,r1'//bjjAYYt}}dWY==GGL! >$--&&!188AIY9 ' YYt}}dWY==QVVX|4 >YYt}}dWY==GGL! >$--&&!188AIY1(<= '& >==&&& >===&&&s>   'G5AH	!H(H0 AI5H		H	H-	0I 	I	c                   \         ^2,          pVP                  R4      p\        P                  V4      p\        P	                  \
        P                  ! V4      R4      ;_uu_ 4       pV P                  VP                  4       V4       RRR4       \        P	                  \
        P                  ! V4      R4      ;_uu_ 4       pV P                  VP                  4       V4       RRR4       \        P	                  \
        P                  ! V4      RRR7      ;_uu_ 4       pV P                  VP                  4       V4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)ra   rM  r=   Nrx   r  rN  )	rN   rP  r   r   r  r   r   rA   rC   )r   uncompressed_bytesuncompressed_strr   rG   s   &    r   test_fileobjTestOpen.test_fileobj  s    "RZ-44W=]]#56
YYrzz*-s33qQVVX'9: 4YYrzz*-t44QVVX'9: 5YYrzz*-tgYFF!QVVX'78 GF	 4344FFFs$   &!E	!E!E/	E	E,	/F 	c                0   V P                  \        4      ;_uu_ 4        \        P                  R 4       RRR4       V P                  \        4      ;_uu_ 4        \        P                  V P
                  R4       RRR4       V P                  \        4      ;_uu_ 4        \        P                  V P
                  R4       RRR4       V P                  \        4      ;_uu_ 4        \        P                  V P
                  RRR7       RRR4       V P                  \        4      ;_uu_ 4        \        P                  V P
                  RRR7       RRR4       V P                  \        4      ;_uu_ 4        \        P                  V P
                  RR	R
7       RRR4       R#   + '       g   i     ELw; i  + '       g   i     ELE; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)gw/^@Nwbtxbtrx   zutf-8rN  ignore)errorsr  )newline)ry   rz   r   r  r   r1   r   s   &r   test_bad_paramsTestOpen.test_bad_params  s3   y))IIg *z**IIdmmU+ +z**IIdmmU+ +z**IIdmmTGI< +z**IIdmmT(I; +z**IIdmmT4I8 +* *))*************sG   F"!F6!G
%#G-#G15#H"F3	6G	
G	G.	1H	H	c                   \         P                  R 4      ^2,          pVP                  R\        P                  4      p\
        P                  V P                  RRR7      ;_uu_ 4       pVP                  V4       RRR4       \        V P                  R4      ;_uu_ 4       p\
        P                  VP                  4       4      P                  R4      pV P                  WB4       RRR4       \
        P                  V P                  RRR7      ;_uu_ 4       pV P                  VP                  4       V4       RRR4       R#   + '       g   i     L; i  + '       g   i     Lx; i  + '       g   i     R# ; i)rM  r  r  zutf-16rN  Nrx   r  r  r  s   &    r   test_encodingTestOpen.test_encoding  s    ||G,r1'//bjjAYYt}}dXY>>!GGL! ?$--&&!188BIY9 ' YYt}}dXY>>!QVVX|4 ?> ?>&& ?>>s%   'E AE!E& E	E#	&E7	c                   \         P                  V P                  R 4      ;_uu_ 4       pVP                  R4       RRR4       \         P                  V P                  RRRR7      ;_uu_ 4       pV P	                  VP                  4       R4       RRR4       R#   + '       g   i     Lf; i  + '       g   i     R# ; i)rL   s   foobarNr  rM  r'  )rO  r(  foobar)r   r  r1   r@   rA   rC   rT   s   & r   test_encoding_error_handler$TestOpen.test_encoding_error_handler  sz    YYt}}d++qGGM" ,YYt}}dWXYNNQVVXx0 ON ,+NNNs   B.!B,B)	,B=	c                   \         P                  R 4      ^2,          p\        P                  V P                  RR RR7      ;_uu_ 4       pVP                  V4       RRR4       \        P                  V P                  RR RR7      ;_uu_ 4       pV P                  VP                  4       V.4       RRR4       R#   + '       g   i     Lg; i  + '       g   i     R# ; i)rM  r  r  )rO  r)  Nr  )rN   rP  r   r  r1   r@   rA   r   )r   r>  rG   s   &  r   test_newlineTestOpen.test_newline  s    ||G,r1YYt}}dWdYKKqGGL! LYYt}}dWdYKKqQ[[]\N; LK LKKKKs   B9"C9C		C	r   N)r$   r%   r&   r'   r
  r  r  r  r"  r*  r-  r1  r5  r(   r)   r*   s   @r   r  r    s7     66
068> 	99
51< <r   r  c                    a  V 3R  lpV# )c                 J   <a  \         P                  ! S 4      VV 3R  l4       pV# )c                     < \         P                  ! S4        S! V / VB \        P                  ! S4       #   \        P                  ! S4       i ; ir   )rR   makedirsr   rmtree)r!   kwargs	directoryfunctions   *,r   wrapper?create_and_remove_directory.<locals>.decorator.<locals>.wrapper  s>    KK	",00  +	  +s	   7 A)	functoolswraps)r>  r?  r=  s   f r   	decorator.create_and_remove_directory.<locals>.decorator  s%    		"	, 
#	, r   r   )r=  rC  s   f r   create_and_remove_directoryrE    s     r   c                      a  ] tR tRt o Rt]! 4       R 4       t]! ]4      R 4       t	R t
]! 4       ]! ]4      R 4       4       t]! ]4      R 4       t]! ]4      R 4       tR	 tR
 tRtV tR# )TestCommandLinei%  s   This is a simple test with gzipc           	     h   \         P                  ! 4       ;_uu_ 4       p\        P                  VR R7      ;_uu_ 4       pVP	                  V P
                  4       RRR4       \        P                  RRR3p\        V\        \        \        R7      ;_uu_ 4       pVP                  VP                  4       4      w  rVRRR4       RRR4       V P                  XR4       V P                  XV P
                  4       R#   + '       g   i     L; i  + '       g   i     L[; i  + '       g   i     Lf; i)rL   r   N-mr   -dstdinstdoutstderrr   )r   r   r   r?   r@   rD   sys
executabler   r   communicater=  rA   )r   bytes_io	gzip_filer!   procouterrs   &      r   test_decompress_stdin_stdout,TestCommandLine.test_decompress_stdin_stdout(  s    ZZ\\Xxd;;y		* < >>45Dt4TBBd++H,=,=,?@ C  	c"dii( <; CB \s:    D!C;	?D!"D	;D!;DD!DD!!D1	c                8   \         P                  P                  \        R 4      pV P	                  \         P                  P                  V4      4       \        P                  VRR7      ;_uu_ 4       pVP                  V P                  4       RRR4       \        RRRV4      w  r4p\        \         P                  P                  \        R4      R4      ;_uu_ 4       pV P                  VP                  4       V P                  4       RRR4       V P                  \         P                  P                  V4      4       V P                  V^ 4       V P                  VR	4       V P                  VR	4       R#   + '       g   i     L; i  + '       g   i     L; i)
ztestgzip.gzrL   )rE   NrI  r   rJ  testgziprx   r   )rR   pathr   TEMPDIRr   existsr   r  r@   rD   r
   rA   rC   r   )r   gzipnamefprcrU  rV  gunzipeds   &      r   test_decompress_infile_outfile.TestCommandLine.test_decompress_infile_outfile5  s	   77<<712YYxdY++rHHTYY ,'fdHE"'',,w
3T::hX]]_dii8 ; 	x01Qc"c" ,+ ;:s   2E6+F	6F		F	c                    \        R RRR4      w  rpV P                  RVP                  4       4       V P                  V^4       V P                  VR4       R# )rI  r   rJ  zthisisatest.outs.   filename doesn't end in .gz: 'thisisatest.out'r   N)r   rA   stripr   r`  rU  rV  s   &   r   $test_decompress_infile_outfile_error4TestCommandLine.test_decompress_infile_outfile_errorF  sN    ,T64ARSJCIIKXQc"r   c                :   \         P                  R R3p\        V\        \        \        R7      ;_uu_ 4       pVP	                  V P
                  4      w  r4RRR4       V P                  XR4       V P                  XR,          R4       R#   + '       g   i     L=; i)rI  r   rK  Nr   :Nr  Nr   )rO  rP  r   r   rQ  rD   rA   )r   r!   rT  rU  rV  s   &    r   test_compress_stdin_outfile+TestCommandLine.test_compress_stdin_outfileL  sq     ~~tV+4tD>>$''		2HC ? 	c"R+.	 ?>s   B

B	c                   \         P                  P                  \        R 4      pVR,           pV P	                  \         P                  P                  V4      4       \        VR4      ;_uu_ 4       pVP                  V P                  4       RRR4       \        RRV4      w  rEpV P                  \         P                  P                  V4      4       V P                  VR4       V P                  VR4       R#   + '       g   i     Lt; i)rZ  .gzrL   NrI  r   r   )rR   r[  r   r\  r   r]  r  r@   rD   r
   r   rA   )r   local_testgzipr^  r_  r`  rU  rV  s   &      r   $test_compress_infile_outfile_default4TestCommandLine.test_compress_infile_outfile_defaultV  s    gz:!E)12.$''2HHTYY ( (fnEx01c"c" ('s   0C88D	c           
     $   R	 EF`  pV P                  VR7      ;_uu_ 4        \        P                  P                  \        R4      pVR,           pV P                  \        P                  P                  V4      4       \        VR4      ;_uu_ 4       pVP                  V P                  4       RRR4       \        RRW4      w  rVpV P                  \        P                  P                  V4      4       V P                  VR4       V P                  VR4       \        P                  ! V4       V P                  \        P                  P                  V4      4       RRR4       EKc  	  R#   + '       g   i     L; i  + '       g   i     EK  ; i)
--fast)compress_levelrZ  rm  rL   NrI  r   r   )rr  --best)r#  rR   r[  r   r\  r   r]  r  r@   rD   r
   r   rA   remove)r   rs  rn  r^  r_  r`  rU  rV  s   &       r   test_compress_infile_outfile,TestCommandLine.test_compress_infile_outfilee  s   2N^<<!#gz!B)E1  !9:.$//2HHTYY' 0  0fn]x 89  c*  c*		(#  !9: =< 3 0/ =<<s%   A0E=E*-B.E=*E:5E==Fc                p    \        R RRR4      w  rpV P                  RV4       V P                  VR4       R# )rI  r   rr  rt  s8   error: argument --best: not allowed with argument --fastr   Nr   r  rA   rf  s   &   r   %test_compress_fast_best_are_exclusive5TestCommandLine.test_compress_fast_best_are_exclusivex  s6    ,T68XNQSVWc"r   c                p    \        R RRR4      w  rpV P                  RV4       V P                  VR4       R# )rI  r   rr  rJ  sA   error: argument -d/--decompress: not allowed with argument --fastr   Nry  rf  s   &   r   -test_decompress_cannot_have_flags_compression=TestCommandLine.test_decompress_cannot_have_flags_compression}  s6    ,T68TJZ\_`c"r   r   N)r$   r%   r&   r'   rD   r	   rW  rE  r\  rb  rg  rj  ro  rv  rz  r}  r(   r)   r*   s   @r   rG  rG  %  s     -D
) 
) !)# *# #  )/ * / !)# *# !); *;$#
# #r   rG  __main__)*__doc__rs   rA  r  r   rR   r  rO  unittestwarnings
subprocessr   r   test.supportr   r   r   r   r   r	   test.support.script_helperr
   r   import_moduler   r   rN   r   r[  abspathr8   r\  r   r   TestCaser-   r:   r  rE  rG  r$   mainr   r   r   <module>r     s      	 	 	  
   " 3 & " = = N""6*""6*		 ''//)**
+h
6&2:: &(x   (N1x N1bH<x H<V
[#h'' [#| zMMO r   