python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_gzip.cpython-312.opt-1.pyc

ΑedZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
ddlmZddlmZmZmZddlmZmZe
j*dZe
j*d	Zd
ZdZej4j7ej8dzZGd
dej<ZGddej@Z!Gdde!Z"Gdde!Z#dZ$Gddej@Z%e&dk(rejNyy)z!Test script for the gzip module.
N)PIPEPopen)
import_helper)	os_helper)_4G
bigmemtestrequires_subprocess)assert_python_okassert_python_failuregzipzlibsy  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-gzdirceZdZdZdZdZy)UnseekableIOcy)NFselfs B/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_gzip.pyseekablezUnseekableIO.seekable&sc"tjNioUnsupportedOperationrs rtellzUnseekableIO.tell)%%%rc"tjrr)rargss  rseekzUnseekableIO.seek,rrN)__name__
__module____qualname__rrr rrrrr%s&&rrc0eZdZejZdZdZy)BaseTestcBtj|jyrrunlinkfilenamers rsetUpzBaseTest.setUp3'rcBtj|jyrr'rs rtearDownzBaseTest.tearDown6r+rN)r!r"r#rTESTFNr)r*r-rrrr%r%0sH((rr%cZeZdZd7dZdZdZdZdZdZdZ	dZ
d	Zee
d
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!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.Z0d/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7y6)8TestGzipct|}tj|jd|z5}|j	|}ddd|jt
|tj|jd|z5}|j|j|dddy#1swYqxYw#1swYyxYw)Nwr)bytesrGzipFiler)writeassertEquallenread)rdatamodeb_datafls      rwrite_and_read_backzTestGzip.write_and_read_back;st
]]4==#d(
3	q
A	CK(
]]4==#d(
3	/qQVVXv.	/	/			/	/sB1!B=1B:=Cctj|jd5}|jtdz|j|j
ttdr#tj|j
|jdddjy#1swYxYw)Nwb2fsync)rr5r)r6data1flushfilenohasattrosrCcloserr=s  r
test_writezTestGzip.test_writeCs
]]4==$
/	1
GGEBJ
GGI
HHJr7#$
GGI		
			sA<B66B?cntj|j}tj	|d5}|jtdzddd|jjttj	|d5}|jtdddtj	|5}|j}ddd|jtdz|j|jty#1swYxYw#1swY}xYw#1swY[xYw)Nr2rBa3)pathlibPathr)rr5r6rDassertIsInstancenamestrr9r7)rr)r=ds    r"test_write_read_with_pathlike_filez+TestGzip.test_write_read_with_pathlike_fileQs<<

.
]]8S
)	 Q
GGEBJ	 affc*
]]8S
)	Q
GGEN	
]]8
$	A	EBJ'affc*	 	 				s#D
DD+DD(+D4c|jttdzttt	d}|jdgd}|j|y)NrBB)rY)shape)r?
memoryviewrDr4rangecast)rmr:s   rtest_write_memoryviewzTestGzip.test_write_memoryview`sL  EBJ!78uU3Z()vvcv)  &rcF|jttdzy)NrB)r?	bytearrayrDrs rtest_write_bytearrayzTestGzip.test_write_bytearrayfs  52:!67rc\|jtjdtdzy)NI()r?arrayrDrs rtest_write_arrayzTestGzip.test_write_arrayis  S%"*!=>rc6tj|jd5}|jt5|jdddd|jt5|jgddd|jtdddtj|jd5}|j|jtdddy#1swYxYw#1swYxYw#1swYoxYw#1swYyxYw)NrArb)	rr5r)assertRaises	TypeErrorr6rDr7r9rJs  rtest_write_incompatible_typez%TestGzip.test_write_incompatible_typels]]4==$
/	1""9-

""9-


GGEN	]]4==$
/	.1QVVXu-	.	.



			.	.sFDC+	D&C78D=%D+C4	0D7D	<DDDc|jtj|jd5}|j	}ddd|jtdzy#1swY#xYw)Nr3rB)rKrr5r)r9r7rDrr=rTs   r	test_readzTestGzip.test_readysT
]]4==#
.	!A	E"H%		sA$$A-c|jg}d}tj|jd5}	|j	}|sn@|j||t
|z
}|j|j|S	ddd|jdj|tdzy#1swY2xYw)Nrr3rrB)rKrr5r)read1appendr8r7rjoinrD)rblocksnreadr=rTs     r
test_read1zTestGzip.test_read1s
]]4==#
.	2!GGI

a Q  51		2	
&)52:6	2	2sAB<<C)sizememusectjtd}tjt	j
|d}|j
|j|ty)Nry
compresslevelrkfileobjr;)rcompressrDr5rBytesIOr7r9)rrz
compressedr=s    rtest_read_largezTestGzip.test_read_largesI]]5]:
MM"**Z"8tMDu-rc:|jtj|jd}|j}|j|j|j|j|j|jt5|jdddd|jt5|jdddd|jt5|jdddtj|jd}|j}|j|j|j|j|j|jt5|jdddd|jt5|jdddy#1swY7xYw#1swYxYw#1swYxYw#1swY^xYw#1swYyxYw)Nr3ryrr2r)rKrr5r)rassertFalseclosedrI
assertTruerl
ValueErrorr9r rr6rE)rr=rs   rtest_io_on_closed_objectz!TestGzip.test_io_on_closed_objects
	
MM$---))(		'


z
*	
FF1I	


z
*	
FF1I	


z
*	
FFH	
MM$---))(		'


z
*	
GGCL	


z
*	
GGI												s<GG,6G9HHG),G69HHHc|jtj|jd5}|j	t
dzdddtj|jd5}|j
}ddd|jtdzt
dzzy#1swYfxYw#1swY9xYw)NabrkrB)	rKrr5r)r6data2r9r7rDrps   rtest_appendzTestGzip.test_appends
]]4==$
/	 1
GGEBJ	 ]]4==$
/	1A	U2X%(34	 	 		sB/2B;/B8;Cctj|jdd5}|jddddt	ddD]=}tj|jdd5}|jdddd?tj|jd5}d}	|jd	}||z
}|sn	ddd|j
d
y#1swYxYw#1swYxYw#1swY4xYw)NrA	arrrkri saaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)rr5r)r6r]r9r7)rr=izgfilecontentsztxts      rtest_many_appendzTestGzip.test_many_appends]]4==$
2	a
GGDM	q#	At}}dA6
!


	
]]4==$
/	#6H{{4(D U#	#	
8,		

	#	#s#C",C.(C:"C+.C7	:Dctj|jd5}|jtdzdddtj|jd5}|j|j
tdzddd|jt5tj|jddddy#1swYxYw#1swYTxYw#1swYyxYw)NxbrBrk)	rr5r)r6rDr7r9rlFileExistsErrorrJs  rtest_exclusive_writezTestGzip.test_exclusive_writes
]]4==$
/	 1
GGEBJ	 
]]4==$
/	31QVVXurz2	3



/	/MM$--.	/	/		 	 	3	3	/	/s#C"(C'!C)CC&)C2c\|jtj|jd5}t	j
|5}|Dcgc]}|}}dddddd|j
dtjdzycc}w#1swY@xYw#1swYDxYw)NrkrBTkeepends)	rKrr5r)rBufferedReaderr7rD
splitlines)rr=r3lineliness     rtest_buffered_readerzTestGzip.test_buffered_readers	

]]4==$
/	-1""1%
-*+,$,,
-	-	
U%5%5t%5%D DE-
-
-	-	-s5B"B	BBB"BB	B""B+c|jtj|jd5}d}	|j	|}|s|dk7rn&|jt
||k|dzdz}?	dddy#1swYyxYw)NrkrryrB)rKrr5r)readlinerr8)rr=line_lengthLs    r
test_readlinezTestGzip.test_readlines]]4==$
/	51KJJ{+[A-uA+ 56*Q"4	/4		5	5	5sAA>>BcL|jtj|jd5}|j	}dddtj|jd5}	|j	d}|gk(rn	dddy#1swYMxYw#1swYyxYw)Nrk)rKrr5r)	readlines)rr=rs   rtest_readlineszTestGzip.test_readliness]]4==$
/	1
A	]]4==$
/	"1KK$7E!	"	"			"	"sB*BBB#c|jtj|j5}	|j	}|j}|snu|j	}|j
|t|dkDrd}nt|}|j|}|j|d|||j
|	dddy#1swYyxYw)N
)
rKrr5r)rrr r8r9r7)rr=oldposline1newposamountline2s       rtest_seek_readzTestGzip.test_seek_reads]]4==
)
	Q

evu:b=F ZFv  w7v$	
	
	
	sBCCc(|jtj|j5}|j	d|jdd|j	d}ddd|j
tddy#1swY#xYw)Nrry)whence)rKrr5r)r9r r7rD)rr=ys   rtest_seek_whencezTestGzip.test_seek_whencesu]]4==
)	Q
FF2J
FF2aF r
A		
E"RL)			s6BBctj|jd5}tdddD]$}|j	||jd&	dddy#1swYyxYw)Nr2rrWsGZ
)rr5r)r]r r6)rr=poss   rtest_seek_writezTestGzip.test_seek_writesZ
]]4==#
.	!!QR(
!s 
!	!	!	!s5A  A)c|jtj|jd5}|j	|j
jddddtj|jtj|jd5}|j	|j
jddddy#1swYxxYw#1swYyxYw)Nr3rkxr)	rKrr5r)r7	myfileobjr;rr(rJs  r	test_modezTestGzip.test_modes
]]4==#
.	5!Q[[--t4	5'
]]4==#
.	5!Q[[--t4	5	5	5	5	5	5s'C'CCC$cdD]l}tj|j|5}|jt	|d|j|j|jdddny#1swYyxYw)N)rArkrR)rr5r)rrGr7rR)rr;r=s   rtest_1647484zTestGzip.test_1647484'sj 	8Dt}}d3
8q6 23  7
8
8	8
8
8sAA33A<	c8|jtj|jd5}|j	t|jd|j|jj|jdddy#1swYyxYw)NrkrR)	rKrr5r)rrGrr7rRrJs  rtest_paddedfile_getattrz TestGzip.test_paddedfile_getattr-sh
]]4==$
/	<1OOGAIIv67QYY^^T]];	<	<	<sABBcd}tj|jd|5}|jtdddtj|j5}|jt
|d|j|j|j}|j|t|j|j|dddy#1swYxYw#1swYyxYw)N[r2mtimer)rr5r)r6rDrrGassertIsNonerr9r7)rrfWritefReaddataReads     r
test_mtimezTestGzip.test_mtime3s
]]4==#u]
=	 LL	 
]]4==
)	1UOOGE734ekk*zz|HXu-U[[%0	1	1	 	 	1	1sC$"A9C0$C-0C9c
d}tj|jd|5}|jtdddt|jd5}|j
d}|j|d|j
d}|j|d	|jjd	d
z}d}|j
d}|j|||j
d}	|j|	tjd
||j
d}
|j|
d|j
d}|j|d|j
t|}|j|||jtj|jj dz
|j
d}
|j|
d|j
d}|j|tjd
ttdddy#1swYxYw#t$rd}d
}YwxYw#1swYyxYw)Nrr2rrkryzLatin-1rrZz<irYsd)rr5r)r6rDopenr9r7encodeUnicodeEncodeErrorstructpackr8r rHstatst_size)rrrridBytescmByteexpectedname
expectedflags	flagsByte
mtimeBytesxflByteosByte	nameBytes
crc32Bytes
isizeBytess               r
test_metadatazTestGzip.test_metadata>s
]]4==#u]
=	 LL	 $--
&+	H%jjmGWk2ZZ]FVW-
(#}}33I>H '


1
IY
6AJZT5)ABjjmGWg.ZZ]FVW-

3|#45IY5
JJrwwt}}-559:AJZ)9:AJZT3u:)FGW+	H+	H	 	 &
(" '

(+	H+	Hs=H8AI! IE.I8I
IIIII"cNtj|_|jyr)rTESTFN_ASCIIr)rrs rtest_metadata_ascii_namez!TestGzip.test_metadata_ascii_nameqs!..
rcgd}d}|D]\}}}|j|5tj|jd|}|5|j	t
dddt
|jd5}|j||jd}|j||ddddddy#1swYgxYw#1swY xYw#1swYxYw)N))fastry)bestrr)tradeoffrrYr2r}rkry)
subTestrr5r)r6rDrr r9r7)	rcases	xflOffsetrRlevelexpectedXflByterrrs	         rtest_compresslevel_metadataz$TestGzip.test_compresslevel_metadataus

	.3	?*T5/d#
?t}}cO(LL'($--.?%JJy)#jjmG$$Wo>?	
?
?	?((??	
?
?s;%CCC:5C/CCCCCC#	ctj|jd5}|jddddtj|jd}|j		|5	ddd|jd	tj|jd5}ddzddd|jdy#1swYxYw#1swYgxYw#t$rYdwxYw#1swYBxYw#t$rYywxYw)NrAsxxxrkz4__enter__ on a closed file didn't raise an exceptionryrz1/0 didn't raise an exception)rr5r)r6rIfailrZeroDivisionErrorrJs  rtest_with_openzTestGzip.test_with_opens
]]4==$
/	1
GGFO	MM$--.			N



IILM	7t}}d3
q!


II56#		


		


 		s_C
,C".C0C"
 C=*C10C=
CCC""	C.-C.1C:6C==	D	D	ctj|jd5}|jtdzdddt|jd5}|jddddtj|jd5}|j
}|j|tdzddddy#1swYxYw#1swYixYw#1swYyxYw)NrArBrs2rkzIncorrect data in file)rr5r)r6rDrr9r7rps   rtest_zero_padded_filezTestGzip.test_zero_padded_files
]]4==$
/	 1
GGEBJ	 $--
&	"!
GGL!	"]]4==$
/	F1AQ
,DE	F	F	 	 	"	"	F	Fs#CC+CCCC'c^|jttjtyr)r
issubclassrBadGzipFileOSErrorrs rtest_gzip_BadGzipFile_exceptionz(TestGzip.test_gzip_BadGzipFile_exceptions
4#3#3W=>rcHt|jd5}|jtdzdddtj|jd5}|j
tj|jdddy#1swY]xYw#1swYyxYw)NrArBr3)	rr)r6rDrr5rlrr)rfiles  rtest_bad_gzip_filezTestGzip.test_bad_gzip_files
$--
&	#$JJurz"	#
]]4==#
.	@$d..?	@	@	#	#	@	@sB+BBB!crtdz}t}tj|d5}|j	|ddd|j}t|}tj|d5}|j
|j|dddy#1swYexYw#1swYyxYw)NrBrArrk)rDrrr5r6getvaluer7r9)runcompressedbufr=rs     rtest_non_seekable_filezTestGzip.test_non_seekable_filesrzn
]]3T]
2	"a
GGL!	"\\^
:&
]]3T]
2	5aQVVX|4	5	5		"	"	5	5sB!7!B-!B*-B6c	Ttdz}tj|jd5}|j	|dddd}tj|jd5}d|_d}|D]R}|j
|}|dk(rn:|j|jt|||t|z
}T|j|jdd|j|t|dddy#1swYxYw#1swYyxYw)	NrrAc3:K	tdddD]}|w)NrBr)r])ns rsizesz!TestGzip.test_peek.<locals>.sizess+q"b)AGsrk!rrd)
rDrr5r)r6max_read_chunkpeekr7r9r8)rr
r=rrwrss       r	test_peekzTestGzip.test_peekss{
]]4==$
/	"1
GGL!	"	
]]4==$
/
	71!AEW
 FF1I8  A3Q
 
QVVC[#.UC$56
	7
	7	"	"
	7
	7sD'B"DDD'cvtdzjdjd}|jtj|jd5}tj|d5}|j|j|ddddddy#1swYxYw#1swYyxYw)NrBasciiTrr3encoding)rDdecoderrKrr5r)r
TextIOWrapperr7r)rrr=ts    rtest_textio_readlineszTestGzip.test_textio_readliness##G,777F
]]4==#
.	7!!!!g6
7!  6
7	7	7
7
7	7	7s$B/1!B#B/#B,	(B//B8c2tj|jtjtjz}tj
|d5}tj|d5}	ddddddy#1swYxYw#1swYyxYw)NrAr2r)rHrr)O_WRONLYO_CREATfdopenrr5)rfdr=gs    rtest_fileobj_from_fdopenz!TestGzip.test_fileobj_from_fdopensyWWT]]BKK"**$<
=
YYr4
 	Aqs3
q
		

		s$B
.B0B
B
	B

Bctj|jdjt	|jd5}tj|d5}|j|jtjdddtj|d5}|j|jtjdddtj|d5}|j|jtjdddtj|d5}|j|jtjddd|jt5tj|dddddddd	D]j}t	|j|5}tj|
5}|j|jtjddddddldD]}d|vrtj|jt	|j|5}|jt5tj|
}ddd5|j|jtjddddddy#1swYGxYw#1swY
xYw#1swYxYw#1swYxYw#1swYhxYw#1swYmxYw#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swY;xYw)NrAr+br3rr2rMrz)rkr(r)rArr)rr5r)rIrr7r;READWRITErlrrr(assertWarns
FutureWarning)rr=r%r;s    rtest_fileobj_modezTestGzip.test_fileobj_modes

dmmT*002
$--
'
	31qs3
4q  3
4qs3
5q  4
5qs3
5q  4
5qs3
5q  4
5"":.
3

ac
2
3
	3 	8DdmmT*
8a]]1]-8$$QVVTYY78
8
8	8%	9Dd{  /dmmT*
9a%%m41

a
0A19$$QVVTZZ89
9
9	9
4
4
5
5
5
5
5
5
3
3
	3
	388
8
81199
9
9sL+K
L'+KL1+K'L;+K4&LLLL(+LL(M
.L5
M
+M:M

K	LK$	L'K1	,L4K>	9LL	LLL% L((L2	5L>:M
M
M

M	cN|j}	|jd}tjd5}|j
tdzdddtj|d5}|j|jtdzdddtj|d5}|j|jtdzdddy#t$r|jdYwxYw#1swYxYw#1swY|xYw#1swYyxYw)Nrz%Temporary file name needs to be ASCIIrArBrk)
r)rrskipTestrr5r6rDr7r9)rstr_filenamebytes_filenamer=s    rtest_bytes_filenamezTestGzip.test_bytes_filenames}}	C)009N]]>4
0	 A
GGEBJ	 
]]>4
0	3AQVVXurz2	3]]<
.	3!QVVXurz2	3	3"	CMMAB	C	 	 	3	3	3	3s4C#D,(D2(D#D?DDDD$ctjdtdzd}|jt	|t
jtj|}tj|}|j|jdddt
jz}|j|jjj|dy)	z-Decompressed data buffering should be limitedrg>Arr}r*ryz)Excessive amount of data was decompressedN)rrint
assertLessr8rDEFAULT_BUFFER_SIZErr5r7r9assertLessEqual_bufferrawr)rbombdecomp
max_decomps    rtest_decompress_limitedz TestGzip.test_decompress_limiteds}}USX-Q}?D	2#9#9:zz$t,Q////
V^^//446
7	9rc\ttfD]}dD]}tj|g|}|j	t|ttjtj|d5}|j	|j|dddy#1swYxYw)Nr)ry)r)rrkr)rDrrrr7typer4r5rrr9)rr:rdatacr=s     r
test_compresszTestGzip.test_compresssEN	5D.
5

d2T2  ee4]]2::e+<4]H5A$$QVVXt455
5	555s4!B""B+c	d}ttfD]}dD]}|j||5tj|g|d|i}|jt
|ttjtj|d5}|jd|j|j|ddddddy#1swYxYw#1swYxYw)NrrA)r:rrrkrry)
rDrrrrr7rBr4r5rrr9r)rrr:rrCr=s      rtest_compress_mtimezTestGzip.test_compress_mtime!sEN	9D.
9\\t$\79 MM$CCUCE$$T%[%8rzz%/@tL9PQq	((%8999
9	9
9999s$A#C
.C	;CC
CC%c(dD]}|j|5tjtd|}tjtd|}|j	t||jt|dddy#1swYxYw)N)r*rr)r~rry)rrrrDassertInassertNotIn)rr
nocompressyescompresss    rtest_compress_correct_levelz$TestGzip.test_compress_correct_level,s	5EE*
5!]]5]O
"mmE%mP

eZ0  4	
5
5	5
5
5sA%BB	cttfD]}tj}tj|d5}|j
|ddd|jtj|j|tj|}|jtj||y#1swYyxYw)NrAr)rDrrrrr5r6r7
decompressr	r)rr:rr=rCs     rtest_decompresszTestGzip.test_decompress5sEN	;D**,Cs6
!

T__S\\^<dCMM$'ET__U3T:	;

sCC	ctjt}|jttj
|ddy)NrrrDrlEOFErrorrOrcompressed_datas  r!test_decompress_truncated_trailerz*TestGzip.test_decompress_truncated_trailer?---.(DOO_Sb5IJrctjt}|jttj
|ddy)NrSrUs  rtest_decompress_missing_trailerz(TestGzip.test_decompress_missing_trailerCrXrctdz}tj|dd}tjt	j
|5}|j
t|jdddtjt	j
|5}|j|jt|||j
t|jddddtddD]X}tjt	j
|d|5}|j
t|jddddZy#1swYxYw#1swY}xYw#1swY}xYw)NrBrZr*ryrr)rDrrr5rrrlrTr9r7r8r])rr:	truncatedr=rs     rtest_read_truncatedzTestGzip.test_read_truncatedGs)RxMM$',	
]]2::i#8]
9	0Qh/	0
]]2::i#8]
9	3QQVVCI.5h2	3q"	7Arzz)BQ-'@A
7Q!!(AFFA6
7
7	7
	0	0	3	3

7
7s%!EAE%,"E1E"%E.1E:	cd}tjtj|5}|j	|jddddy#1swYyxYw)NscQExtraI-.2Mxr*sTest)rr5rrr7r9)rgzdatar=s   rtest_read_with_extrazTestGzip.test_read_with_extraUsO<]]2::f#5]
6	0!QVVXw/	0	0	0s!AAc^tj|jd5}|jtdddtj|jd5}|j
jjjdddy#1swYaxYw#1swYyxYw)NrArk)	rrr)r6rDr:r;_fpprependrJs  rtest_prepend_errorzTestGzip.test_prepend_error]s~
YYt}}d
+	q
GGEN	
YYt}}d
+	(q
IIMM%%'	(	(			(	(sB/B#B #B,cbtjdgd}t||jz}tj	tjd5}|j|j|||j|j|dddy#1swYyxYw)NQ)ryrrZrr2r)
rgr8itemsizerr5rrr7r6r)rqLENGTHr=s    rtest_issue44439zTestGzip.test_issue44439dsKK_-Q!**$
]]2::<c]
:	/aQWWQZ0QVVXv.	/	/	/s
AB%%B.ctj}d}tj|d5}|j	||j|j
}ddd|j
}|jtj|||jt5tjdddtjtj}tj}tj||j|j}|j||y#1swYxYw#1swYxYw)Nimportant message here.r2r)wbits)rrrr5r6rEr	r7rOrlrTr

decompressobj	MAX_WBITS_read_gzip_headerr9)rbmessager=partial_data	full_datarTread_messages        rtest_flush_flushes_compressorz&TestGzip.test_flush_flushes_compressorls	JJL,
]]13]
/	(1
GGG
GGI::<L	(JJL	3W=

x
(	*OOL)	*dnn_5JJ|$q!||AFFH-w/	(	(	*	*s2E2EEE&czGdd}tj}|}tj|d5}||_|j|jd|jddddtjdddg}|j|j|y#1swY:xYw)	Nc eZdZdZdZddZy)1TestGzip.test_flush_modes.<locals>.FakeCompressorcg|_yr)modesrs r__init__z:TestGzip.test_flush_modes.<locals>.FakeCompressor.__init__s	
rcyNrr)rr:s  rrz:TestGzip.test_flush_modes.<locals>.FakeCompressor.compresssrc:|jj|yr)r}rt)rr;s  rrEz7TestGzip.test_flush_modes.<locals>.FakeCompressor.flushs

!!$'rN))r!r"r#r~rrErrrFakeCompressorr{s
 

rrr2rrBr)	zlib_moder)
rrrr5rrEr
Z_SYNC_FLUSHr7r})rrrsfcr=expected_modess      rtest_flush_modeszTestGzip.test_flush_modess		
JJL


]]13]
/	#1AJ
GGI
GGBK
GGcG"		#
	
	
>2	#	#s;B11B:cptj}d}tj|d5}|j	||jt
||j	|ddd|j}|jtj||dzy#1swYBxYw)Nrnr2rr)
rrrr5r6r r8r	r7rO)rrsrtr=r:s     rtest_write_seek_writezTestGzip.test_write_seek_writes
JJL,
]]13]
/	1
GGG
FF3w< 
GGG	zz|.!<		s=B,,B5N)rs)8r!r"r#r?rKrUr`rcrhrnrqrxrrrrrrrrrrrrrrrrrrrrrrrrrrrr&r/r4r?rDrFrMrPrWr[r^rarerlrxrrrrrr0r0:s/
+'8?.&
7S#.$.85-&/	F
5
"&*!58<	11Hf?(7*
F?@57,7943
95	95;KK70(/0*36
=rr0cBeZdZdZdZdZdZdZdZdZ	dZ
d	Zy
)TestOpenctdz}tj|jd5}|j	|dddt|jd5}tj|j
}|j||dddtj|jd5}|j|j
|dddtj|jd5}|j	|dddt|jd5}tj|j
}|j||dzddd|jt5tj|jddddtj|jtj|jd5}|j	|dddt|jd5}tj|j
}|j||dddy#1swY$xYw#1swYxYw#1swYxYw#1swYtxYw#1swY*xYw#1swYxYw#1swYxYw#1swYyxYw)NrBrArkrrrrDrrr)r6rOr9r7rlrrr(rr
r=	file_datas    rtest_binary_modeszTestOpen.test_binary_modessrz
YYt}}d
+	"q
GGL!	"
$--
&	6!1IY5	6YYt}}d
+	5qQVVX|4	5YYt}}d
+	"q
GGL!	"
$--
&	:!1IYq(89	:


/	+IIdmmT*	+'
YYt}}d
+	"q
GGL!	"
$--
&	6!1IY5	6	6)	"	"	6	6	5	5	"	"	:	:	+	+	"	"	6	6_I6I+8!I8J19J!J/J+6J7I(+I58JJJJ(+J47Kctj|j}tj	|d5}|jtdzdddtj	|d5}|jtdddtj	|5}|j|jtdzdddy#1swYxYw#1swY[xYw#1swYyxYw)NrArBrrN)	rOrPr)rrr6rDr7r9)rr)r=s   rtest_pathlike_filezTestOpen.test_pathlike_files<<

.
YYx
&	 !
GGEBJ	 
YYx
&	!
GGEN	
YYx
 	3AQVVXurz2	3	3		 	 			3	3s#C-C (C)CC&)C2ctdz}tj|jd5}|j	|dddt|jd5}tj|j
}|j||dddtj|jd5}|j|j
|dddtj|jd5}|j	|dddt|jd5}tj|j
}|j||dzddd|jt5tj|jddddtj|jtj|jd5}|j	|dddt|jd5}tj|j
}|j||dddy#1swY$xYw#1swYxYw#1swYxYw#1swYtxYw#1swY*xYw#1swYxYw#1swYxYw#1swYyxYw)NrBr2rkr3rMrrrrs    rtest_implicit_binary_modesz#TestOpen.test_implicit_binary_modessrz
YYt}}c
*	"a
GGL!	"
$--
&	6!1IY5	6YYt}}c
*	5aQVVX|4	5YYt}}c
*	"a
GGL!	"
$--
&	:!1IYq(89	:


/	*IIdmmS)	*'
YYt}}c
*	"a
GGL!	"
$--
&	6!1IY5	6	6)	"	"	6	6	5	5	"	"	:	:	*	*	"	"	6	6rctjddz}|jdtj}t
j
|jdd5}|j|dddt
|jd5}t
j|jjd}|j||dddt
j
|jdd5}|j|j|dddt
j
|jdd5}|j|dddt
|jd5}t
j|jjd}|j||d	zdddy#1swY[xYw#1swYxYw#1swYxYw#1swYxYw#1swYyxYw)
NrrB
wtrrkrtatrrDrreplacerHlineseprrr)r6rOr9r7rr
uncompressed_rawr=rs     rtest_text_modeszTestOpen.test_text_modess||G,r1'//bjjA
YYt}}dWY
=	"
GGL!	"
$--
&	:!188AIY(89	:YYt}}dWY
=	5QVVX|4	5
YYt}}dWY
=	"
GGL!	"
$--
&	>!188AIY(81(<=	>	>	"	"	:	:	5	5	"	"	>	>s>GAG:!G G,5AG8GG G),G58Hctdz}|jd}tj|}tj	tj|d5}|j|j|dddtj	tj|d5}|j|j|dddtj	tj|dd5}|j|j|dddy#1swYxYw#1swYjxYw#1swYyxYw)NrBrr3rkrr)	rDrrrrrrr7r9)runcompressed_bytesuncompressed_strrr=s     rtest_fileobjzTestOpen.test_fileobjs"RZ-44W=]]#56

YYrzz*-s
3	;qQVVX'9:	;
YYrzz*-t
4	;QVVX'9:	;
YYrzz*-tgY
F	9!QVVX'78	9	9		;	;	;	;	9	9s$!D)+!D5?!E)D25D>E
cv|jt5tjdddd|jt5tj|j
dddd|jt5tj|j
dddd|jt5tj|j
ddddd|jt5tj|j
ddddd|jt5tj|j
dd	
dddy#1swYGxYw#1swYxYw#1swYxYw#1swYxYw#1swY|xYw#1swYyxYw)Ngw/^@wbtxbtrkzutf-8rignore)errorsr)newline)rlrmrrrr)rs rtest_bad_paramszTestOpen.test_bad_paramssK


y
)	IIg	


z
*	,IIdmmU+	,


z
*	,IIdmmU+	,


z
*	=IIdmmTGI<	=


z
*	<IIdmmT(I;	<


z
*	9IIdmmT4I8	9	9			,	,	,	,	=	=	<	<	9	9sGE1	!E>!F#F#F##F/1E;>FFF #F,/F8ctjddz}|jdtj}t
j
|jdd5}|j|dddt
|jd5}t
j|jjd}|j||dddt
j
|jdd5}|j|j|dddy#1swYxYw#1swYaxYw#1swYyxYw)	NrrBrrzutf-16rrkrrrs     r
test_encodingzTestOpen.test_encodings||G,r1'//bjjA
YYt}}dXY
>	"!
GGL!	"
$--
&	:!188BIY(89	:YYt}}dXY
>	5!QVVX|4	5	5	"	"	:	:	5	5s%D$AD0:!D<$D-0D9<Ec@tj|jd5}|jddddtj|jddd5}|j	|jddddy#1swYVxYw#1swYyxYw)NrAsfoobarrrr)rrfoobar)rrr)r6r7r9rJs  rtest_encoding_error_handlerz$TestOpen.test_encoding_error_handler s
YYt}}d
+	#q
GGM"	#
YYt}}dWXY
N	1QVVXx0	1	1	#	#	1	1sB!BBBcxtjddz}tj|jddd5}|j|dddtj|jddd5}|j
|j|gdddy#1swYWxYw#1swYyxYw)NrrBrr)rrr
)rDrrrr)r6r7r)rr
r=s   rtest_newlinezTestOpen.test_newline(s||G,r1
YYt}}dWdY
K	"q
GGL!	"
YYt}}dWdY
K	<qQ[[]\N;	<	<	"	"	<	<sB$9"B0$B-0B9N)r!r"r#rrrrrrrrrrrrrrs/66368> 	9
9
51<rrcfd}|S)NcFtjfd}|S)Nctj	|i|tjS#tjwxYwr)rHmakedirsrrmtree)rkwargs	directoryfunctions  rwrapperz?create_and_remove_directory.<locals>.decorator.<locals>.wrapper3s>KK	"
,00  +	  +s	5A)	functoolswraps)rrrs` r	decoratorz.create_and_remove_directory.<locals>.decorator2s%		"	,
#	,rr)rrs` rcreate_and_remove_directoryr1srceZdZdZedZeedZdZ	eeedZ
eedZeedZdZ
d	Zy
)TestCommandLinesThis is a simple test with gzipctj5}tj|d5}|j	|j
dddtjdddf}t|ttt5}|j|j\}}dddddd|jd|j|j
y#1swYxYw#1swYLxYw#1swYPxYw)NrAr-mr-dstdinstdoutstderrr)
rrrr5r6r:sys
executablerrcommunicater	r7)rbytes_io	gzip_filerprocouterrs       rtest_decompress_stdin_stdoutz,TestCommandLine.test_decompress_stdin_stdoutAs
ZZ\	AXxd;
+y		*
+>>45Dt4TB
Ad++H,=,=,?@S
A	A	
c"dii(
+
+
A
A	A	As:C:C"	7C:#C.#C:"C+	'C:.C7	3C::Dctjjtd}|j	tjj|tj|d5}|j|jdddtddd|\}}}ttjjtdd5}|j|j|jddd|jtjj||j|d	|j|d
|j|d
y#1swYxYw#1swYzxYw)Nztestgzip.gzrA)r;rrrtestgziprkrr)rHpathruTEMPDIRrexistsrrr6r:r
r7r9r)rgzipnamefprcrrgunzipeds       rtest_decompress_infile_outfilez.TestCommandLine.test_decompress_infile_outfileNs77<<712
YYxdY
+	 rHHTYY	 'fdHEC
"'',,w
3T
:	9hX]]_dii8	9	
x01Qc"c"	 	 	9	9s*E&+E2&E/2E;ctdddd\}}}|jd|j|j|d|j|dy)Nrrrzthisisatest.outs.filename doesn't end in .gz: 'thisisatest.out'ryr)rr7striprrrrs    r$test_decompress_infile_outfile_errorz4TestCommandLine.test_decompress_infile_outfile_error_sP,T64ARSCJCIIKXQc"rctjddf}t|ttt5}|j	|j
\}}ddd|j
d|j
dddy#1swY1xYw)Nrrrrrr)rrrrrr:r7)rrrrrs     rtest_compress_stdin_outfilez+TestCommandLine.test_compress_stdin_outfileesy~~tV+
4tD
>	3$''		2HC	3	
c"Ra+.		3	3sA>>Bctjjtd}|dz}|j	tjj|t
|d5}|j|jdddtdd|\}}}|jtjj||j|d|j|dy#1swYmxYw)Nr.gzrArrr)rHrrurrrrr6r:r
rr7)rlocal_testgziprrrrrs       r$test_compress_infile_outfile_defaultz4TestCommandLine.test_compress_infile_outfile_defaultosgz:!E)12
.$
'	 2HHTYY	 (fnECx01c"c"	 	 s$C,,C5cdD]L}|j|5tjjtd}|dz}|jtjj
|t|d5}|j|jdddtdd||\}}}|jtjj
||j|d|j|dtj||jtjj
|dddOy#1swYxYw#1swYgxYw)	N)--fast--best)compress_levelrrrArrr)rrHrrurrrrr6r:r
rr7remove)rrrrrrrrs        rtest_compress_infile_outfilez,TestCommandLine.test_compress_infile_outfile~s2	;N^<
;!#gz!B)E1  !9:.$/(2HHTYY'( 0fnn]Cx 89  c*  c*		(#  !9:
;
;	;((
;
;s%A$E =EB/E EE  E*	cptdddd\}}}|jd||j|dy)Nrrrrs8error: argument --best: not allowed with argument --fastrrrIr7rs    r%test_compress_fast_best_are_exclusivez5TestCommandLine.test_compress_fast_best_are_exclusives8,T68XNC

QSVWc"rcptdddd\}}}|jd||j|dy)NrrrrsAerror: argument -d/--decompress: not allowed with argument --fastrrrs    r-test_decompress_cannot_have_flags_compressionz=TestCommandLine.test_decompress_cannot_have_flags_compressions8,T68TJC

Z\_`c"rN)r!r"r#r:r	rrrrrrrrrrrrrrr>s-D
)
)!)#*# # )/*/!)#*#!);*;$#
#rr__main__)(__doc__rgrrrHrOrrunittest
subprocessrrtest.supportrrrrr	test.support.script_helperr
r
import_modulerr
rDrrabspathr.rrrTestCaser%r0rrrr!mainrrr<module>rs
		

"&"==N"}""6*"}""6*		
''//)**
+h
6&2::&(x  (l	=xl	=^E<xE<P
[#h''[#|zHMMOr