python (3.11.7)

(root)/
lib/
python3.11/
test/
__pycache__/
test_zipfile.cpython-311.opt-1.pyc

eNZ	ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlZddlZddlmZddlZddlZddlmZddlmZmZmZddlmZddlmZmZmZmZm Z m!Z!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)e$dzZ*e$d	zZ+d
Z,dZ-gdZ.d
Z/GddZ0Gdde0ej1Z2eGdde0ej1Z3eGdde0ej1Z4eGdde0ej1Z5GddZ6Gdde6ej1Z7eGdde6ej1Z8eGdde6ej1Z9eGd d!e6ej1Z:Gd"d#Z;Gd$d%e;ej1Z<eGd&d'e;ej1Z=eGd(d)e;ej1Z>eGd*d+e;ej1Z?Gd,d-ej1Z@Gd.d/ej1ZAGd0d1ej1ZBGd2d3ZCGd4d5eCej1ZDeGd6d7eCej1ZEeGd8d9eCej1ZFeGd:d;eCej1ZGGd<d=ej1ZHGd>d?ZIGd@dAeIej1ZJeGdBdCeIej1ZKeGdDdEeIej1ZLeGdFdGeIej1ZMGdHdIZNGdJdKZOGdLdMej1ZPeGdNdOej1ZQGdPdQej1ZRGdRdSej1ZSGdTdUej1ZTGdVdWej1ZUeVZWGdXdYZXdZZYd[ZZd\Z[Gd]d^ej1Z\Gd_d`ej1Z]Gdadbej1Z^e_dckrej`dSdS)dN)assert_python_ok)
TemporaryFile)randintrandom	randbytes)
script_helper)findfile
requires_zlibrequires_bz2
requires_lzmacaptured_stdoutcaptured_stderrrequires_subprocess)TESTFNunlinkrmtreetemp_dirtemp_cwdfd_count2dzipfile_datafiles))	_ziptest1
1q2w3e4r5t)zziptest2dir/_ziptest2
qawsedrftg)z!ziptest2dir/ziptest3dir/_ziptest3
azsxdcfvgb)z-ziptest2dir/ziptest3dir/ziptest4dir/_ziptest3
6y7u8i9o0pc#8KtVt5}|V||jdddn#1swxYwYt	j5}|V||jddddS#1swxYwYdSN)TESTFN2rassertFalseclosedioBytesIO)testfs  E/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/test/test_zipfile.py	get_filesr),s
MMM	#A"""###############
#"""##################s#AA	A	#BBBceZdZedZdZd"dZd"dZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#dS)#AbstractTestsWithSourceFilecdttD|_d|j|_dS)NcPg|]#}td|tfzd$S)z'Zipfile test line %d. random float: %f
ascii)bytesr.0is  r(
<listcomp>z:AbstractTestsWithSourceFile.setUpClass.<locals>.<listcomp>8sH888H &((m,-466888r4)rangeFIXEDTEST_SIZEline_genjoindataclss r(
setUpClassz&AbstractTestsWithSourceFile.setUpClass6sE88!&~!6!688888CL))r4cttd5}||jddddS#1swxYwYdSNwbopenrwriter9selffps  r(setUpz!AbstractTestsWithSourceFile.setUp=
&$

	 2HHTY	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 >AANc||d}tj|dfi|5}|td|tt|d|j|dd5}|jD]}||	dddn#1swxYwYddddS#1swxYwYdS)N)compression
compresslevelwanother.namestrfilewritten-open-wmode)zipfileZipFilerBrwritestrr9rAr7)rDr'rJrKkwargszipfplines       r(make_test_archivez-AbstractTestsWithSourceFile.make_test_archiveBsX!,}MM
_Q
.
.v
.
.	"%KK///KK'''NN9di000,377
"1 M""DGGDMMMM"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"		"	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"s6A.C B4(C4B8	8C;B8	<CCCc	~||||tj|d|5}||t
|j||d|j||d|jtj}|	||
}|}|t|d|
d|d|
d|d|
d	|d|d
\}}	}
}||d|t!j|	d|t!j|
d||t%t|j|}|t|d
|
t
||
d||
d||
d||}
d|
D}|t|d
|
t
||
d||
d||
d||
D]/}||jt|j0t
dddfD]_}||}||j|||jt|j`|ddddS#1swxYwYdS)NrrMrN)file	File NamerModifiedSize%Y-%m-%d%H:%M:%SrOcg|]	}|j
Sfilenamer0s  r(r3z8AbstractTestsWithSourceFile.zip_test.<locals>.<listcomp>q///AQZ///r4)rXrRrSassertEqualreadrr9r$StringIOprintdirgetvalue
splitlineslenassertInsplit
assertTruetimestrptimestrnamelistinfolist	file_sizegetinforgtestzip)rDr'rJrKrVrE	directorylinesfndatetime_sizenamesinfosr2nminfos                 r(zip_testz$AbstractTestsWithSourceFile.zip_testMsq+}===_Q[
1
10	UUZZ//;;;UZZ77CCCUZZ	22DI>>>BNNN###

I((**ESZZ+++MM+uQx000MM*eAh///MM&%(+++$)!HNN$4$4!BeTR000OODM$
;;<<<OODM%<<===T3s49~~#6#6777NN$$ESZZ+++MM&%(((MM.%000MM)U+++MM*E222NN$$E/////ESZZ+++MM&%(((MM.%000MM)U+++MM*E222
>
>  c$)nn====~y:JK
A
A}}R((  333  TY@@@@
MMOOOa0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	sO7P22P69P6c`t|D]}|||jdSr r)rrJrDr's  r(
test_basicz&AbstractTestsWithSourceFile.test_basic;4	/	/AMM!T-....	/	/r4c|||tj|d|5}g}|t5}	|d}|sn||.	dddn#1swxYwYg}|d5}	|d}|sn||.	dddn#1swxYwY|d||j	|d||j	ddddS#1swxYwYdSNrZTrMr4)
rXrRrSrArrjappendrir8r9)	rDr'rJrVzipdata1zipopen1	read_datazipdata2zipopen2s	         r(
zip_open_testz)AbstractTestsWithSourceFile.zip_open_tests'q+..._Q[
1
1	<UHF##
/x/ (

c 2 2I$OOI...	/	
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/HN++
/x/ (

c 2 2I$OOI...	/	
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
SXXh//;;;SXXh//;;;%	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<sZE
0B;EB	EB	E)0C&E&C*	*E-C*	.AEE!Ec`t|D]}|||jdSr r)rrJrs  r(	test_openz%AbstractTestsWithSourceFile.test_open=4	4	4Aq$"23333	4	4r4ctjt}|||jtj|d|j5}||jtddddS#1swxYwYdSNrZ)
pathlibPathr!rrJrRrSassertIsInstancergru)rDpathrVs   r(test_open_with_pathlikez3AbstractTestsWithSourceFile.test_open_with_pathlikes|G$$4!1222
_T3(8
9
9	7U!!%.#666	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7s!A>>BBc|||tj|d|5}g}|t5}	|t
dd}|sn||<	dddn#1swxYwY|d	||j
ddddS#1swxYwYdSNrZTr`r4)rXrRrSrArrjrrrir8r9)rDr'rJrVrrrs       r(zip_random_open_testz0AbstractTestsWithSourceFile.zip_random_open_testseq+..._Q[
1
1		<UHF##
/x/ (

ga.>.> ? ?I$OOI...	/	
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
SXXh//;;;		<		<		<		<		<		<		<		<		<		<		<		<		<		<		<		<		<		<s5C
>B	CB	CB	1CC"Cc`t|D]}|||jdSr r)rrJrs  r(test_random_openz,AbstractTestsWithSourceFile.test_random_open=4	;	;A%%a)9::::	;	;r4c|||tj|d5}|t5}g}	|d}|sn||.	dddn#1swxYwYdddn#1swxYwY|d||j	dS)NrZTr4)
rXrRrSrArread1rrir8r9rDr'rJrVzipopenzipdatars       r(zip_read1_testz*AbstractTestsWithSourceFile.zip_read1_testsQq+..._Q
$
$	*
ZZ

	*#*G
*#MM"--	 y)))	
*
	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	
'**DI66666s5B2B:BB
	
B
B
	BB!$B!c`t|D]}|||jdSr )r)rrJrs  r(
test_read1z&AbstractTestsWithSourceFile.test_read1s=4	5	5A4#34444	5	5r4c|||tj|d5}|t5}g}	|d}|t|d|sn||Q	dddn#1swxYwYdddn#1swxYwY|	d
||jdS)NrZT
r4)rXrRrSrArrassertLessEqualrorrir8r9rs       r(zip_read1_10_testz-AbstractTestsWithSourceFile.zip_read1_10_testsmq+..._Q
$
$	*
ZZ

	*#*G
*#MM"--	$$S^^R888 y)))
*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*	
'**DI66666s6CAB)C)B-	-C0B-	1CCCc`t|D]}|||jdSr )r)rrJrs  r(
test_read1_10z)AbstractTestsWithSourceFile.test_read1_10=4	8	8A""1d&67777	8	8r4c|||tj|d5}|t5}d}	|}|sn#||z
}|d}|sn||z
}:dddn#1swxYwYdddn#1swxYwY|||jdS)NrZr4Td)	rXrRrSrArreadlinerjrir9)rDr'rJrVrr9rjs       r(zip_readline_read_testz2AbstractTestsWithSourceFile.zip_readline_read_tests\q+..._Q
$
$	
ZZ

	#*D	
''))||C((	
																															
ty)))))s5B(>BB(B	B(B	B((B,/B,c`t|D]}|||jdSr )r)rrJrs  r(test_readline_readz.AbstractTestsWithSourceFile.test_readline_reads=4	=	=A''4+;<<<<	=	=r4c\|||tj|d5}|t5}|jD],}|}|||-	dddn#1swxYwYddddS#1swxYwYdSr)rXrRrSrArr7rri)rDr'rJrVrrWlinedatas       r(zip_readline_testz-AbstractTestsWithSourceFile.zip_readline_tests1q+..._Q
$
$	5F##
5w M55D&//11H$$Xt44445
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5s5B!5B	=B!	B
	
B!B
	B!!B%(B%c`t|D]}|||jdSr )r)rrJrs  r(
test_readlinez)AbstractTestsWithSourceFile.test_readlinerr4c~|||tj|d5}|t5}|}dddn#1swxYwYt
|j|D]\}}|||	ddddS#1swxYwYdSr)	rXrRrSrAr	readlineszipr7ri)rDr'rJrVrziplinesrWziplines        r(zip_readlines_testz.AbstractTestsWithSourceFile.zip_readlines_test
s?q+..._Q
$
$	0F##
/w",,..
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/!$T]H!=!=
0
0
g  $////
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0s5B2A(B2(A,	,B2/A,	04B22B69B6c`t|D]}|||jdSr )r)rrJrs  r(test_readlinesz*AbstractTestsWithSourceFile.test_readlines=4	9	9A##At'78888	9	9r4cV|||tj|d5}|t5}t|j|D]\}}|||	dddn#1swxYwYddddS#1swxYwYdSr)rXrRrSrArrr7ri)rDr'rJrVrrWrs       r(zip_iterlines_testz.AbstractTestsWithSourceFile.zip_iterlines_tests.q+..._Q
$
$	4F##
4w%(%@%@44MD'$$Wd33334
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4	4	4	4	4	4	4	4	4	4	4	4	4	4	4	4	4	4	4s5B2B:BB
	
B
B
	BB"%B"c`t|D]}|||jdSr )r)rrJrs  r(test_iterlinesz*AbstractTestsWithSourceFile.test_iterlines!rr4ctjtd|j5}|dddddn#1swxYwYtjtd|j5}|d5}||dd||dddddn#1swxYwYddddS#1swxYwYdS)	z>Check for cases where compressed data is larger than original.rLrN12NrZr`12)rRrSr!rJrTrArirj)rDrVopenobjs   r(test_low_compressionz0AbstractTestsWithSourceFile.test_low_compression%s_Wc4+;
<
<	,NN9d+++	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,_Wc4+;
<
<	8I&&
8'  a$777  a$777
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8sHAAA/C<AC$C<$C(	(C<+C(	,C<<DDctjtd}|dd|j|d}||j|jdS)NrLb.txthello world
compress_type)rRrSr!rTrJryrir)rDrVrs   r(test_writestr_compressionz5AbstractTestsWithSourceFile.test_writestr_compression1sa--
w
T=MNNN}}W%%+T-=>>>>>r4ctjtdd}|dd|j|dd|jd	|d}||j|j||jd|d}||j|j||jddS)
NrLr`rKa.txtrrr)rrK)	rRrSr!rTrJryrir_compresslevel)rDrVa_infob_infos    r(test_writestr_compresslevelz7AbstractTestsWithSourceFile.test_writestr_compresslevel7sA>>>
w
T=MNNN
w
T=M%&		(	(	(w''-t/?@@@.222w''-t/?@@@.22222r4cdD]}|dz}t|}tjtjd|j5}|d||dd5}||}|	t||dddn#1swxYwYdddn#1swxYwYdS)N)r`iiii@r`rLfoorZ)rrRrSr$r%rJrTrArjriro)rD	test_sizerxjunkzipfrEbufs       r(test_read_return_sizez1AbstractTestsWithSourceFile.test_read_return_sizeGsJ6	:	:I!A
IY''DsD4DEE
:

eT***YYuc**:b''),,C$$SXXy999:::::::::::::::
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:	:	:s6-C29B7+C7B;;C>B;?CC	C	c<tj}tj|d5}|d|j|j|}dddn#1swxYwY|}tj|}tj|5}|	d5}|
|dz
|t5|
dddn#1swxYwYdddn#1swxYwYdddn#1swxYwYtj|}tj|5}|	d5}|
|dz
|t5|
dr	|
ddddn#1swxYwYdddn#1swxYwYdddn#1swxYwYtj|}tj|5}|	d5}|
|dz
|t5|dr	|ddddn#1swxYwYdddn#1swxYwYddddS#1swxYwYdS)NrLrPrNrr)r$r%rRrSrTr9rJtellrmrAtruncateassertRaisesEOFErrorrjr)rDrEr
end_offsetzipfiledatars      r(test_truncated_zipfilez2AbstractTestsWithSourceFile.test_truncated_zipfileSs#
Z\\
_Rc
*
*
*	#dMM)TYd>NMOOOJ	#	#	#	#	#	#	#	#	#	#	#	#	#	#	#kkmm
Z
$
$
_R
 
 	#D9%%
#JO,,,&&x00##LLNNN###############
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#	#	#	#	#	#	#	#	#	#	#	#	#	#	#	#Z
$
$
_R
 
 	D9%%
JO,,,&&x00!,,s++",,s++














															Z
$
$
_R
 
 	D9%%
JO,,,&&x00!--,,"--,,














																		s7A--A14A14E
3D5=DD5D""D5%D"&D5)E5D9	9E<D9	=EEE?H.3H,H4HHHHHH.H	H.H	H..H25H2!L73K9*,K"K9"K&&K9)K&*K9-L9K=	=LK=	LLLcTd}t|D]}tj|d|j5}|t
|t
|}|d|dddn#1swxYwYtj|d5}t
|}t|tr|d|z|n|d|z||d|t
|
|}|d|z||d||d	||jtjkr,|d
||d|||5}t
|}|d|z||d||jtjkr|d
|dddn#1swxYwY|d
t
|dddn#1swxYwY|d
t
|dS)Nz	file.namerLzmode='w'rZzfilename=%rzfile=%rzmode='r'z	filemode=z
file_size=zcompress_type=zcompress_size=zname=%rz[closed])
r)rRrSrJrBrreprrp
isinstancerury
ZIP_STOREDrA)rDfnamer'rVrZrs      r(	test_reprz%AbstractTestsWithSourceFile.test_reprqs4	3	3AC)9::
-eFE***KK

j!,,,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
C((
9EKKa%%4MM-!"3Q7777MM)a-333

j!,,,u--..

me3Q777

k1---

lA...#w'999MM"2A666MM"2A666ZZ&&;'W

AMM)e"3Q777MM*a000'7+===

&6:::;;;;;;;;;;;;;;;

j$w--888)
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9*
MM*d5kk22227	3	3sJAA==B	B	D+I8A*H>2I8>II8I&I88I<	?I<	cdt|D]}|||jd dS)N	rrrs  r(test_compresslevel_basicz4AbstractTestsWithSourceFile.test_compresslevel_basicsC4	@	@AMM!T-QM????	@	@r4ctjtdd5}|td|tdd|d}|d}||jd||jdddddS#1swxYwYdS)zTCheck that files within a Zip archive can have different
        compression levels.rLr`r
compress_1
compress_9rN)rRrSr!rBrryrir)rDrVone_info	nine_infos    r(test_per_file_compresslevelz7AbstractTestsWithSourceFile.test_per_file_compresslevels_Wc
;
;
;	:uKK---KKAK>>>}}\22H

l33IX4a888Y5q999
	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:sBCC
CcGfddtj}d	|}dtj|d|j5}|dd5}|ddddn#1swxYwYd	|dd5}|d	dddn#1swxYwY	ddddn#t$rd
z
YnwxYw	dn#dwxYw	dddn#1swxYwYtjtj|5}|	|
dg|	|dddddn#1swxYwYtjtj|5}|	|
ddg|	|dd|	|dd	ddddS#1swxYwYdS)Nc$eZdZfdZxZS)CAbstractTestsWithSourceFile.test_writing_errors.<locals>.BrokenFilecrkrtdz
t|dSNr`)OSErrorsuperrB)rDr9	__class__countstops  r(rBzIAbstractTestsWithSourceFile.test_writing_errors.<locals>.BrokenFile.writes<$}}%
QJE

d#####r4)__name__
__module____qualname__rB
__classcell__)r
rrs@r(
BrokenFilersC
$
$
$
$
$
$
$
$
$
$
$r4rrTrLfile1sdata1file2sdata2r`)r$r%rRrSrJrArBrrmrirvrj)rDrtestfilerVr'rrs     @@r(test_writing_errorsz/AbstractTestsWithSourceFile.test_writing_errorss	$	$	$	$	$	$	$	$	$	$	$	@!z||HE30@AA
!UZZ--&GGH%%%&&&&&&&&&&&&&&&!GS11*Q)))***************
 E
!
!
!
!
!
!
!AIDDD!EEDELLLLE
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!H,=,=,?,?!@!@AA
@U  !1!1G9===  G!4!4h???
@
@
@
@
@
@
@
@
@
@
@
@
@
@
@!	@(_RZ(9(9(;(;<<
=
=	<U^^--/ABBBUZZ00(;;;UZZ00(;;;	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<sDB5DB	DB		DC!%C;C!C	C!C	C!D!C30C:2C33C:7D:C>>DDDAF00F47F45A=I??JJcVttttdSr rrr!rDs r(tearDownz$AbstractTestsWithSourceFile.tearDownvwr4r )$r
rrclassmethodr<rFrXrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrer4r(r+r+5s
**[*   
	"	"	"	"4444l///<<<0444777
<
<
<;;;
7
7
7555777 888***(===
555888000999444999
8
8
8???333 
:
:
:<333>@@@	:	:	:"<"<"<Jr4r+cteZdZejZdZdZdZdZ	dZ
dZdZdZ
d	Zd
ZdZdZd
ZdZdZdS)StoredTestsWithSourceFileNcN|||tj|d5}|d}||jd|d}||jdddddS#1swxYwYdS)NrZrNrO)rXrRrSryri
external_attr)rDr'rJrVzinfozinfo2s      r(zip_test_writestr_permissionsz7StoredTestsWithSourceFile.zip_test_writestr_permissionss
	
q+...
_Q
$
$	@MM),,EU0+>>>]]#344FV1;???	@	@	@	@	@	@	@	@	@	@	@	@	@	@	@	@	@	@sA!BB!Bcjt|D]"}||tj#dSr )r)r#rRrrs  r(test_writestr_permissionsz3StoredTestsWithSourceFile.test_writestr_permissionssA4	F	FA..q'2DEEEE	F	Fr4ctjtdtj5}|t
ddddn#1swxYwYtjtdtj5}||dgddddS#1swxYwYdS)NrL	/absoluterZabsoluterRrSr!rrBrrirvrDrVs  r(test_absolute_arcnamesz0StoredTestsWithSourceFile.test_absolute_arcnamess
_Wc7+=
>
>	-%KK,,,	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-_Wc7+=
>
>	=%U^^--
|<<<	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=s#AAA>*B55B9<B9ctjtdtj5}|t
t
dddn#1swxYwYtjtdtj5}|d|j||	t
dgddddS#1swxYwYdS)z&Test appending to an existing zipfile.rLNarN)
rRrSr!rrBrrTr9rirvr*s  r(test_append_to_zip_filez1StoredTestsWithSourceFile.test_append_to_zip_filesG
_Wc7+=
>
>	(%KK'''	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(_Wc7+=
>
>	D%NN9di000U^^--	/BCCC	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	Ds$!AAAACC"Ccdd}ttd5}||dddn#1swxYwYtjtdtj5}|ttdddn#1swxYwYttd5}|t|tj|d5}|	|
tg|	|t|jdddn#1swxYwYdddn#1swxYwYttd5}|	|t|||}dddn#1swxYwYtj|5}tj|5}|	|
tg|	|t|jdddn#1swxYwYddddS#1swxYwYdS)z9Test appending to an existing file that is not a zipfile.I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!I am not a ZipFile!r?Nr-rbrZ)rAr!rBrRrSrrseekrorirvrjr9r$r%)rDr9r'rVrbios      r(test_append_to_non_zip_filez5StoredTestsWithSourceFile.test_append_to_non_zip_files)
'4
 
 	A
GGDMMM															_Wc7+=
>
>	(%KK'''	(	(	(	(	(	(	(	(	(	(	(	(	(	(	('4
 
 	@A
FF3t99C((
@E  !1!1F8<<<  F!3!3TY???
@
@
@
@
@
@
@
@
@
@
@
@
@
@
@	@	@	@	@	@	@	@	@	@	@	@	@	@	@	@
'4
 
 	#AQVVCII..555&&((K	#	#	#	#	#	#	#	#	#	#	#	#	#	#	#Z
$
$	<W_S-A-A	<UU^^--x888UZZ//;;;	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<s:>>*!BBB78E4/A"EE4E!	!E4$E!	%E44E8;E8AG++G/2G/
J%A"J
J%
J	J%J	J%%J),J)ctj5}tj|dtj5}|ttdddn#1swxYwY|}dddn#1swxYwYd}ttd5}||||dddn#1swxYwYtjt5}|
|tg|
|t|j
ddddS#1swxYwYdS)NrLr0r?)r$r%rRrSrrBrrmrAr!rirvrjr9rDr3rVrr9r's      r(test_read_concatenated_zip_filez9StoredTestsWithSourceFile.test_read_concatenated_zip_files-
Z\\	)Sc7+=>>
,%FF+++
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,,,..K	)	)	)	)	)	)	)	)	)	)	)	)	)	)	))
'4
 
 	!A
GGDMMM
GGK   	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!_W
%
%	<U^^--x888UZZ//;;;	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<sY!B
!A"B
"A&	&B
)A&	*B

BB/+C&&C*-C*
A"E99E=E=ctj5}tj|dtj5}|ttdddn#1swxYwY|}dddn#1swxYwYddz}ttd5}||||dddn#1swxYwYtjtd5}|
|tg|d|j
dddn#1swxYwYttd5}|
|t|||}dddn#1swxYwYtj|5}tj|5}|
|tdg|
|t|j
|
|d|j
dddn#1swxYwYddddS#1swxYwYdS)NrLsI am not a ZipFile!i@Br?r-rNr1)r$r%rRrSrrBrrmrAr!rirvrTr9rjror6s      r($test_append_to_concatenated_zip_filez>StoredTestsWithSourceFile.test_append_to_concatenated_zip_files
Z\\	)Sc7+=>>
,%FF+++
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,,,..K	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)&g-
'4
 
 	!A
GGDMMM
GGK   	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!_Wc
*
*	1eU^^--x888NN9di000	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1'4
 
 	#AQVVCII..555&&((K	#	#	#	#	#	#	#	#	#	#	#	#	#	#	#Z
$
$	?W_S-A-A	?UU^^--	/BCCCUZZ//;;;UZZ	22DI>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?s!B
!A"B
"A&	&B
)A&	*B

BB2+C))C-0C-A
E$$E(+E(AGG"G:KBJ, K,J0	0K3J0	4KKKctjtdtj5}|t
t
dddn#1swxYwYt
tdd5}|ddddn#1swxYwYtjtd5}||tjddddS#1swxYwYdS)NrLr-utf-8encodingz
rZ)rRrSr!rrBrrArrDrVr's   r(test_ignores_newline_at_endz5StoredTestsWithSourceFile.test_ignores_newline_at_end*s
_Wc7+=
>
>	(%KK'''	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(
'3
1
1
1	%Q
GGO$$$	%	%	%	%	%	%	%	%	%	%	%	%	%	%	%
_Wc
*
*	:e!!%999	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:s5!AAA5BBB<!C**C.1C.c2tjtdtj5}d|_|ttdddn#1swxYwYttdd5}|ddddn#1swxYwYtjtd5}||tj|	|jdddddS#1swxYwYdS)NrLthis is a commentr-r;r<zabcdef
rZ)
rRrSr!rcommentrBrrArrir>s   r()test_ignores_stuff_appended_past_commentszCStoredTestsWithSourceFile.test_ignores_stuff_appended_past_comments2s
_Wc7+=
>
>	(%0EMKK'''	(	(	(	(	(	(	(	(	(	(	(	(	(	(	('3
1
1
1	"Q
GGL!!!	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"
_Wc
*
*	Be!!%999U],@AAA	B	B	B	B	B	B	B	B	B	B	B	B	B	B	B	B	B	Bs5(AA!A<BB"%B"<DDDcztjtd5}|tttd5}||t|dddn#1swxYwYddddS#1swxYwYdS)z`Check that calling ZipFile.write without arcname specified
        produces the expected result.rLr1N)rRrSr!rBrrArirjr>s   r(test_write_default_namez1StoredTestsWithSourceFile.test_write_default_name<s_Wc
*
*	?eKKfd##
?q  F!3!3QVVXX>>>
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?s60B0ABB0B	B0B	 B00B47B4cd}tjtd5}||ddddn#1swxYwYtjtd5}||5}||t|j|t|j	d|t|j
|t|j|t|jdddn#1swxYwYddddS#1swxYwYdS)Nsomefile.txtrLrPbogusrZr)
rRrSr!rTrAcloser
ValueErrorrjr2rreadableseekable)rDrrVfids    r(test_io_on_closed_zipextfilez6StoredTestsWithSourceFile.test_io_on_closed_zipextfileDs
_W3
/
/
/	+5NN5'***	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+_W3
/
/
/	<5E""
<c		!!*ch777!!*ch:::!!*ch777!!*cl;;;!!*cl;;;

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<sHAAA'E=B6D?3E?E	EE	EEEcNtjtd5}|dddddn#1swxYwYtjtd5}|t
|jtdddn#1swxYwYtjtd5}|t
5|tddddn#1swxYwYddddS#1swxYwYdS)z[Check that trying to call write() on a readonly ZipFile object
        raises a ValueError.rLrPrGrHNrZ)	rRrSr!rTrrJrBrrAr*s  r(test_write_to_readonlyz0StoredTestsWithSourceFile.test_write_to_readonlyRs_W3
/
/
/	45NN>7333	4	4	4	4	4	4	4	4	4	4	4	4	4	4	4_W3
/
/
/	?5j%+v>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?_W3
/
/
/	-5"":..
-
-

6
,,,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-sW?AA%'BBB>DD6DD	D	D	
DD!Dctjtdtjt
d5}|t|jtdddn#1swxYwYtjt
dd5}|t|	t}|
|jdddddS#1swxYwYdS)N)rrrLFstrict_timestampsir`r`rrr)osutimerrRrSr!rrJrBryri	date_time)rDrVr!s   r(test_add_file_before_1980z3StoredTestsWithSourceFile.test_add_file_before_1980_s[
   
_Wc
*
*	?ej%+v>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?_WcU
C
C
C	EuKKMM&))EU_.CDDD	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	Es$'A((A,/A,AC,,C03C0cHd}	tj|n)#t$r|d|dYnwxYw	t	jt||fn%#t$r|dYnwxYwt	jtj}|dkr|d|tj
td5}|tj|jtdddn#1swxYwYtj
tdd	5}|t|t}||jd
ddddS#1swxYwYdS)Nl&
ztime.localtime(z) raises OverflowErrorz/Host fs cannot set timestamp to required value.lb fz,Linux VFS/XFS kernel bug detected: mtime_ns=rLFrR)i;;r])rs	localtime
OverflowErrorskipTestrUrVrstatst_mtime_nsrRrSr!rstructerrorrBryrirW)rDtsmtime_nsrVr!s     r(test_add_file_after_2107z2StoredTestsWithSourceFile.test_add_file_after_2107jsN
	HN2	H	H	HMMFBFFFGGGGG	H	MHVb"X&&&&	M	M	MMMKLLLLL	M76??.*++
MMKKKLLL
_Wc
*
*	AeflEK@@@	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A_WcU
C
C
C	JuKKMM&))EU_.HIII	J	J	J	J	J	J	J	J	J	J	J	J	J	J	J	J	J	JsC#??A  BB,DDD:AFFF)r
rrrRrrJrr#r%r+r.r4r7r9r?rCrErNrPrXrgrer4r(rrs$K@@@FFF===DDD<<<.<<<???,:::BBB???<<<---	E	E	EJJJJJr4rc"eZdZejZdZdS)DeflateTestsWithSourceFilectjtd5}|tdtj|tdtj|d}|d}||j	tj||j	tjddddS#1swxYwYdS)zUCheck that files within a Zip archive can have different
        compression options.rLstoreme	deflatemeN)
rRrSr!rBrrZIP_DEFLATEDryrir)rDrVsinfodinfos    r(test_per_file_compressionz4DeflateTestsWithSourceFile.test_per_file_compressions_Wc
*
*	HeKK	7+=>>>KKW-ABBBMM),,EMM+..EU0'2DEEEU0'2FGGG
	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	HsCC))C-0C-N)r
rrrRrmrJrprer4r(riris2&K	H	H	H	H	Hr4riceZdZejZdS)Bzip2TestsWithSourceFileNr
rrrR	ZIP_BZIP2rJrer4r(rrrr#KKKr4rrceZdZejZdS)LzmaTestsWithSourceFileNr
rrrRZIP_LZMArJrer4r(rwrw"KKKr4rwcHeZdZedZdZdZdZdZdZ	dZ
dS)	AbstractTestZip64InSmallFilescxdtdtD}d||_dS)Nc3<K|]}td|zdVdS)zTest of zipfile line %d.r.N)r/r0s  r(	<genexpr>z;AbstractTestZip64InSmallFiles.setUpClass.<locals>.<genexpr>sF774q8'BB777777r4r
)r5r6r8r9)r;r7s  r(r<z(AbstractTestZip64InSmallFiles.setUpClasssA77"1n55777::h''r4c
tj|_tj|_dt_dt_ttd5}||jddddS#1swxYwYdS)Nrrr?)	rRZIP64_LIMIT_limitZIP_FILECOUNT_LIMIT_filecount_limitrArrBr9rCs  r(rFz#AbstractTestZip64InSmallFiles.setUps) ' ;"&'#&$

	 2HHTY	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 sA88A<?A<c		tj|d|d5}|td|tt|d|jdddn#1swxYwYtj|d|5}||t|j||d|j||d|jtj	}|
||}|}|t|d|d|d	|d
|d	|d|d	|d\}}}	}
||d|t#j|d
|t#j|	d||
t't|j|}|t|d|t||d||d||}d|D}|t|d|t||d||d||D]/}
||
jt|j0tddfD]_}||}||j|||jt|j`|ddddS#1swxYwYdS)NrLT
allowZip64rMrNrZrcr]rr^r_r`rarbcg|]	}|j
Srerfr0s  r(r3z:AbstractTestZip64InSmallFiles.zip_test.<locals>.<listcomp>rhr4)rRrSrBrrTr9rirjr$rkrlrmrnrorprqrrrsrtrurvrwrxryrgrz)rDr'rJrVrEr{r|r}r~rrrrr2rrs                r(rz&AbstractTestZip64InSmallFiles.zip_testsP
_Q[T
B
B
B	1eKK///KK'''NN9di000	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1_Q[
1
1/	UUZZ//;;;UZZ77CCCUZZ	22DI>>>BNN2

I((**ESZZ+++MM+uQx000MM*eAh///MM&%(+++$)!HNN$4$4!BeTR000OODM$
;;<<<OODM%<<===T3s49~~#6#6777NN$$ESZZ+++MM&%(((MM.%000MM)U+++NN$$E/////ESZZ+++MM&%(((MM.%000MM)U+++
>
>  c$)nn====~y9
A
A}}R((  333  TY@@@@
MMOOO_/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	s%AA<<BBO	Q33Q7:Q7c`t|D]}|||jdSr rrs  r(rz(AbstractTestZip64InSmallFiles.test_basicrr4ctjtd|jd}d|_d}t|D]$}|d|zd|dzd	zz%|t|	||
tjtd
|j}|t|	|t|D]L}|d|zd}||d|dzd	zzM|
dS)NrLTrrfoo%08d%dr9rZr.)
rRrSrrJdebugr5rTrirorvrIrjdecode)rDrnumfilesr2zipf2contents      r(test_too_many_filesz1AbstractTestZip64InSmallFiles.test_too_many_filessOvsD,<*.000
x	=	=AMM)a-A);<<<<T]]__--x888

T-=>>U^^--..999x	:	:AjjQ//66w??GWdadRi&89999





r4ctjtd|jd}d|_d}t|D]$}|d|zd|dzd	zz%|t|	||
tj5|d|zd
dddn#1swxYwY|t|	||tjtd|jd}d|_|t|	||
tj5|d|zd
dddn#1swxYwY|t|	||tjtd|jd}d|_|t|	|d
}t||D]$}|d|zd|dzd	zz%|t|	||tjtd|j}|t|	|t|D]L}|
d|zd}||d|dzd	zzM|dS)NrLFrrrrrrrr4r-TrrZr.)rRrSrrJrr5rTrirorvrLargeZipFilerIrjr)rDrrr2	numfiles2rrs       r(test_too_many_files_appendz8AbstractTestZip64InSmallFiles.test_too_many_files_append
svsD,<*/111
x	=	=AMM)a-A);<<<<T]]__--x888


w3
4
4	5	5MM)h.444	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5T]]__--x888

vsD,<*/111
T]]__--x888


w3
4
4	5	5MM)h.444	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5T]]__--x888

vsD,<*.000
T]]__--x888	x++	=	=AMM)a-A);<<<<T]]__--y999

T-=>>U^^--..	:::y!!	:	:AjjQ//66w??GWdadRi&89999





s$4CC!C+GGGc|jt_|jt_ttttdSr )rrRrrrrrr!rs r(rz&AbstractTestZip64InSmallFiles.tearDown1s1"k&*&;#vwr4N)r
rrrr<rFrrrrrrer4r(r|r|s(([(
   777r///&%%%Nr4r|cleZdZejZdZdZdZdZ	dZ
			ddZdZd	Z
d
ZdZdZd
ZdS)StoredTestZip64InSmallFilesctj|d|d5}|tj|jt
dddddS#1swxYwYdSNrLFrrM)rRrSrrrBrrDr'rJrVs    r(large_file_exception_testz5StoredTestZip64InSmallFiles.large_file_exception_test<s
_Q[U
C
C
C	Cug2#k6>
C
C
C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C-AAActj|d|d5}|tj|jd|jddddS#1swxYwYdSr)rRrSrrrTr9rs    r(large_file_exception_test2z6StoredTestZip64InSmallFiles.large_file_exception_test2As
_Q[U
C
C
C	Iug2#nndi
I
I
I	I	I	I	I	I	I	I	I	I	I	I	I	I	I	I	I	I	Irct|D]B}||tj||tjCdSr )r)rrRrrrs  r(test_large_file_exceptionz5StoredTestZip64InSmallFiles.test_large_file_exceptionFsZ4	C	CA**1g.@AAA++Aw/ABBBB	C	Cr4ctjtdtjd5}|t
ddddn#1swxYwYtjtdtj5}||dgddddS#1swxYwYdS)NrLTrr'rZr(r)r*s  r(r+z2StoredTestZip64InSmallFiles.test_absolute_arcnamesKs(
_Wc7+=(,...	-16KK,,,	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-_Wc7+=
>
>	=%U^^--
|<<<	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=s#AAA*B77B;>B;ctjtdd5}|d|jdddn#1swxYwYtjtdd5}|d}|j}dddn#1swxYwYtjtdd5}|d|jdddn#1swxYwYtjtdd5}|d}||j|ddddS#1swxYwYdS)NrLTrrNrZr-strfile2)rRrSr!rTr9ryextrari)rDrVr!rs    r(test_appendz'StoredTestZip64InSmallFiles.test_appendSs&_Wcd
;
;
;	1uNN9di000	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1
_Wcd
;
;
;	 uMM),,EKE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 _Wcd
;
;
;	2uNN:ty111	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2
_Wcd
;
;
;	1uMM),,EU[%000	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1sGAA	A	,BBB<C$$C(+C(1E		E
E
Fcd}d}g}	g}
|}|r.d}|r*|	||
|tjd|}|}|r.d}|r*|	||
|tjd|}|}
|rd}
|r|
|tjd|
}
tjddt|	zzddt|	zg|	R}tjddt|
zzddt|
zg|
R}tjdd	dt|
zz}tjdd
dt|	zz}tjdddt|	zz}tjdddt|
zz}d
}d}tjdt|}d|z|z|z|z|z|z|zdz|z|z|z|zdz|
z|z|zdzdzdz|z|zdzdzdzdz}|S)zGenerate bytes sequence for a zip with (incomplete) zip64 data.

        The actual values (not the zip 64 0xffffffff values) stored in the file
        are:
        file_size: 8
        compress_size: 8
        header_offset: 0
        r<L<HHQr`z<Q:2z<Hrcstest.txttest1234sPK!%sPK--!%s
sPK,--ss
sPKlssPK:2s)rrcpackro)rDfile_size_64_setfile_size_extracompress_size_64_setcompress_size_extraheader_offset_64_setheader_offset_extraactual_sizeactual_header_offsetlocal_zip64_fieldscentral_zip64_fieldsrx
compress_size
header_offsetlocal_extra
central_extracentral_dir_sizeoffset_to_central_dirlocal_extra_lengthcentral_extra_lengthrgrfilename_lengthzip64_contentss                        r(make_zip64_filez+StoredTestZip64InSmallFiles.make_zip64_fileasb !		9"I
9"))+666$++K888Ki00	#
	9&M"
9"))+666$++K888D-88
,
	B&M"
B$++,@AAAD-88
kC.////
c$%%%
 	


C01111
c&'''
"	



";tR!c:N6O6O2O-OPP &D"q3?Q;R;R7R2R S S#[q1s;M7N7N3N/NOO%{4Q=Q9R9R5R1RSS +dCMM::
L


!	
!




P	
P



#

#:
:
 !
"#
&?'
?(N)
N*:+
:,-
.$/
$2M3
M45
8N9
N:";
"	Br4c	|d}|tj5}tjtj|dddn#1swxYwY|dt|j	
|ddd}|tj5}tjtj|dddn#1swxYwY|dt|j	
|d}|tj5}tjtj|dddn#1swxYwY|dt|j	
|ddddd}|tj5}tjtj|dddn#1swxYwY|d	t|j	
|d
ddd}|tj5}tjtj|dddn#1swxYwY|d	t|j	
|ddd
d}|tj5}tjtj|dddn#1swxYwY|d	t|j	
|d
d
d
}|tj5}tjtj|dddn#1swxYwY|d	t|j	
dS)a
Missing zip64 extra records raises an exception.

        There are 4 fields that the zip64 format handles (the disk number is
        not used in this module and so is ignored here). According to the zip
        spec:
              The order of the fields in the zip64 extended
              information record is fixed, but the fields MUST
              only appear if the corresponding Local or Central
              directory record field is set to 0xFFFF or 0xFFFFFFFF.

        If the zip64 extra content doesn't contain enough entries for the
        number of fields marked with 0xFFFF or 0xFFFFFFFF, we raise an error.
        This test mismatches the length of the zip64 extra field and the number
        of fields set to indicate the presence of zip64 data.
        T)rNz	file size)rrrz
compress size)r)rrrrrz
header offsetF)rrrr)rrrr)rrr)rrrR
BadZipFilerSr$r%rpru	exceptionlower)rDmissing_file_size_extraemissing_compress_size_extramissing_header_offset_extras     r(test_bad_zip64_extraz0StoredTestZip64InSmallFiles.test_bad_zip64_extrasR$#'"6"6!#7#
#


w1
2
2	AaOBJ'>??@@@	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A

k3q{#3#3#9#9#;#;<<<'+&:&:! !%';'
'
#


w1
2
2	EaOBJ'BCCDDD	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E

os1;'7'7'='='?'?@@@'+&:&:!%';'
'
#

w1
2
2	EaOBJ'BCCDDD	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E

os1;'7'7'='='?'?@@@
'+&:&:! !% $!%';'
'
#

w1
2
2	EaOBJ'BCCDDD	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E

os1;'7'7'='='?'?@@@'+&:&:"!% $!%	';'
'
#

w1
2
2	EaOBJ'BCCDDD	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E

os1;'7'7'='='?'?@@@'+&:&:! !&!%	';'
'
#

w1
2
2	EaOBJ'BCCDDD	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E

os1;'7'7'='='?'?@@@'+&:&:"!&!%';'
'
#


w1
2
2	EaOBJ'BCCDDD	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E

os1;'7'7'='='?'?@@@@@s}'A))A-0A-%'DDD'GG	G	'I66I:=I:3'L&&L*-L*#'OOO'RR	R	cd}d}d}d}dddddddddf}tdt|dzD]}tj||D]}i}|D]}	||	tjtj|j	d	i|5}
|

d}||j|||j
|||j|||
||dddn#1swxYwYdS)
NrrrT)rr)rr)rrr`re)r5ro	itertoolscombinationsupdaterRrSr$r%rrwrirxrrrj)rDexpected_file_sizeexpected_compress_sizeexpected_header_offsetexpected_contentparamsrZcomborUczfr!s            r( test_generated_valid_zip64_extraz<StoredTestZip64InSmallFiles.test_generated_valid_zip64_extra"s!"!"&
"&$??%)$GG%)$GG
q#f++/**
	G
	GA"/::	
G	
G%%AMM!$$$$_RZ0D0D0N0Nv0N0N%O%OPPGTVKKMM!,E$$U_6HIII$$U%8:PQQQ$$U%8:PQQQ$$RWWU^^5EFFFGGGGGGGGGGGGGGG		
G
	G
	GsBD??EEc"tj}tj|dd5}|ddd5}|ddddn#1swxYwYdddn#1swxYwY|}tjd|dd	\}}}}}	}
}}}
}}}}}}|	|d
|
|tj|	|d|	|d|	|	d|	|
d|	|d|	|d
|	|
d|	|d|	|d|	|d|	|d|	|dtjtj|}|}|	t|d|
|djtjdS)zGTest that forcing zip64 extensions correctly notes this in the zip filerLTrQrtext.txtrQforce_zip64_Nz<4sBBHH8xIIHH8shhQQx4s?PKrrrrr`PK)r$r%rRrSrArBrmrcunpackriassertGreaterEqual
ZIP64_VERSIONrwroextract_version)rDr9rzirheaderversrUflagscompcsizeusizefn_lenex_total_lenrgex_idex_lenex_usizeex_csizecd_sigzzinfoss                      r(test_force_zip64z,StoredTestZip64InSmallFiles.test_force_zip64=s*z||
_T
=
=
=	#4@@
B














															--//
M2GCRCLAA	
D"eT5%(E68Xv	
///g&;<<<Q"""q!!!
+++
+++###r***"""$$$1%%%1%%%///OBJw//00Va(((q	 97;PQQQQQs5A=A&A=&A*	*A=-A*	.A==BBcd}|t|tj|t|t	tjdS)zjTest that creating a zip with/without seeking will raise a RuntimeError if zip64 was required but not usedctj|dd5}|ddd5}|dtjdzzdddn#1swxYwYddddS#1swxYwYdS)	NrLTrrFrrr`)rRrSrArBr)rErrs   r(make_zipzRStoredTestZip64InSmallFiles.test_unseekable_zip_unknown_filesize.<locals>.make_zipvs#$???
?2WWZcuWEE?HHTW%81%<=>>>???????????????
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?s4A;&A#A;#A'	'A;*A'	+A;;A?A?N)rRuntimeErrorr$r%
UnseekablerDrs  r($test_unseekable_zip_unknown_filesizez@StoredTestZip64InSmallFiles.test_unseekable_zip_unknown_filesizess]	?	?	?
	
,"*,,???,*RZ\\2J2JKKKKKr4cd}|tj|tj|tj|ttjdS)z^Test that trying to add a large file to a zip that doesn't allow zip64 extensions fails on addctj|dd5}tjd}tjdz|_||dddddS#1swxYwYdS)NrLFrrr`rP)rRrSZipInforrxrA)rErrs   r(rzRStoredTestZip64InSmallFiles.test_zip64_required_not_allowed_fail.<locals>.make_zips#%@@@
(Bz22!(!4q!83'''	
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(sAA%%A),A)N)rrRrr$r%rrs  r($test_zip64_required_not_allowed_failz@StoredTestZip64InSmallFiles.test_zip64_required_not_allowed_fail~sc	(	(	(	
'."*,,GGG'.*RZ\\:R:RSSSSSr4ctjdzfd}|tj}tjd|ddz\}}}}}}}	}
}}}
}}}}||d|	|tj
||d||d||d||d||	d||
d	||d
||
d||d||||||d|ttjj}tjd
|ddz\}}}}}}}	}
}}}
}}}}}}}||d|	|tj
||d|d|d||d||d||	d||
d	||d
||
d||d||d||d||d||||||ddS)zhTest that creating a zip without seeking will use zip64 extensions if the file size is provided up-frontr`c,tj|dd5}tjd}|_||dd5}|dzdddn#1swxYwYdddn#1swxYwY|S)NrLTrrFrr)rRrSr	rxrArB)rErrrrxs    r(rzPStoredTestZip64InSmallFiles.test_unseekable_zip_known_filesize.<locals>.make_zips
#$???
/2z22!*WWTW??/2HHTI-...///////////////	
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/Is54B	
A2&B	2A6	6B	9A6	:B		B
B
z<4sBBHH8xIIHH8shhQQ{}x4sN>rrrrrrrz<4sBBHH8xIIHH8shhQQ{}x4s4xQQ4sVz{:b}1000sPK)
rRrr$r%rmrcrformatrirrrrE)rDr
seekable_datarrrUrrrrrrrgrrrrrunseekable_data	dd_headerdd_usizedd_csizerxs                      @r("test_unseekable_zip_known_filesizez>StoredTestZip64InSmallFiles.test_unseekable_zip_known_filesizes '!+						!..7799

M4;;IFF
VeWY\eWeVeHfgg		
D"eT5%(E68X	
///g&;<<<Q"""q!!!
+++
+++###r***"""$$$9---9---///#(:bjll#;#;<<?HHJJ

M:AA)LLo^m_adm_m^mNnoo		
D"eT5%(E68Xx6	
///g&;<<<Qu--v666q!!!
+++
+++###r***"""$$$1%%%1%%%L1119---9---/////r4N)FFFFFF)r
rrrRrrJrrrr+rrrrrrr
rrer4r(rr8s$KCCC
III
CCC
===1117<8=8=aaaaF\A\A\A|GGG64R4R4Rl	L	L	L
T
T
TJ0J0J0J0J0r4rceZdZejZdS)DeflateTestZip64InSmallFilesNr
rrrRrmrJrer4r(rr&KKKr4rceZdZejZdS)Bzip2TestZip64InSmallFilesNrsrer4r(rrrur4rceZdZejZdS)LzmaTestZip64InSmallFilesNrxrer4r(rrrzr4rc&eZdZdZdZdZdZdS)AbstractWriterTestsc.ttdSr rr!rs r(rzAbstractWriterTests.tearDownwr4cd}tjtd|j5}|dd}|||||j|||j|	|
d|ddddS#1swxYwYdS)NcontentrLr&)rRrSr!rJrArBrIrrr#rirjrDr9rrLs    r(test_close_after_closez*AbstractWriterTests.test_close_after_closes
_Wc4+;
<
<	6		&#&&A
GGDMMM
GGIIIOOAH%%%
GGIIIOOAH%%%TYYv..555	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6sB1C!!C%(C%cd}tjtd|j5}|dd}|||||j|	t|jd||d|ddddS#1swxYwYdS)Nr%rLr&r4)
rRrSr!rJrArBrIrrr#rrJrirjr&s    r(test_write_after_closez*AbstractWriterTests.test_write_after_closes
_Wc4+;
<
<	6		&#&&A
GGDMMM
GGIIIOOAH%%%j!'3777TYYv..555
	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6sB$CCCctjdgd}t||jz}tjtjd|j5}|dd5}|	|
||dddn#1swxYwY|	|dj|ddddS#1swxYwYdS)Nr)r`rrrcr\rLr9)
arrayroitemsizerRrSr$r%rJrArirBryrx)rDqLENGTHrr9s     r(test_issue44439z#AbstractWriterTests.test_issue44439seK___--Q!*$
_RZ\\30@
A
A	DS&#&&
8$  A777
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8S[[00:FCCC	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	Ds6C.2*B(C.(B,	,C./B,	01C..C25C2N)r
rrrr'r)r/rer4r(r r sU	6	6	6666DDDDDr4r ceZdZejZdS)StoredWriterTestsNr
rrrRrrJrer4r(r1r1	s$KKKr4r1ceZdZejZdS)DeflateWriterTestsNrrer4r(r4r4s&KKKr4r4ceZdZejZdS)Bzip2WriterTestsNrsrer4r(r6r6s#KKKr4r6ceZdZejZdS)LzmaWriterTestsNrxrer4r(r8r8s"KKKr4r8cPeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dS)
PyZipFileTestscJ|dz|vr||dz|dSdS)Nor)rp)rDnamervs   r(assertCompiledInzPyZipFileTests.assertCompiledIns7#:X%%MM$*h/////&%r4ctj|tjtjtjvs|dtj|d}	tj|tjtj	z}tj
|n%#t$r|dYnwxYwt|dS)N)
effective_idsz/requires write access to the installed locationztest_zipfile.try)
rUaccessW_OKsupports_effective_idsr`rr8rAO_WRONLYO_CREATrI	Exceptionr)rDrrgfds    r(requiresWriteAccessz"PyZipFileTests.requiresWriteAccesssyrw')yB4M'MOOO	MMMKLLL7<<&899	M2;#;<<BHRLLLL	M	M	MMMKLLLLL	Mxs.AB//CCcx|tjtt5}t
j|d5}t}|dr|	tj
}tj2||	tjd|vr tj|}n
|dd}||tj|}||||||dddn#1swxYwYdddn#1swxYwYt5}t
j|d5}t}|dr
|dd}||dddtj|}||||||dddn#1swxYwYddddS#1swxYwYdS)NrL.pyc__pycache__rtestpackage/)rHrUrdirname__file__rrR	PyZipFileendswithrqsepaltsepextend	importlibutilsource_from_cachewritepybasenameassertNotInrvr>)rDtrVr}
path_splitbns      r(test_write_pyfilez PyZipFileTests.test_write_pyfile+s<  !:!:;;;
__	87#4Q#<#<	8B{{6""
!XXbf--
9(%%bhhry&9&9::: J.."99"==BBCRCBMM"!!"%%BR!1!1222!!"enn&6&6777	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8"__		87#4Q#<#<		8B{{6""
WMM"m,,,)MM27+;+;B+?+?+?@BR!1!1222!!"enn&6&6777		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8		8snF+D,FF+F	F+F	F++F/2F/J/B1JJ/J	J/J	J//J36J3cddl}tj|j}||t
5}tj|d5}|	||
}|d||d|dddn#1swxYwYddddS#1swxYwYdS)NrrLzemail/__init__.pyzemail/mime/text.py)emailrUrrNrOrHrrRrPrXrvr>)rDr`
packagedirr[rVrs      r(test_write_python_packagez(PyZipFileTests.test_write_python_packageIsTW__U^44
  ,,,
__	?7#4Q#<#<	?MM*%%%NN$$E!!"5u===!!"6>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?s7C"AC8CC	CC	CC #C c	"ddl}tj|j}||t
5}tj|d5}t5}|
|dddn#1swxYwY|}|d|vt5}|
|ddddn#1swxYwY|}|d|vd}t5}|
t5|
||dddn#1swxYwYdddn#1swxYwY|}|rt||d|vdddn#1swxYwYddddS#1swxYwYdS)NrrLSyntaxErrorcdS)NFre)whatevers r(<lambda>zCPyZipFileTests.test_write_filtered_python_package.<locals>.<lambda>gser4
filterfuncchtj|dS)Nbad)rUrrY
startswith)rs r(filterzAPyZipFileTests.test_write_filtered_python_package.<locals>.filterls)7++D11<<UCCCCr4)r&rUrrNrOrHrrRrPr
rXrmrrassertWarnsUserWarningprint)rDr&rar[rV	reportSIO	reportStrrms        r("test_write_filtered_python_packagez1PyZipFileTests.test_write_filtered_python_packageWs{W__T]33
  ,,,
__	<7#4Q#<#<	<!""
*i

j)))
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*!**,,IOOMY6777!""
Mi

j5K5K
LLL
M
M
M
M
M
M
M
M
M
M
M
M
M
M
M!**,,IOOM:;;;
D
D
D ""
=i1A1A+1N1N
=
=

jV
<<<
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=!**,,I
!i   OOM:;;;/	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<sH"G,1BG,BG,B<G,C<0G,<DG,D?G,FF	6FF
F	F
F
G,FG, F!?G, H,G0	0H3G0	4HHHcddl}tj|j}||d}d}t
5}tj|d|5}|	||
}|d|z||d|z|dddn#1swxYwYddddS#1swxYwYdS)	NrFr`rJrL)optimizezemail/__init__zemail/mime/text)r`rUrrNrOrHrrRrPrXrvrp)rDr`raoptlevelextr[rVrs        r(test_write_with_optimizationz+PyZipFileTests.test_write_with_optimizationusiW__U^44
  ,,,'(
__	:

q#
9
9
9	:=BMM*%%%NN$$EMM*S0%888MM+c15999
	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:	:s7C((ACC(C	C(C	C((C,/C,cftjt	ttjtddd5}|ddddn#1swxYwYttjtddd5}|ddddn#1swxYwYttjtddd5}|d	dddn#1swxYwYt5}tj	|d5}|
t|}|d||d||
d|dddn#1swxYwYdddn#1swxYwYttdS#ttwxYw)
Nmod1.pyrLr;r<
print(42)
mod2.pyprint(42 * 42)
zmod2.txtzbla bla bla
rUmkdirr!rArr8rBrrRrPrXrvr>rZrrDrEr[rVrs     r(test_write_python_directoryz*PyZipFileTests.test_write_python_directorys
	bgll7I66gNNN
(RT'''
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(bgll7I66gNNN
-RT+,,,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-bgll7J77wOOO
*SU)))
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
4Aw'8C'@'@
4E

g&&&((%%i777%%i777  U333

4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
7OOOOOF7OOOOs5HA2&H2A66H9A6:8H2CHCHC8HD6*H6D::H=D:>HG9%A1G"G9"G&	&G9)G&	*G9-H9G==HG=HH0c|tjt	ttjtddd5}|ddddn#1swxYwYttjtddd5}|ddddn#1swxYwYt5}tj	|d5}|
td	|}|d||
d|dddn#1swxYwYdddn#1swxYwYttdS#ttwxYw)
NrzrLr;r<r{r|r}c.|dS)Nr|)rQ)r}s r(rgzEPyZipFileTests.test_write_python_directory_filtered.<locals>.<lambda>s68kk)6L6L2Lr4rhr~rs     r($test_write_python_directory_filteredz3PyZipFileTests.test_write_python_directory_filteredsw
	bgll7I66gNNN
(RT'''
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(bgll7I66gNNN
-RT+,,,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
3Aw'8C'@'@
3E

g3M3M
NNN((%%i777  E222

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
7OOOOOF7OOOOs5F%A2&F%2A66F%9A6:8F%2CF%CF%CF%-FAE-!F-E1	1F4E1	5F8F%FF%FF%%F;ct5}tj|d5}ttdd5}|ddddn#1swxYwY|t|jtttdddn#1swxYwYddddS#1swxYwYdS)NrLr;r<z!most definitely not a python file)
rrRrPrArrBrrrXr)rDr[rVr's    r(test_write_non_pyfilez$PyZipFileTests.test_write_non_pyfilesp
__	7#4Q#<#<	fcG444
=;<<<
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=lEM6BBB6NNN																																		sWCB0AB0A##B0&A#'=B0$C0B4	4C7B4	8CCCc	tjt	ttjtddd5}|ddddn#1swxYwYt5}tj	|d5}t5}|tjtddddn#1swxYwY|d|
|}|d||d|dddn#1swxYwYdddn#1swxYwYt!tdS#t!twxYw)NrzrLr;r<zBad syntax in python file
rdzmod1.pyc)rUrr!rArr8rBrrRrPr
rXrprmrvrZr)rDrEr[rVsrs      r(test_write_pyfile_bad_syntaxz+PyZipFileTests.test_write_pyfile_bad_syntaxsn
	bgll7I66gNNN
8RT6777
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
4Aw'8C'@'@
4E$&&D!MM"',,w	"B"BCCCDDDDDDDDDDDDDDD

mQZZ\\:::((

i///  U333
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
7OOOOOF7OOOOs5F,A2&F,2A66F,9A6:F,F!E409C5)E45C99E4<C9=A+E4(F4E8	8F;E8	<F?F,FF,FF,,Gctjt	ttjtddd5}|ddddn#1swxYwYt5}tj	|d5}|
tjtdz|
}|d|dddn#1swxYwYdddn#1swxYwYttdS#ttwxYw)NrzrLr;r<r{)rUrr!rArr8rBrrRrPrXrrrvr>rrs     r(test_write_pathlikez"PyZipFileTests.test_write_pathlikes
		bgll7I66gNNN
(RT'''
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
8Aw'8C'@'@
8E

gl733i?@@@((%%i777
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8

7OOOOOF7OOOOsx5D?A2&D?2A66D?9A6:D?D!AD;DD	DD	DD?D""D?%D"&D??EN)r
rrr>rHr^rbrsrxrrrrrrer4r(r:r:s000888<???<<<<
:
:
:.(,r4r:ceZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZejejjd
kddZejejjdkddZdZdS)ExtractTestsctjtdtj5}tD]\}}|||	ddddS#1swxYwYdS)NrL)rRrSr!rSMALL_TEST_DATArTrDrVfpathfdatas    r(make_test_filezExtractTests.make_test_files
_Wc7+=
>
>	-% /
-
-uue,,,,
-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-s$AAAc	t5|tjtd5}t
D]\}}||}tj	tj
|}tj|}|||t|d5}|||dddn#1swxYwYt!|	dddn#1swxYwYddddS#1swxYwYdSNrZr1)rrrRrSr!rextractrUrr8getcwdnormpathrirAencoderjr)rDrVrrwrittenfilecorrectfiler's       r(test_extractzExtractTests.test_extracts
ZZ	(	(!!!#..
(%$3
(
(LE5"'--"6"6K#%',,ry{{E"B"BK"$'"2"2;"?"?K$$[+>>>k400CA((BBBCCCCCCCCCCCCCCC;''''
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(sY/EBE;D	ED!
!E$D!
%E9EE			EE		
EE!$E!c|tjtd5}tD]\}}|||}tj||}tj	|}|
tj||||ft|d5}|
||dddn#1swxYwYt!|	dddn#1swxYwYt!tdSr)rrRrSr!rrrUrr8rrrsamefilerArirrjr)rDtargetrVrrrrr's        r(_test_extract_with_targetz&ExtractTests._test_extract_with_targets
_Wc
*
*
	$e /
$
$u#mmE6::!gll6599 g..{;; 0 0k J J[Z`Labbb+t,,?$$U\\^^QVVXX>>>???????????????{####
$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$	ws6B)E;DED##E&D#'EEEc~t5}||ddddS#1swxYwYdSr )rrrDextdirs  r(test_extract_with_targetz%ExtractTests.test_extract_with_targets
ZZ	36**6222	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3266ct5}|tj|ddddS#1swxYwYdSr )rrrrrs  r(!test_extract_with_target_pathlikez.ExtractTests.test_extract_with_target_pathlikes
ZZ	A6**7<+?+?@@@	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A(AAAc	ht5|tjtd5}|tD]\}}tj	tj
|}t|d5}||
|dddn#1swxYwYt|	dddn#1swxYwYddddS#1swxYwYdSr)rrrRrSr!
extractallrrUrr8rrArirrjr)rDrVrroutfiler's      r(test_extract_allzExtractTests.test_extract_alls
ZZ
	$
	$!!!#..
$%  """$3$$LE5 gll29;;>>Ggt,,C((BBBCCCCCCCCCCCCCCC7OOOO
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$
	$sY/D'A"D ;C'	D'C+
+D.C+
/DD'D	D'D	D''D+.D+c"|tjtd5}||t
D]\}}tj||}t|d5}|
||dddn#1swxYwYt|	dddn#1swxYwYttdSr)rrRrSr!rrrUrr8rArirrjr)rDrrVrrrr's       r(_test_extract_all_with_targetz*ExtractTests._test_extract_all_with_targetsa
_Wc
*
*	 eV$$$ /
 
 u',,vu55'4((?A$$U\\^^QVVXX>>>???????????????w

 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	ws6AC0;C<C0CC0CC00C47C4c~t5}||ddddS#1swxYwYdSr )rrrs  r(test_extract_all_with_targetz)ExtractTests.test_extract_all_with_target*s
ZZ	76..v666	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7rct5}|tj|ddddS#1swxYwYdSr )rrrrrs  r(%test_extract_all_with_target_pathlikez2ExtractTests.test_extract_all_with_target_pathlike.s
ZZ	E6..w|F/C/CDDD	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	Erc|tj|t	|d5}|||ddddS#1swxYwYdS)Nr1)rrrUrisfilerArirj)rDrgrr's    r(
check_filezExtractTests.check_file2sx00111
(D
!
!	0QQVVXXw///	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0s)A99A=A=ctjj}||ddd||ddd||ddddS)	Nz,,?,C:,foo,bar/z,z_,C_,foo,bar/zza\b,c<d>e|f"g?h*iza\b,c_d_e_f_g_h_i../../foo../../ba..rrM	foo/ba..r)rRrS_sanitize_windows_nameri)rDsans  r(test_sanitize_windows_namez'ExtractTests.test_sanitize_windows_name7s}o40#668IJJJ13779MNNN3S99<HHHHHr4c8gd}||dS)N))z
../foo/barfoo/bar)z
foo/../barr)z
foo/../../barr)z
foo/bar/..r)z./../foo/barr)z/foo/barr)z/foo/../barr)z/foo/../../barr_test_extract_hackers_arcnames)rDcommon_hacknamess  r(*test_extract_hackers_arcnames_common_casesz7ExtractTests.test_extract_hackers_arcnames_common_cases>s1	
	
	
	
++,<=====r4\zRequires \ as path separator.c8gd}||dS)z>Test combination of path fixing and windows name sanitization.))z
..\foo\barr)z..\/foo\/barr)zfoo/\..\/barr)zfoo\/../\barr)z	C:foo/barr)z
C:/foo/barr)zC://foo/barr)z
C:\foo\barr)z//conky/mountpoint/foo/barr)z\\conky\mountpoint\foo\barr)z///conky/mountpoint/foo/barmountpoint/foo/bar)z\\\conky\mountpoint\foo\barr)z//conky//mountpoint/foo/barr)z\\conky\\mountpoint\foo\barr)z//?/C:/foo/barr)z\\?\C:\foo\barr)zC:/../C:/foo/barz
C_/foo/bar)za:b\c<d>e|f"g?h*izb/c_d_e_f_g_h_i)rrNr)rDwindows_hacknamess  r(*test_extract_hackers_arcnames_windows_onlyz7ExtractTests.test_extract_hackers_arcnames_windows_onlyKs1


*	
++,=>>>>>r4rMzRequires / as path separator.c8gd}||dS)N))z	//foo/barr)rzfoo../ba..r)
foo/..\barrr)rDposix_hacknamess  r((test_extract_hackers_arcnames_posix_onlyz5ExtractTests.test_extract_hackers_arcnames_posix_onlyes/



	
++O<<<<<r4c|D]i\}}d|z}tjtdtj5}tj}||_d|_|||dddn#1swxYwY|	tjd}tj
ddd}tjj
|g|dR}tjtd5}|||}	||	|d	|d
|	d|dddn#1swxYwY|||t%dtjtd5}||dddn#1swxYwY|||t%dtjj
tjg|dR}tjtd5}||}	||	|d
|zdddn#1swxYwY|||t%|ddtjtd5}|dddn#1swxYwY|||t%|ddt+tkdS)NfoobarrLrrMrsubdirsubsubrZzextract z: z != )msgz
extract %rr)rrRrSr!rr	rgr rTreplacerUrRrr8rqrrirrrrr)
rD	hacknamesarcname	fixednamerrVr!
targetpathrrs
          r(rz+ExtractTests._test_extract_hackers_arcnamesnsW"+(	(	GY'.."2"22G#w/ABB
/e))!(&1#ug...
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/oobfc22Gh(CCJ',zIIOOC4H4HIIIK#..
F%#mmGZ@@  kk")'';;;&E!FFF
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F

OOK1118#..
-%  ,,,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-OOK1118',ry{{JY__S5I5IJJJK#..
=%#mmG44  k%1G%;!===
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
OOK1119??3''*+++#..
#%  """
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#OOK1119??3''*+++7OOOOQ(	(	sZ8B		B
	B
	8EE!	$E!	'G		G
	G
	1JJ	J	.LL	L	N)r
rrrrrrrrrrrrrrunittestskipIfrUrrRrrrrer4r(rrsJ---
(((&&333AAA$$$777EEE000
III>>>X_RW[D(*JKK??LK?2X_RW[C')IJJ==KJ=)))))r4rc>eZdZdZdZdZdZdZedZ	dZ
dZd	Zd
Z
dZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)e*d'Z+d(Z,d)S)*
OtherTestscVtjtdtj5}|dd|t5|dddddn#1swxYwY||dgdzdddn#1swxYwYtjtd5}|	}d}|D]F}|
|5}||z
}dddn#1swxYwYG||dd	hd}|D]}|||z
}||dd	hddddS#1swxYwYdS)
NrLr=rbarrrZr4rsbarfoo)
rRrSr!rrTrnrorirvrwrArjrp)rDrVrr9rrs      r(test_open_via_zip_infoz!OtherTests.test_open_via_zip_infos
_Wc7+=
>
>	=%NN65)))!!+..
.
.vu---
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.U^^--x!|<<<		=	=	=	=	=	=	=	=	=	=	=	=	=	=	=_Wc
*
*
	8eNN$$ED
+
+ZZ%%+GLLNN*D+++++++++++++++MM$I 6777D
)
)

4(((MM$I 6777
	8
	8
	8
	8
	8
	8
	8
	8
	8
	8
	8
	8
	8
	8
	8
	8
	8
	8sl1B=A:.B=:A>	>B=A>	/B==CC"0FD6*F6D::F=D:>AFF"%F"ctjtd5}dD]F}tj|}|xjtjzc_|||G	ddddS#1swxYwYdS)NrLabcdefghijklmnop)rRrSr!r		flag_bits_MASK_USE_DATA_DESCRIPTORrT)rDorig_zipr9r!s    r(-test_writestr_extended_local_header_issue1202z8OtherTests.test_writestr_extended_local_header_issue1202s
_Wc
*
*	/h*
/
/--7#DD!!%....
/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/sA
A33A7:A7ctjtd5}tD]6\}}|||||jd7	dddn#1swxYwY||jdtjtd5}||jddddn#1swxYwY||jddS)z8Check that the zipfile is closed after the 'with' block.rLzzipfp is not openNzipfp is not closedrZ)rRrSr!rrTassertIsNotNonerEassertIsNoners    r(
test_closezOtherTests.test_closes
_Wc
*
*	De /
D
Duue,,,$$UX/BCCCC
D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	
%($9:::
_Wc
*
*	@e  +>???	@	@	@	@	@	@	@	@	@	@	@	@	@	@	@%($9:::::s#?A''A+.A+'CCCctjtd5}tD]\}}|||	dddn#1swxYwY	tjtd5}tj#1swxYwYdS#tj$r||jdYdSwxYw)zWCheck that the zipfile is closed if an exception is raised in the
        'with' block.rLNrZr)rRrSr!rrTrrrE)rDrVrrzipfp2s     r(test_close_on_exceptionz"OtherTests.test_close_on_exceptions;_Wc
*
*	-e /
-
-uue,,,,
-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	@#..
+&(***
+
+
+
+
+
+
+
+
+
+!	@	@	@fi)>??????	@sA$AAAB2BB

B
B
B*CCc|d}|ttjt	j|ddS)NsdPKx!p@xPKxx!p@xPK/rZ)rNotImplementedErrorrRrSr$r%rDr9s  r(test_unsupported_versionz#OtherTests.test_unsupported_versionsDY	
-w*T**C	1	1	1	1	1r4ctd}tj|5}|D])}||*	ddddS#1swxYwYdS)Nzzip_cp437_header.zip)r	rRrSrvrArI)rDrrVr=s    r(test_read_unicode_filenamesz&OtherTests.test_read_unicode_filenamess/00
_U
#
#	)u((
)
)

4  &&((((
)	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)s?A11A58A5c0tjtd5}|dd|dd||djtdddn#1swxYwYtjtd5}||j	djd||j	djdddddS#1swxYwYdS)NrLfoo.txtzTest for unicode filenameuö.txtrrZr`)
rRrSrrTrrwrgrurifilelistrDrs  r(test_write_unicode_filenamesz'OtherTests.test_write_unicode_filenamess
_VS
)
)	BRKK	#>???KK
$?@@@!!"++--"2";SAAA	B	B	B	B	B	B	B	B	B	B	B	B	B	B	B
_VS
)
)	BRR[^4i@@@R[^4jAAA	B	B	B	B	B	B	B	B	B	B	B	B	B	B	B	B	B	Bs%A%BBB1A
DDDctjtd5}|dd||ddddddS#1swxYwYdS)NrLuприкладssample)rRrSr!rTrirjr*s  r('test_read_after_write_unicode_filenamesz2OtherTests.test_read_after_write_unicode_filenamess
_Wc
*
*	FeNN+Y777UZZ(8999EEE	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	FsAA((A,/A,cttd}d}tjtdtj5}|||dddn#1swxYwY|t5tjtdtjdddn#1swxYwYtjtd5}||	|g||
||ddddS#1swxYwYdS)z&Test exclusive creating a new zipfile.testfile.txt#hello, world. this is some content.xNrZ)rr!rRrSrrTrFileExistsErrorrirvrj)rDrgrrVs    r(test_exclusive_create_zip_filez)OtherTests.test_exclusive_create_zip_filesw!8
_Wc7+=
>
>	.%NN8W---	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.



/
/	>	>OGS'*<===	>	>	>	>	>	>	>	>	>	>	>	>	>	>	>
_Wc
*
*	<eU^^--z:::UZZ117;;;	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<s6A!!A%(A%&B88B<?B<AD==EEctjtrtjtd}d}	tjtd5}|||dddn#1swxYwYn%#t$r|	dYnwxYw|
tjttjtd5}||||ddddS#1swxYwYdS)Nrrr-z1Could not append data to a non-existent zip file.rZ)
rUrexistsrrrRrSrTrfailrrrirj)rDrgrrs    r((test_create_non_existent_file_for_appendz3OtherTests.test_create_non_existent_file_for_appends
7>>&!!	If!8	K--
/Hg...
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/	K	K	KIIIJJJJJ	K	
v..///
_VS
)
)	9RRWWX..888	9	9	9	9	9	9	9	9	9	9	9	9	9	9	9	9	9	9sHBB4BBBBBB.-B.*D99D=D=cttdd5}|ddddn#1swxYwY	tjt}dS#tj$rYdSwxYw)NrLr;r<this is not a legal zip file
)rArrBrRrSr)rDrErs   r(test_close_erroneous_filez$OtherTests.test_close_erroneous_files&#
0
0
0	7BHH5666	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	((BBB!			DD	s:>>A!!A43A4c"ttdd5}|ddddn#1swxYwY|t	jt|t	jt
jtttd5}|t	j|dddn#1swxYwYtj	}|d|t	j||
dd|t	j|dS)	z;Check that is_zipfile() correctly identifies non-zip files.rLr;r<rNr1sthis is not a legal zip file
r)rArrBr"rR
is_zipfilerrr$r%r2rCs  r(test_is_zip_erroneous_filez%OtherTests.test_is_zip_erroneous_files&#
0
0
0	7BHH5666	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7+F33444+GL,@,@AABBB
&$

	52W/33444	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5Z\\
2333+B//000
1


+B//00000s:>>(C88C<?C<ctj}tj|d5}|dddddn#1swxYwY|}t
t|D]I}tj|d|}|tj	tj|JdS)zCCheck that zipfiles with missing bytes at the end raise BadZipFile.rLrPrO, for a Muse of Fire!N)
r$r%rRrSrTrmr5rorr)rDrErrNs     r(test_damaged_zipfilezOtherTests.test_damaged_zipfile1sZ\\
_Rc
*
*
*	@dMM)%>???	@	@	@	@	@	@	@	@	@	@	@	@	@	@	@kkmms;''((	G	GAKO,,Bg0'/2FFFF	G	GsA

AActjtd5}|dddddn#1swxYwY|tjtt
td5}|tj||dd|}dddn#1swxYwYtj
}|||tj||dd|tj|dS)z7Check that is_zipfile() correctly identifies zip files.rLrPrr	Nr1r)rRrSrrTrrrrAr2rjr$r%rB)rDrrEzip_contentss    r(test_is_zip_valid_filez!OtherTests.test_is_zip_valid_file?s_V#
.
.
.	@$MM)%>???	@	@	@	@	@	@	@	@	@	@	@	@	@	@	@	
*622333
&$

	%2OOG.r22333GGAqMMM7799L	%	%	%	%	%	%	%	%	%	%	%	%	%	%	%
Z\\
*2..///
1


*2../////s"?AAAC))C-0C-c\|ttjtdSr )rrrRrSrrs r(%test_non_existent_file_raises_OSErrorz0OtherTests.test_non_existent_file_raises_OSErrorRs$	
'7?F;;;;;r4cttdd}||tjtjtttdd5}|ddddn#1swxYwY|tjtjtdS)NrLr;r<z
short file)rArrIrrRrrSrB)rDr'rEs   r(!test_empty_file_raises_BadZipFilez,OtherTests.test_empty_file_raises_BadZipFile`sw///				',govFFF
&#
0
0
0	#BHH\"""	#	#	#	#	#	#	#	#	#	#	#	#	#	#	#',govFFFFFs3BBBctd}dD][}tjd||dd<tj|}|tjtj|\dS)NPK)r`rrrZr)		bytearrayrcrr$r%rrRrrS)rDbufferdirsizer's    r(8test_negative_central_directory_offset_raises_BadZipFilezCOtherTests.test_negative_central_directory_offset_raises_BadZipFileisw344"	F	FG"Kg66F2b5M
6""Ag0'/1EEEE	F	Fr4ctj}tj|d5}|dddddn#1swxYwY|t|jd|t|jd|t|j	|t|jddttdd	5}|d
dddn#1swxYwY|t|jtdS)z?Verify that testzip() doesn't swallow inappropriate exceptions.rLrPrO, for a Muse of Fire!Nz	bogus.txtrHr;r<zzipfile test data)r$r%rRrSrTrrJrjrArzrrB)rDr9rr's    r(!test_closed_zip_raises_ValueErrorz,OtherTests.test_closed_zip_raises_ValueErrortsz||
_T
,
,
,	?MM)%=>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	
*di;;;*di;;;*dl333*dm['JJJ
&#
0
0
0	)A
GG'(((	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)*dj&99999s#A

AA3DDDc^|ttjtddS)z>Check that bad modes passed to ZipFile constructor are caught.r-N)rrJrRrSrrs r(test_bad_constructor_modez$OtherTests.test_bad_constructor_modes$*govsCCCCCr4ctjtd5}|dddddn#1swxYwYtjtd5}|d|t|jdd|t|jdd|t|jdd	ddddS#1swxYwYdS)
z7Check that bad modes passed to ZipFile.open are caught.rLrPrrNrZr-UrU)rRrSrrTrjrrJrArDrs  r(test_bad_open_modezOtherTests.test_bad_open_modeso
_V#
.
.
.	?$MM)%=>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?_V#
.
.
.	F$IIi   j$)YDDDj$)YDDDj$)YEEE
	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	Fs"?AA%A<C..C25C2ctjtd5}|dd|d5}ttD]+}||dd,||ddddn#1swxYwYddddS#1swxYwYdS)	zsCheck that calling read(0) on a ZipExtFile object returns an empty
        string and doesn't advance file pointer.rLrPrrrr4r	N)	rRrSrrTrAr5r6rirj)rDrr'r2s    r(
test_read0zOtherTests.test_read0so_V#
.
.
.	F$MM)%=>>>9%%
F~..55A$$QVVAYY4444  +DEEE	
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	Fs6,CA)B=1C=C	CC	CCCctjtd5}|t|jddddddS#1swxYwYdS)zqCheck that attempting to call open() for an item that doesn't
        exist in the archive raises a RuntimeError.rLrPrrZN)rRrSrrKeyErrorrAr!s  r(test_open_non_existent_itemz&OtherTests.test_open_non_existent_items_V#
.
.
.	C$h	9cBBB	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	Cs#AAAc`|ttjtdddS)zMCheck that bad compression methods passed to ZipFile.open are
        caught.rLrN)rrrRrSrrs r(test_bad_compression_modez$OtherTests.test_bad_compression_modes)	
-wRPPPPPr4cd}tjtj|d5}|t
|jdddddS#1swxYwYdS)NsfPK.C@xPK..C@xPK/!rZr)rRrSr$r%rrrA)rDr9rs   r(test_unsupported_compressionz'OtherTests.test_unsupported_compressions6_RZ--s
3
3	Ct149cBBB	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	C	Cs"AA Actjtd5}|dd||dgddddS#1swxYwYdS)zLCheck that a filename containing a null byte is properly
        terminated.rLrPzfoo.txtqqqr	rN)rRrSrrTrirvr!s  r(test_null_byte_in_filenamez%OtherTests.test_null_byte_in_filenames_V#
.
.
.	;$MM*,EFFFT]]__yk:::	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;sAA))A-0A-c|tjd|tjd|tjd|tjddS)zACheck that ZIP internal structure sizes are calculated correctly..8rN)rirRsizeEndCentDirsizeCentralDirsizeEndCentDir64sizeEndCentDir64Locatorrs r(test_struct_sizeszOtherTests.test_struct_sizessl/444/444126668"=====r4c.
tjtd5}||jd|dddddn#1swxYwYtjtd5}||jddddn#1swxYwYd}tjtd5}||_|dddddn#1swxYwYtjtd5}||j|dddn#1swxYwYd	d
tdD}|d}tjtd5}||_|dddddn#1swxYwYtjtd5}||j|dddn#1swxYwYtjtd5}|	t5|d
z|_dddn#1swxYwY|dddddn#1swxYwYtjtd5}||j|dddn#1swxYwYtjtd5}d|_|dddddn#1swxYwYtjtd5}d|_dddn#1swxYwYtjtd5}||jddddn#1swxYwYtjtd5}d|_|dddddn#1swxYwYtj
t}tjtd5}d|_dddn#1swxYwY||tj
tktjtd5}||jdddddS#1swxYwYdS)z8Check that comments on the archive are handled properly.rLrPr4rrNrZs9Bravely taking to his feet, he beat a very brave retreat.c$g|]
}d|dzdzzS)rrrrer0s  r(r3z,OtherTests.test_comments.<locals>.<listcomp>s%KKK1DAqD2I.KKKr4r.soopssoriginal commentr-san updated commentsoriginal comment that's longersshorter comment)rRrSrrirBrTr8r5rrnrorUrgetsizerr)rDrzipfrrBcomment2original_zip_sizes      r(
test_commentszOtherTests.test_commentss_V#
.
.
.	?$T\3///MM)%=>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?_V#
.
.
.	1%U]C000	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1O
_V#
.
.
.	?$"DLMM)%=>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?_V#
.
.
.	4%T\7333	4	4	4	4	4	4	4	4	4	4	4	4	4	4	477KKk8J8JKKKLL??7++
_V#
.
.
.	?$#DLMM)%=>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?_V#
.
.
.	6%U]H555	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6_V#
.
.
.	?$!!+..
2
2''1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2MM)%=>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?_V#
.
.
.	6%U]H555	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6_V
-
-
-	?.DLMM)%=>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?_V
-
-
-	10DL	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1
_V
-
-
-	BT\+@AAA	B	B	B	B	B	B	B	B	B	B	B	B	B	B	B
_V
-
-
-	?<DLMM)%=>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?GOOF33
_V
-
-
-	.-DL	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.)BGOOF,C,CCDDD
_V
-
-
-	?T\+=>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?s2AA!AB((B,/B,C::C>C> EEE/GG G?H''H+.H+
J,(I?3J,?J	J,J	J,,J03J0K::K>K> M

MM0NNN*OOO8P""P&)P&,RRR!T

TTc tjtdtj5}|dd|t5d|_dddn#1swxYwYddddS#1swxYwYdS)NrLrrzthis is an error)rRrSrrrTr	TypeErrorrBr!s  r(test_unicode_commentzOtherTests.test_unicode_comments
_VS'*<
=
=	2MM)%=>>>""9--
2
21
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2s51BA+B+A/	/B2A/	3BB
Bc^tjtdtj5}||jd|_dddn#1swxYwYtjtd5}||jdddddS#1swxYwYdS)Nr-rArZ)rRrSrrr"rrBrir!s  r($test_change_comment_in_empty_archivez/OtherTests.test_change_comment_in_empty_archives)
_VS'*<
=
=	0T]+++/DL	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0_VS
)
)	ATT\+?@@@	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	As#"AAA9B""B&)B&ctjtdtj5}|dddddn#1swxYwYtjtdtj5}||jd|_dddn#1swxYwYtjtd5}||jdddddS#1swxYwYdS)NrLrrr-rArZ)	rRrSrrrTrrrrBrir!s  r('test_change_comment_in_nonempty_archivez2OtherTests.test_change_comment_in_nonempty_archives
_VS'*<
=
=	?MM)%=>>>	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?
_VS'*<
=
=	0OODM***/DL	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0_VS
)
)	ATT\+?@@@	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	A	As5A		A
A
9"B''B+.B+C55C9<C9ctjtd}|	tjtd}n*#tj$r|dYnwxYwtjtd}|	tjtd}dS#|dYdSxYw)NrLrPrZz+Unable to create empty ZIP file in 'w' moder-z+Unable to create empty ZIP file in 'a' mode)rRrSrrIrrr!s  r(test_empty_zipfilezOtherTests.test_empty_zipfilesvC000

	E?6444DD!	E	E	EIICDDDDD	EvC000

	E?6444DDD	EIICDDDDDDsA

$A43A4'CCcttdd}||tjtjtddS)NrLr;r<rZ)rArrIrrRrrSrs  r(test_open_empty_filezOtherTests.test_open_empty_file(sJ
w///				',govsKKKKKr4cT|ttjdddS)N	seventies)ir`r`rrr)rrJrRr	rs r(test_create_zipinfo_before_1980z*OtherTests.test_create_zipinfo_before_19800s5*!/;8M	O	O	O	O	Or4cvtjd}|t|ddS)z=Before bpo-26185, repr() on empty ZipInfo object was failing.emptyrfz&<ZipInfo filename='empty' file_size=0>N)rRr	rirrDrs  r(test_create_empty_zipinfo_reprz)OtherTests.test_create_empty_zipinfo_repr4s7
_g
.
.
.b#KLLLLLr4ctj}||jd||jd||jd||jtj||jd||j	d|
|jd||jtj
||jtj
||jd||jd||jd||jd||jd||jd||jddS)z'Ensure all required attributes are set.NoNamerTr4)rrrN)rRr	ri
orig_filenamergrWrrrBrrp
create_systemcreate_versionDEFAULT_VERSIONrreservedrvolume
internal_attrr rxrrPs  r(,test_create_empty_zipinfo_default_attributesz7OtherTests.test_create_empty_zipinfo_default_attributes9s
_

)8444h///'<===)7+=>>>S)))3'''

b&///*G,CDDD+W-DEEEa(((q)))A&&&)1---)1---	
q))))1-----r4cd}tjtj|d5}||ddddS#1swxYwYdS)z>If an extra field in the header is less than 4 bytes, skip it.snPK@abcAPK@abcPK3%rZN)rRrSr$r%rrzrDrrs   r(#test_zipfile_with_short_extra_fieldz.OtherTests.test_zipfile_with_short_extra_fieldOs
B	_RZ00#
6
6	.$dllnn---	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.s(AA#&A#cd}d}d}tjtdtj5}|dd5}||dddn#1swxYwY|dd5}|t5|dddddn#1swxYwY|t5|dd	dddn#1swxYwY|t5|d
ddddn#1swxYwY|t5|tddddn#1swxYwY|t5|
dddn#1swxYwY||dddn#1swxYwY|d
d5}||dddn#1swxYwYdddn#1swxYwYtjtd	5}||d|||d|||d
|||
gdddddS#1swxYwYdS)Ns"It's fun to charter an accountant!s And sail the wide accountant seas#To find, explore the funds offshorerLrrPrhandlerZruabcder[baz)rrrb)rRrSr!rrArBrrJrTrOrIrirjrv)rDmsg1msg2msg3rw2w1s       r(test_open_conflicting_handlesz(OtherTests.test_open_conflicting_handles^sb425
_Wc7+=
>
>	$5s++
r














5s++
r&&z2222IIhSI111222222222222222&&z22//IIe#I...///////////////&&z2222MM%111222222222222222&&z2211JJx000111111111111111&&z22!!JJLLL!!!!!!!!!!!!!!!














5s++
r














															$_Wc
*
*	EdTYYu--t444TYYu--t444TYYu--t444T]]__.C.C.CDDD		E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	EsDI2A&I2&A*	*I2-A*	.I2H#C;HCHCH,DHDHDH5EHEHE H=F%H%F))H,F)-H
G+H+G//H2G/3HI2H	I2H	I29II2I	I2"I	#I22I69I6B&M

MMc		d}|d}tjtd5}|d|dddn#1swxYwYtjtd5}|dd5}||tj|	|
|||tj|	|
d||tj|	|
||	|d|||dz|dtj
|	|
t||dtj|	|
ddddn#1swxYwYdddn#1swxYwYtj}tj|d5}|d|dddn#1swxYwYtj|d5}|dd5}||tj|	|
|||tj|	|
d||tj|	|
||	|d|||dz|dtj
|	|
t||dtj|	|
ddddn#1swxYwYddddS#1swxYwYdS)	NsWhere's Bruce?sBrucerLrrZrr\rP)findrRrSrrTrAr2rUSEEK_SETrirSEEK_CURrjSEEK_ENDror$r%)rDtxtblocrrEr9s      r(test_seek_tellzOtherTests.test_seek_tell{s0xx!!
_VS
)
)	*TMM)S)))	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*
_VS
)
)	/T9c**
/bbk***  D111r{+++  A...bk***  D111  Sd1f-=>>>2;'''  CHH5552;'''  A...
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/z||
_T
,
,
,	*MM)S)))	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*
_T
,
,
,	/9c**
/bbk***  D111r{+++  A...bk***  D111  Sd1f-=>>>2;'''  CHH5552;'''  A...
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/sAAA:IF+I<II	II	II#&I#J66J:=J:R=.F+R%R=%R)	)R=,R)	-R==SScd}tj|}tj|dtj5}|dddddn#1swxYwYt
jdd5tj|5}|t|j
ddddn#1swxYwYddddS#1swxYwYdS)NrrL)rJrazzipfile.bz2)r$r%rRrSrtrTmockpatchrrr)rDr9zip_filers    r()test_decompress_without_3rd_party_libraryz4OtherTests.test_decompress_without_3rd_party_librarysd:d##
_Xs8I
J
J
J	'bKK&&&	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'
Z
t
,
,	E	E**
Eb!!,
GDDD
E
E
E
E
E
E
E
E
E
E
E
E
E
E
E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	EsGAA"A;C"B>2C>C	CC	CCCcVttttdSr rrs r(rzOtherTests.tearDownrr4N)-r
rrrrrrrr
rrrrrrrrrrrrrrr"r$r'r)r+r-r6r?rBrDrFrHrJrMrQr[r^rhrprrvrrer4r(rrs888(///
;
;
;@@@	1	1	1]__))_)BBBFFF
<<<999$


111$GGG000&<<<GGG	F	F	F:::$DDDFFF
F
F
FCCCQQQ
	C	C	C;;;>>>8?8?8?t222AAAAAAEEE"LLLOOOMMM
...,
.
.
.EEE:$/$/$/L\^^EE^Er4rceZdZdZdZdS)AbstractBadCrcTestsc|j}tjtj|d5}|d|ddddS#1swxYwYdS)z>Tests that files with bad CRCs return their name from testzip.rZrPafileN)zip_with_bad_crcrRrSr$r%rirzr]s   r(test_testzip_with_bad_crcz-AbstractBadCrcTests.test_testzip_with_bad_crcs'
_RZ00s
;
;
;	6tWdllnn555	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6	6s)A&&A*-A*c|j}tjtj|d5}|tj|jddddn#1swxYwYtjtj|d5}|dd5}|tj|jdddn#1swxYwYdddn#1swxYwYtjtj|d5}|dd5}d|_	|tj5|dr	|ddddn#1swxYwYdddn#1swxYwYddddS#1swxYwYdS)zFTests that files with bad CRCs raise a BadZipFile exception when read.rZrPr{Nr)
r|rRrSr$r%rrrjrA
MIN_READ_SIZE)rDrrcorrupt_files    r(test_read_with_bad_crcz*AbstractBadCrcTests.test_read_with_bad_crcsL'_RZ00s
;
;
;	Ftg0$)WEEE	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F_RZ00s
;
;
;	It7C((
IL!!'"4l6GHHH
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I	I	I	I	I	I	I	I	I	I	I	I	I	I	I	I
_RZ00s
;
;
;	t7C((
L-.*&&w'9::&++A..'++A..














																		s'A##A'*A'C6-&CC6C#	#C6&C#	'C66C:=C:)G'F6',FF6F##F6&F#'F6*G6F:	:G=F:	>GGGN)r
rrr}rrer4r(ryrys2666r4ryc eZdZejZdZdS)StoredBadCrcTestssxPK ;:rafilehello,AworldPK ;:rafilePK3/N)r
rrrRrrJr|rer4r(rrs"$K	r4rc eZdZejZdZdS)DeflateBadCrcTestss|PKn}=FAKEnafileHW(/Iɠ=PKn}=FAKEnafilePK33N)r
rrrRrmrJr|rer4r(rrs"&K	6r4rc eZdZejZdZdS)Bzip2BadCrcTestssPKnu=FAKE8nafileBZh91AY&SYԨ@D  P!u5:"(HjTe?PKnu=FAKE8n afilePK3[N)r
rrrRrtrJr|rer4r(rrs"#K
	r4rc eZdZejZdZdS)LzmaBadCrcTestssPKnu=FAKEnafile	]4I:3`	q!.8PKnu=FAKEn afilePK3>N)r
rrrRryrJr|rer4r(rrs""K	%r4rcleZdZdZdZdZdZdZdZdZ	dZ
d	Zed
Z
dZdZd
S)DecryptionTestszCheck that ZIP decryption works. Since the library does not
    support encryption at the moment, we use a pre-generated encrypted
    ZIP file.sPKni.#y?&test.txtgly|-=yrZ}Lg|䋺)lPKni.#y?& test.txtPK6LsPK	}38xuzeroUT	֋GڋGUx<MaXY&{oEםPKxuPK	}38xu
zeroUT֋GUxPK?[szipfile.py encryption testscttd5}||jdddn#1swxYwYt	jtd|_ttd5}||jdddn#1swxYwYt	jtd|_	dS)Nr?rZ)
rArrBr9rRrSrr!data2zip2rCs  r(rFzDecryptionTests.setUp!	s
&$

	 2HHTY	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ?63//
'4
 
 	!BHHTZ   	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!OGS11			s!=AA<B##B'*B'c|jtjt|jtjtdSr )rrIrUrrrr!rs r(rzDecryptionTests.tearDown)	sL
	&	
	'r4c|t|jjd|t|jjddS)Ntest.txtzero)rrrrjrrs r(test_no_passwordz DecryptionTests.test_no_password/	sB	
,
zBBB,	?????r4c|jd|t|jjd|jd|t|jjddS)Nsperlrr)rsetpasswordrrrjrrs r(test_bad_passwordz!DecryptionTests.test_bad_password5	slW%%%,
zBBB	g&&&,	?????r4c:|jd||jd|j|jd||jd|jdS)Npythonrs12345r)rrrirjplainrplain2rs r(test_good_passwordz"DecryptionTests.test_good_password;	sY'''z22DJ???	h'''//=====r4c0d}|t|5|jddddn#1swxYwY|t|5|jdddddn#1swxYwY|t|5|jdddddn#1swxYwY|t|5|jdddddn#1swxYwY|t|5d|j_|jdddddS#1swxYwYdS)Nzpwd: expected bytes, got strunicoderpython)pwd)assertRaisesRegexrArrrjrArr)rDexpected_msgs  r(test_unicode_passwordz%DecryptionTests.test_unicode_passwordB	s5

#
#I|
<
<	,	,H  +++	,	,	,	,	,	,	,	,	,	,	,	,	,	,	,
#
#I|
<
<	0	0HMM*h///	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
#
#I|
<
<	4	4HMM*(M333	4	4	4	4	4	4	4	4	4	4	4	4	4	4	4
#
#I|
<
<	7	7HZX666	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7
#
#I|
<
<	&	&#DHLHMM*%%%	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&sYAA	A	+BBB9C""C&)C&D11D58D5'FFFc|jd|j}d}||}t	|}|jdd5}||tj|	|
|||tj|	|
d||tj|	|
||	||||||z|j
}d|_
d|_d|_|dtj|	|
d||tj|	||||||z||_
|dtj|	|
t	||dtj|	|
d|ddddS#1swxYwYdS)Nrs
encryptionrrZrr`r4)rrrrjrorAr2rUrkrirrlrjr_readbuffer_offsetrm)rDrn	test_wordrobloc_lenrE
old_read_sizes       r(rpzDecryptionTests.test_seek_tellU	sY'''j!	xx	""y>>
X]]:s
+
+	rGGD"+&&&RWWYY---GGTE2;'''RWWYY***GGD"+&&&RWWYY---RWWX..Dh4F0GHHH
,M B BNBJGGAr{###RWWYY***GGD"+&&&RWWX..Dh4F0GHHH,BGGAr{###RWWYYC111GGAr{###RWWYY***
GGIII;																		s#I>K..K25K2N)r
rr__doc__r9rrrrFrrrr
rrrprer4r(rr	s
	)		:

*E
F222@@@@@@]__>>_>&&&&#####r4rcZeZdZedZdZdZdZdZdZ	dZ
dZd	Zd
Z
dS)"AbstractTestsWithRandomBinaryFilesctdddztddz}ddt|D|_dS)Nr@rr`r4c	3zK|]6}tjdttddzV7dS)z<firN)rcrrrr0s  r(rz@AbstractTestsWithRandomBinaryFiles.setUpClass.<locals>.<genexpr>	sU77 !#Kfhhwud7K7K.KLL777777r4)rr8r5r9)r;	datacounts  r(r<z-AbstractTestsWithRandomBinaryFiles.setUpClass|	s`BOOD(71d+;+;;	8877%*9%5%577777r4cttd5}||jddddS#1swxYwYdSr>r@rCs  r(rFz(AbstractTestsWithRandomBinaryFiles.setUp	rGrHcVttttdSr rrs r(rz+AbstractTestsWithRandomBinaryFiles.tearDown	rr4ctj|d|5}|td|ttddddS#1swxYwYdS)NrLrM)rRrSrBrrs    r(rXz4AbstractTestsWithRandomBinaryFiles.make_test_archive	s
_Q[
1
1	(UKK///KK'''	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(s<A  A$'A$c|||tj|d|5}|t}|t
|t
|j|||j||d|jddddS#1swxYwYdS)NrZrM)rXrRrSrjrriror9)rDr'rJrVtestdatas     r(rz+AbstractTestsWithRandomBinaryFiles.zip_test	sq+..._Q[
1
1	DUzz&))HS]]C	NN;;;Xty111UZZ77CCC		D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	DsBCCCc`t|D]}|||jdSr rrs  r(	test_readz,AbstractTestsWithRandomBinaryFiles.test_read	rr4c|||tj|d|5}g}|t5}	|d}|sn||.	dddn#1swxYwYg}|d5}	|d}|sn||.	dddn#1swxYwYd|}	|t|	t|j
||	|j
d|}
|t|
t|j
||
|j
ddddS#1swxYwYdSr)rXrRrSrArrjrr8riror9)rDr'rJrVrrrrr	testdata1	testdata2s           r(rz0AbstractTestsWithRandomBinaryFiles.zip_open_test	syq+..._Q[
1
1	3UHF##
/x/ (

c 2 2I$OOI...	/	
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/HN++
/x/ (

c 2 2I$OOI...	/	
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/**IS^^S^^<<<Y	222**IS^^S^^<<<Y	222/	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3sZG
0B;GB	GB	G)0C&G&C*	*G-C*	.C
GGGc`t|D]}|||jdSr rrs  r(rz,AbstractTestsWithRandomBinaryFiles.test_open	rr4c>|||tj|d|5}g}|t5}	|t
dd}|sn||<	dddn#1swxYwYd|}|	t|t|j|	||jddddS#1swxYwYdSr)rXrRrSrArrjrrr8riror9)rDr'rJrVrrrrs        r(rz7AbstractTestsWithRandomBinaryFiles.zip_random_open_test	sq+..._Q[
1
1	2UHF##
/x/ (

ga.>.> ? ?I$OOI...	/	
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/xx))HS]]C	NN;;;Xty111	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2s6D
>B	DB	DB	A(DDDc`t|D]}|||jdSr rrs  r(rz3AbstractTestsWithRandomBinaryFiles.test_random_open	rr4N)r
rrrr<rFrrXrrrrrrrer4r(rr{	s77[7
   
(((DDD///333:444222";;;;;r4rceZdZejZdS) StoredTestsWithRandomBinaryFilesNr2rer4r(rr	s$KKKr4rceZdZejZdS)!DeflateTestsWithRandomBinaryFilesNrrer4r(rr	rr4rceZdZejZdS)Bzip2TestsWithRandomBinaryFilesNrsrer4r(rr	rur4rceZdZejZdS)LzmaTestsWithRandomBinaryFilesNrxrer4r(rr	rzr4rc&eZdZdZdZdZdZdS)Tellablec"||_d|_dSNr)rEoffsetrCs  r(__init__zTellable.__init__	sr4cZ|j|}|xj|z
c_|Sr )rErBr)rDr9ns   r(rBzTellable.write	s*GMM$qr4c|jSr )rrs r(rz
Tellable.tell	s
{r4c8|jdSr rEflushrs r(rzTellable.flush	

r4N)r
rrrrBrrrer4r(rr	sP
r4rc eZdZdZdZdZdS)rc||_dSr )rErCs  r(rzUnseekable.__init__	s
r4c6|j|Sr )rErBrs  r(rBzUnseekable.write	sw}}T"""r4c8|jdSr rrs r(rzUnseekable.flush
rr4N)r
rrrrBrrer4r(rr	sA###r4rc eZdZdZdZdZdS)UnseekableTestsc	dttfD]}||5tj}|dtj|}tj||dtj	5}|
dd|
dddddn#1swxYwY||dd	d
tj|d5}|
d5}||ddddn#1swxYwY|
d5}||ddddn#1swxYwYdddn#1swxYwYdddn#1swxYwYdS)
Nc|Sr rer's r(rgz/UnseekableTests.test_writestr.<locals>.<lambda>
!r4wrapperabcrLones111twos222r\abcPKrZrP)rrsubTestr$r%rBBufferedWriterrRrSrrTrirmrArj)rDrr'bfrVrzopens       r(
test_writestrzUnseekableTests.test_writestr
s#h
:
	?
	?Gg..
?
?JLL&q))_WWR[[#w7IJJ3eNN66222NN66222333333333333333  bqb!18<<<_QS111?T6**?e((v>>>???????????????6**?e((v>>>??????????????????????????????
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
	?
	?sA&G(-C	=G(	C

G(C
A	G(G0)E%	G%E)
)G,E)
-G)F:	.G:F>
>GF>
GG(GG(GG((G,	/G,	c	JdttfD]}||5tj}|dtj|}tj||dtj	5}|
ttttd5}|ddddn#1swxYwY|tdttd5}|ddddn#1swxYwY|td	dddn#1swxYwY||dd
dtj|d
5}|
d5}||ddddn#1swxYwY|
d	5}||ddddn#1swxYwYdddn#1swxYwYdddn#1swxYwYdS)Nc|Sr rers r(rgz,UnseekableTests.test_write.<locals>.<lambda>
rr4rrrLr?rrrrr\rrZrP)rrrr$r%rBrrRrSr
addCleanuprrrArirmrj)rDrr'rrVf2rrs        r(
test_writezUnseekableTests.test_write
s#h
:	?	?Gg..
?
?JLL&q))_WWR[[#w7IJJ0eOOFF333fd++)r((()))))))))))))))KK///fd++)r((()))))))))))))))KK///000000000000000  bqb!18<<<_QS111?T6**?e((v>>>???????????????6**?e((v>>>??????????????????????????????
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?	?	?sA&J6E7C(	E7(C,
,E7/C,
03E7#E	9E7E	
	E7E	

E7+J7E;;J>E;?A	JI?)H	I?H
I?H
I?3)I(	I?(I,
,I?/I,
0I?3J?JJJJJ	J	c	dttfD]}||5tj}|dtj|}tj||dtj	5}|
dd5}|ddddn#1swxYwY|
dd5}|ddddn#1swxYwYdddn#1swxYwY||dd	d
tj|5}||
dd||
dddddn#1swxYwYdddn#1swxYwYdS)Nc|Sr rers r(rgz1UnseekableTests.test_open_write.<locals>.<lambda>,
rr4rrrLrrrrr\r)rrrr$r%rBrrRrSrrArirmrj)rDrr'rrrs      r(test_open_writezUnseekableTests.test_open_write+
s
#h
:
	@
	@Gg..
@
@JLL&q))_WWR[[#w7IJJ,d63//,5F+++,,,,,,,,,,,,,,,63//,5F+++,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
  bqb!18<<<_Q''@4$$TYYv%6%6???$$TYYv%6%6???@@@@@@@@@@@@@@@
@
@
@
@
@
@
@
@
@
@
@
@
@
@
@
	@
	@sA&G(D#'C		=D#	C


D#C

D#*D	D#D
D#D
D#G(#D''G(*D'+AG(2AGG(GG(GG((G,	/G,	N)r
rrrrrrer4r(rr
sF??? ???*@@@@@r4rc`eZdZedZdZdZdZdZdZ	dZ
dZd	Zd
Z
dZdS)
TestsWithMultipleOpenscbdtdz|_dtdz|_dS)Nr'r)rdata1rr:s r(r<z!TestsWithMultipleOpens.setUpClass>
s.Yu---	Yu---			r4ctj|dtj5}|d|j|d|jddddS#1swxYwYdS)NrLrr)rRrSrmrTrr)rDr'rVs   r(rXz(TestsWithMultipleOpens.make_test_archiveC
s
_QW%9
:
:	/eNN64:...NN64:...	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/	/s7A%%A),A)c	zt|D])}||tj|d5}|d5}|d5}|d}|d}||z
}||z
}dddn#1swxYwYdddn#1swxYwY||||||jdddn#1swxYwY+dS)NrZrPr)r)rXrRrSrArjrirrDr'rzopen1zopen2rrs       r(test_same_filez%TestsWithMultipleOpens.test_same_fileI
s4		4		4A""1%%%---
4YYv&&+&$))F2C2C+v"KK,,E"KK,,EV[[]]*EV[[]]*E	++++++++++++++++++++++++++++++
  ...  
333
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4		4		4sZD.C&*AC	C&C
C&C
C&D.&C**D.-C*.4D..D2	5D2	c	t|D].}||tj|d5}|d5}|d5}|d}|d}||z
}||z
}dddn#1swxYwYdddn#1swxYwY|||j|||jdddn#1swxYwY0dS)NrZrPrrr	r)rXrRrSrArjrirrrs       r(test_different_filez*TestsWithMultipleOpens.test_different_fileW
s4		4		4A""1%%%---
4YYv&&+&$))F2C2C+v"KK,,E"KK,,EV[[]]*EV[[]]*E	++++++++++++++++++++++++++++++
  
333  
333
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4		4		4sZD3C&*AC	C&C
C&C
C&D3&C**D3-C*.9D33D7	:D7	c	t|D].}||tj|d5}|d5}|d}|d5}|d}||z
}||z
}dddn#1swxYwYdddn#1swxYwY|||j|||jdddn#1swxYwY0dS)NrZrPrrrr)rDr'rrrrrs       r(test_interleavedz'TestsWithMultipleOpens.test_interleavede
s4
	4
	4A""1%%%---
4YYv&&/&"KK,,E6**/f &C 0 0..//////////////////////////////  
333  
333
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
	4
	4sZD3+C&?AC	C&C
C&C
C&D3&C**D3-C*.9D33D7	:D7	ct|D]N}||tj5}t	j|d5}||d}||d}dddn#1swxYwY|d}|d}||z
}||z
}dddn#1swxYwY|	||j
|	||jPdS)NrZrrr)r)rX
contextlib	ExitStackrRrS
enter_contextrArjrirr)rDr'stackrrrrrs        r(test_read_after_closez,TestsWithMultipleOpens.test_read_after_closet
s4	0	0A""1%%%%''
'5_Q,,D"0061B1BCCF"0061B1BCCFDDDDDDDDDDDDDDDC((C((&&
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
UDJ///UDJ////	0	0s7DAB."D.B22D5B26ADD!	$D!	ct|D]c}tj|dtj5}|d|j|d|j|d5}|d}dddn#1swxYwYdddn#1swxYwY|	||jddtj|d5}|d}|d}dddn#1swxYwY|	||j|	||jedS)NrLrrrrZ)
r)rRrSrmrTrrrArjrirDr'rrrrs      r(test_read_after_writez,TestsWithMultipleOpens.test_read_after_write
s	4	0	0AC)=>>
-$

fdj111

fdj111YYv&&-&"KK,,E---------------
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

UDJtt$4555C((
*D		&))		&))
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
UDJ///UDJ////	0	0sHAB8?B!B8!B%%B8(B%)B88B<	?B<	;+D22D6	9D6	ct|D]@}tj|dtj5}|d|j|d5}|d|d|jdddn#1swxYwYdddn#1swxYwYtj|d5}|d}|d}dddn#1swxYwY|	||j|	||jBdS)NrLrrrrZ)
r)rRrSrmrTrrArjrrir	s      r(test_write_after_readz,TestsWithMultipleOpens.test_write_after_read
s4
	0
	0AC)=>>
6$

fdj111YYv&&6&KK$$$MM&$*555666666666666666
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
C((
*D		&))		&))
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
UDJ///UDJ////
	0
	0sG1B8$1B!B8!B%%B8(B%)B88B<	?B<	+DD	D	ct}|ttjtd5}tdD]E}|d|d5}	dddn#1swxYwYF	dddn#1swxYwY||tdS)NrZrPrr)	rrXr!rRrSr5rjrAri)rD
startcountrrrs     r(test_many_opensz&TestsWithMultipleOpens.test_many_opens
s>ZZ
w'''
_W3
/
/
/	43ZZ

		&!!!YYv&&&
															
	
XZZ00000s6<B'BB'BB'BB''B+.B+cjtjtdtj5}|d|jdddn#1swxYwYtjtdtj5}|dd5}|d}|dd5}||j	dddn#1swxYwY||z
}dddn#1swxYwYdddn#1swxYwY|
||jtjt5}|
|d|j	ddddS#1swxYwYdS)NrLrr-rZrr)rRrSr!rmrTrrArjrBrri)rDrr1rrgs     r(test_write_while_readingz/TestsWithMultipleOpens.test_write_while_reading
s
_Wc7+?
@
@	.DMM&$*---	.	.	.	.	.	.	.	.	.	.	.	.	.	.	.
_Wc7+?
@
@	#D63''
#2YYvs++)rHHTZ((()))))))))))))))"	
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#	#	#	#	#	#	#	#	#	#	#	#	#	#	#	#	

+++
_W
%
%	<TYYv..
;;;	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<s}AAA>D-,DC(D(C,,D/C,0D
D-D	D-D	D--D14D1,/F((F,/F,c.ttdSr r"rs r(rzTestsWithMultipleOpens.tearDown
r#r4N)r
rrrr<rXrrrrr
rrrrrer4r(rr<
s..[.///444444
4
4
4000000000
1
1
1<<<r4rc>eZdZdZdZdZdZdZdZdZ	dZ
d	S)
TestWithDirectoryc8tjtdSr )rUrr!rs r(rFzTestWithDirectory.setUp
s
r4c
tjtd5}|tdddn#1swxYwY|tjtj	td|tjtj	tdd|tj
tj	tddddS)N
zipdir.zipr-br)rRrSr	rr!rrrUrisdirr8rr!s  r(test_extract_dirz"TestWithDirectory.test_extract_dir
s
_Xl33
4
4	%OOG$$$	%	%	%	%	%	%	%	%	%	%	%	%	%	%	%

bgll7C&@&@AABBB

bgll7C&E&EFFGGGrw||GS#s'K'KLLMMMMMsA		A
A
ctjtjtd|dSNr-)rUrrr8r!rrs r(
test_bug_6050zTestWithDirectory.test_bug_6050
s:
gs++,,,r4c	tjtd}tj|tj|jdz}tjtd5}|
||jd}||j
d||j|dzdz|
|d|jd}||j
d	||j|dzdzdddn#1swxYwYtjtd
5}|jd}||j
d||j|dzdz|jd}||j
d	||j|dzdztjtd}tj||||tjtj|d|t'tj|dddddS#1swxYwYdS)
Nrr:rLrz/x/ryr`zy/rZrr)rUrr8r!rrast_moderRrSrrBrrrrgrQrir rrrolistdir)rDdirpathrQrr!rs      r(test_write_dirz TestWithDirectory.test_write_dir
s',,w,,
ww'&0
_VS
)
)	GTJJwM!$EOOEN33E::;;;U042:2EFFFJJw$$$M!$EOOEND111U042:2EFFF	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G_VS
)
)	9TM!$EOOEN33E::;;;U042:2EFFFM!$EOOEND111U042:2EFFFW\\'844FHVOOF###OOBGMM"',,vs*C*CDDEEESF!3!344a888	9	9	9	9	9	9	9	9	9	9	9	9	9	9	9	9	9	9s&0CEEE1E8K66K:=K:c	(tjtjtdtjtd5}|dd|j	d}|
|jd|
|jddddn#1swxYwYtjtd5}|j	d}|
|jd|
|jdtjtd}tj||||
tjtj|d|
tj|dgddddS#1swxYwYdS)	NrrLzx/r4riArZr)rUrrr8r!rRrSrrTrrirgr rrrQrrr")rDrr!rs    r(test_writestr_dirz#TestWithDirectory.test_writestr_dir
s.
gs++,,,
_VS
)
)	JTMM$$$$M!$EU^T222U02HIII		J	J	J	J	J	J	J	J	J	J	J	J	J	J	J
_VS
)
)	8TM!$EOOEN33D99:::U02HIIIW\\'844FHVOOF###OOBGMM"',,vs*C*CDDEEERZ//#777	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8s&AB88B<?B<DHHHctjtd5}|d|jd}||jd||jd|d|jd}||jd||jd|dd	
|jd}||jd||jdtjd
}d|_d|_	d|_
d|_|||jd}||jd
||j|jtj
td}tj||||t#tj|hdddddS#1swxYwYdS)NrLr{r
directory/iAdirectory2/r`
directory3irPrzdirectory3/zdirectory4/rr>r{
directory2r*
directory4)rRrSrrrrirgr r	CRCrxrrUrr8r!rsetr")rDrr!	old_zinfo	new_zinfors      r(
test_mkdirzTestWithDirectory.test_mkdir
s_
_VS
)
)	oRHH[!!!KNEU^\:::U02HIIIHH]###KNEU^];;;U02HIIIHH\H...KNEU^];;;U02HIII
66I&<I#IM"#I&'I#HHYAIY/???Y4i6MNNNW\\'844FHVMM&!!!SF!3!3446m6m6mnnn;	o	o	o	o	o	o	o	o	o	o	o	o	o	o	o	o	o	osHII	I	cztjtd5}|tjdd|jd}||jdtj	
td}tj|tj
|j}||d|jd}||jd||j|d	zd	ztj	
td
}tj||||t%tj|ddhddddS#1swxYwYdS)NrLr(r8rr+r))rr`rrr{)rRrSrrTr	rrirgrUrr8r!rrar!rBr rr.r")rDrr!r{rQrs      r( test_create_directory_with_writez2TestWithDirectory.test_create_directory_with_writes
_VS
)
)	SRKK55r:::KNEU^\:::Wl;;IHY79%%-DHHY
H666KNEU^];;;U042:2EFFFW\\'844FHVMM&!!!SF!3!344{L6QRRR%	S	S	S	S	S	S	S	S	S	S	S	S	S	S	S	S	S	SsFF00F47F4ctttjt
rt
t
dSdSr )rr!rUrrrrrs r(rzTestWithDirectory.tearDown*s<w
7>>&!!	6NNNNN		r4N)r
rrrFrrr$r&r1r3rrer4r(rr
sNNN   
9994888"ooo@SSS*r4rc,eZdZdZdZdZdZdZdS)ZipInfoTestscptjt}|tj|jd||	||j
tj
tdSNztest_zipfile.py)rRr		from_filerOri	posixpathrYrgr"is_dirrxrUrr;rPs  r(test_from_filezZipInfoTests.test_from_file1s
_
&
&x
0
0+BK88:KLLL%%%rwx'@'@AAAAAr4ctjtjt
}|tj|j	d|
|||jtjt
dSr8)rRr	r9rrrOrir:rYrgr"r;rxrUrr;rPs  r(test_from_file_pathlikez$ZipInfoTests.test_from_file_pathlike7s
_
&
&w|H'='=
>
>+BK88:KLLL%%%rwx'@'@AAAAAr4ctjtjt
d}|tj|j	d|
|||jtj
t
dS)Nr&)rRr	r9rUfsencoderOrir:rYrgr"r;rxrr;rPs  r(test_from_file_bytesz!ZipInfoTests.test_from_file_bytes=s
_
&
&r{8'<'<f
E
E+BK88&AAA%%%rwx'@'@AAAAAr4cttd5}tj|d}|tj|j	d|
|||jtjtddddS#1swxYwYdS)Nr1r&)rArOrRr	r9filenorir:rYrgr"r;rxrUrr;)rDr'rs   r(test_from_file_filenoz"ZipInfoTests.test_from_file_filenoCs

(D
!
!	FQ**188::v>>BY/<<fEEERYY[[)))R\27??8+D+DEEE		F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	FsCC''C+.C+ctjtjt}t
j|d}||j	d|
|||jt
j
||jddS)Nstdlib_testsz
stdlib_tests/r)rUrrNabspathrOrRr	r9rirgrrr;rrrx)rDr#rs   r(
test_from_dirzZipInfoTests.test_from_dirJs'//"'//(";";<<
_
&
&w
?
?o666		$$$)7+=>>>q)))))r4N)r
rrr<r>rArDrHrer4r(r6r60skBBBBBBBBBFFF*****r4r6cXeZdZdZdZdZdZdZedZ	dZ
dS)	CommandLineTestctjddg|Ri|\}}}|tjdS)N-mrRr)rrrrUlinesepr)rDargsrUrcouterrs      r(
zipfilecmdzCommandLineTest.zipfilecmdUs_$5dI@@@@8>@@C{{2:,,..666r4c(tjddg|RS)NrLrR)rassert_python_failure)rDrNs  r(zipfilecmd_failurez"CommandLineTest.zipfilecmd_failureZs24JTJJJJr4c|\}}}||d|d||d||d||dd\}}}||d||ddS)Nr4susageserrorsrequired-lr8)rUrirprassertNotEqualstrip)rDrOrPrQs    r(test_bad_usezCommandLineTest.test_bad_use]s..00Cc"""

h		,,,

h		,,,

k399;;///..tR88Cc"""CIIKK-----r4c(td}dD]@}|||}||dAtd}|d|\}}}||ddS)Nr)-tz--testsDone testingztesttar.tarr\r4)r	rRrirstriprU)rDzip_nameoptrPrOrQs      r(test_test_commandz!CommandLineTest.test_test_commandgsL))!	<	<C//#x00CSZZ\\?;;;;M**..tX>>Cc"""""r4ctd}tj}tj|d5}||dddn#1swxYwY|dd}dD]0}|||d}|	||1dS)NrrZr.backslashreplace)rWz--listzascii:backslashreplace)PYTHONIOENCODING)
r	r$rkrRrSrlrmrrRri)rDr^r[tfexpectedr_rPs       r(test_list_commandz!CommandLineTest.test_list_commandpsL))KMM
_Xs
+
+	rKKNNN															::<<&&w0BCC!	,	,C//#x3K"MMCS(++++	,	,sAA!Ac~|ttttdd5}|ddddn#1swxYwYtjt|tttt
j	
tddd5}|ddddn#1swxYwYttg}ttdztdzg}d	D]}	|j|tg|R}|
|d
tjt5}|
|||
||dd|
||d
ddddn#1swxYwYtt#ttwxYwdS)NrLr;r<ztest 1file.txtztest 2rMz	/file.txt)-cz--creater4rstest 1rstest 2)rrrrArBrUr	TESTFNDIRrrr8rRr!rirRrSrvrj)rDr'filesrvr_rPrs       r(test_create_commandz#CommandLineTest.test_create_command{s'''
&#
0
0
0	A
GGH															
	***
"',,y*55sW
M
M
M	QR
GGH															#IOY-DE#		 		 C
 %doc7;U;;;  c***_W--F$$R[[]]H===$$RWWXa[%9%99EEE$$RWWXa[%9%99EEEFFFFFFFFFFFFFFF
ww		 		 sUAA!AC55C9<C9.AH$1BH8H$H	H$H	H$$H:ctd}dD]}t5}||||}||dt	j|5}|D]"}tj	||j
dtj}|
r3|tj||tj|t#|d5}||||dddn#1swxYwY$	dddn#1swxYwYdddn#1swxYwYdS)Nr)-ez	--extractr4rMr1)r	rrRrirRrSrwrUrr8rgrrRr;rrrrrArj)	rDr^r_rrPrrrr's	         r(test_extract_commandz$CommandLineTest.test_extract_commandstL))$
	H
	HC
Hvooc8V<<  c***_X..	H" kkmmHH!w||F$&K$7$7RV$D$D F F99;;H OOBGMM$,?,?@@@@ OOBGNN4,@,@AAA!%dD!1!1HQ $ 0 02772;; G G GHHHHHHHHHHHHHHHH	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H
H
H
H
H
H
H
H
H
H
H
H
H
H
H
H
	H
	Hs[AG%C$F+	<FF+FF+FF+G+F//G2F/3GG		G	N)r
rrrRrUrZr`rfr
rlrorer4r(rJrJSs777
KKK...###	,	,	,]__  _ *HHHHHr4rJceZdZdZdZdZdZdZej	e
jdej	ej
dejded	Zej	e
jdej	ej
dejded
ZdS)TestExecutablePrependedZipz@Test our ability to open zip files with an executable prepended.c^tdd|_tdd|_dS)Nexe_with_zipziptestdata)rexe_with_z64)r	exe_zip	exe_zip64rs r(rFz TestExecutablePrependedZip.setUps.}EEE!.GGGr4c<|tj|d|tj|5}|D]-}||}|d|.	ddddS#1swxYwYdS)Nzis_zipfile failed on sFAVORITE_NUMBER)rrrRrrSrvrjrp)rDr=rVrr9s     r(_test_zip_worksz*TestExecutablePrependedZip._test_zip_workss*400666	8	8	8_T
"
"	8e^^%%
8
8zz!}}

0$7777
8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8sABBBc:||jdSr )ryrvrs r( test_read_zip_with_exe_prependedz;TestExecutablePrependedZip.test_read_zip_with_exe_prependedsT\*****r4c:||jdSr )ryrwrs r("test_read_zip64_with_exe_prependedz=TestExecutablePrependedZip.test_read_zip64_with_exe_prependedsT^,,,,,r4zsys.executable required.z	/bin/bashz#Test relies on #!/bin/bash working.c|tj|jtjg}|d|dSNsnumber in executable: 5)
subprocesscheck_outputrvsys
executablerprDoutputs  r(test_execute_zip2z,TestExecutablePrependedZip.test_execute_zip2s8
($,)GHH

0&99999r4c|tj|jtjg}|d|dSr)rrrwrrrprs  r(test_execute_zip64z-TestExecutablePrependedZip.test_execute_zip64s8
($.#.)IJJ

0&99999r4N)r
rrrrFryr{r}r
skipUnlessrrrUrAX_OKrrrrer4r(rqrqsIJJHHH888+++---X)CDDX;88>@@::@@ED:X)CDDX;88>@@::@@ED:::r4rqc(eZdZGddZdS)jaracoc(eZdZGddZdS)jaraco.itertoolsc eZdZdZdZdZdS)jaraco.itertools.Counterc<d|_t||_dSr)riter
_orig_iter)rDr2s  r(rz!jaraco.itertools.Counter.__init__s
"&q''r4c|Sr rers r(__iter__z!jaraco.itertools.Counter.__iter__sr4cNt|j}|xjdz
c_|Sr)nextrr)rDresults  r(__next__z!jaraco.itertools.Counter.__next__s%do..

a


r4N)r
rrrrrrer4r(CounterrsA
*
*
*







r4rN)r
rrrrer4r(rrs<										r4rN)r
rrrrer4r(rrs<r4rctj|D]}||d|S)z}
    Given a writable zip file zf, inject directory entries for
    any directories implied by the presence of children.
    r4)rRCompleteDirs
_implied_dirsrvrT)rr=s  r(add_dirsrsH
$222;;==AA
D#
Ir4c@tj}tj|d}|dd|dd|dd|dd	|d
dd|_|S)
u:
    Create a zip file with this structure:

    .
    ├── a.txt
    ├── b
    │   ├── c.txt
    │   ├── d
    │   │   └── e.txt
    │   └── f.txt
    └── g
        └── h
            └── i.txt

    This fixture has the following key characteristics:

    - a file at the root (a)
    - a file two levels deep (b/d/e)
    - multiple files in a directory (b/c, b/f)
    - a directory containing only a directory (g/h)

    "alpha" because it uses alphabet
    "rep" because it's a representative example
    rLrscontent of azb/c.txtscontent of cz	b/d/e.txtscontent of ezb/f.txtscontent of fz	g/h/i.txtscontent of izalpharep.zip)r$r%rRrSrTrg)r9rs  r(build_alpharep_fixturers2:<<D	s	#	#BKK)))KK	?+++KK_---KK	?+++KK_--- BK
Ir4cFtjfd}|S)zZ
    Given a method, wrap it in a for loop that invokes method
    with each subtest.
    cP|D]}||dS)N)alpharep)zipfile_alpharep)rDrmeths  r(rzpass_alpharep.<locals>.wrappers@--//	*	*HD)))))	*	*r4)	functoolswraps)rrs` r(
pass_alphareprs:_T*****Nr4ceZdZdZdZdZedZedZedZ	edZ
edZd	Zd
Z
dZdZd
ZedZdZedZedZedZedZedZedZedZedZedZedZedZdZdZdZ dZ!edZ"ed Z#ed!Z$ed"Z%ed#Z&ed$Z'ed%Z(ed&Z)ed'Z*ed(Z+ed)Z,ed*Z-d+S),TestPathcttj|_||jjdSr )rrfixturesrrIrs r(rFzTestPath.setUps/",..

+,,,,,r4c#K|5tVdddn#1swxYwY|5ttVddddS#1swxYwYdSr )rrrrs r(rzTestPath.zipfile_alpharep!s
\\^^	+	+(*****	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+
\\^^	5	513344444	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5	5s488A>>BBchtj|jt	}|j}|||jz}|d5}|	|
dddn#1swxYwY|Sr>)rrrrrrErIrgrArBrm)rDrtmpdirrrstrms      r(zipfile_ondiskzTestPath.zipfile_ondisk'sdm99(**EEFF))
YYt__	*JJv(()))	*	*	*	*	*	*	*	*	*	*	*	*	*	*	*s3(B''B+.B+ctj|}|\}}}|\}}}|\}	|\}
|
\}dSr )rRriterdir)rDrrootr-rgrr'rrhr2s            r(test_iterdir_and_typeszTestPath.test_iterdir_and_types0sj|H%%,,..1a))++1ayy{{yy{{yy{{r4c.tj|}dSr rRrrDrrs   r(test_is_file_missingzTestPath.test_is_file_missing@|H%%r4ctj|}|\}}}|t5|ddddS#1swxYwYdSr )rRrrrrJrDrrr-rrs      r(test_iterdir_on_filezTestPath.test_iterdir_on_fileEs|H%%,,..1a


z
*
*		
IIKKK																		sA))A-0A-c.tj|}dSr rrs   r(test_subdir_is_dirzTestPath.test_subdir_is_dirLrr4ctj|}|\}}}|d5}|}dddn#1swxYwY||d|dd5}|}dddn#1swxYwY||ddS)Nr;r<zcontent of arZ)rRrrrArjri)rDrrr-rrrr9s        r(rzTestPath.test_openTs<|H%%,,..1a
VVWV
%
%	99;;D															~...
VVC
!
!	T99;;D															~.....s$A$$A(+A(B<<CCctj}tj|d}|dddd|_tj|}|\}|	d}|
dd5}|}dddn#1swxYwY||d|
d5}|}dddn#1swxYwY||ddS)	NrLzpath/16.txtzThis was utf-16zutf-16ztest_open_utf16.zipz16.txtrZr<)
r$r%rRrSrTrrgrrjoinpathrArjri)rDin_memory_filerrru16rr9s        r(test_open_encoding_utf16z!TestPath.test_open_encoding_utf16_s
_^S
1
1
M#4#;#;H#E#EFFF+|B,,..mmH%%
XXc8
$
$	99;;D															0111
XXxX
(
(	D99;;D															011111s$.CCCD''D+.D+ctj}tj|d}|ddd|_tj|}|\}|d}|	dd}|
|d	|d
dd5}|
|ddddn#1swxYwY|
td
5|	dd}dddn#1swxYwY|d
dd5}|t 5|dddn#1swxYwYddddS#1swxYwYdS)NrLzpath/bad-utf8.binsinvalid utf-8: .z"test_read_text_encoding_errors.zipzbad-utf8.binr;ignore)errorszinvalid utf-8: .rZsurrogateescapeuinvalid utf-8: .r=r<strict)r=r)r$r%rRrSrTrgrrr	read_textrirArjrrArUnicodeDecodeError)rDrrrrrr9r's        r(test_open_encoding_errorsz"TestPath.test_open_encoding_errorsns
_^S
1
1
')DEEE:|B,,..mmN++}}WX}661222
XXc7+<X
=
=	GQVVXX'EFFF	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G
#
#Iz
:
:	<	<==7=;;D	<	<	<	<	<	<	<	<	<	<	<	<	<	<	<XXcGHX
=
=	""#566
















																		sZ
)C??DD%E		E
E
,GF(G(F,	,G/F,	0GGGc"d}tddd|}|j}|t	|d|j||dd||dd	d
S)z8EncodingWarning must blame the read_text and open calls.aimport io, zipfile
with zipfile.ZipFile(io.BytesIO(), "w") as zf:
    zf.filename = '<test_encoding_warnings in memory zip file>'
    zf.writestr("path/file.txt", b"Spanish Inquisition")
    root = zipfile.Path(zf)
    (path,) = root.iterdir()
    file_path = path.joinpath("file.txt")
    unused = file_path.read_text()  # should warn
    file_path.open("r").close()  # should warn
z-Xwarn_default_encodingrirrs^<string>:8: EncodingWarning:r`s^<string>:9: EncodingWarning:N)rrQrnriroassertRegex)rDcodeprocwarningss    r(test_encoding_warningszTestPath.test_encoding_warningss
 &=tTJJ8&&((X48444!&GHHH!&GHHHHHr4ctjtjtjd}|dd5}|ddddn#1swxYwY|ddd	5}|d
ddddS#1swxYwYdS)zo
        If the zipfile is open for write, it should be possible to
        write bytes or text to it.
        rLrPzfile.binr?sbinary contentsNrhr;r<z	text file)rRrrSr$r%rrArB)rDrrs   r(rzTestPath.test_open_writesE
\'/"*,,SAAA
B
B
[[
$
$
)
)$
/
/	+4JJ)***	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+
[[
$
$
)
)#
)
@
@	$DJJ{###	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$s$"BBB9CC #C ctjtt}|t
5|dddddS#1swxYwYdS)zJ
        Attempting to open a directory raises IsADirectoryError.
        rN)rRrrrrIsADirectoryErrorrrArs  r(test_open_extant_directoryz#TestPath.test_open_extant_directory\(#9#;#;<<
=
=


0
1
1	$	$KK!!###	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$	$(A==BBctj|}|t5|ddddddn#1swxYwY|t5|dddddddS#1swxYwYdS)Nrr1r;r<)rRrrrJrrArs   r(test_open_binary_invalid_argsz&TestPath.test_open_binary_invalid_argssJ|H%%


z
*
*	@	@MM'""''w'???	@	@	@	@	@	@	@	@	@	@	@	@	@	@	@


z
*
*	7	7MM'""''g666	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7	7s#+A&&A*-A**CC	Cctjtt}|t
5|dddddS#1swxYwYdS)zR
        Attempting to open a missing directory raises FileNotFoundError.
        rN)rRrrrrFileNotFoundErrorrrArs  r(test_open_missing_directoryz$TestPath.test_open_missing_directoryrrctj|}|\}}}|ddS)Nr;)rRrrrrs      r(rzTestPath.test_reads<|H%%,,..1a	Gr4ctj|}|d}|ddd}dSNrrre.txtrRrrrDrrr-rs     r(
test_joinpathzTestPath.test_joinpathsS|H%%MM'""MM#'',,55g>>r4c\tj|}|ddd}dS)Nrrrr)rDrrrs    r(test_joinpath_multiplezTestPath.test_joinpath_multiples*|H%%MM#sG,,r4cNtj|}|dz}|dzdzdz}dSrrrs     r(test_traverse_truedivzTestPath.test_traverse_truedivs1|H%%7N3Jw&r4cJtdddd}t|dS)zI
        Disable the __future__.division when testing traversal.
        zzipfile.Path(alpharep) / 'a'z(test)evalT)sourcergrQdont_inheritN)compiler)rDrrs   r(test_traverse_simpledivz TestPath.test_traverse_simpledivs5
1	


	
T




r4c||}tjt|}t	j|dS)zN
        zipfile.Path should be constructable from a path-like object
        N)rrrrurR)rDrrpathlikes    r(test_pathlike_constructionz#TestPath.test_pathlike_constructionsD
,,X66<N 3 344Xr4c\tj|}|tjdzdSr)rRrrrs   r(test_traverse_pathlikezTestPath.test_traverse_pathlikes,|H%%w|C      r4c.tj|}dSr rrs   r(test_parentzTestPath.test_parentrr4c.tj|}dSr rrs   r(test_dir_parentzTestPath.test_dir_parentrr4c.tj|}dSr rrs   r(test_missing_dir_parentz TestPath.test_missing_dir_parent
rr4ctj|}|\}}}|dd|dd|dz\}dS)zk
        If the underlying zipfile is changed, the Path object should
        reflect that change.
        rrzbar/baz.txtrbrN)rRrrrT)rDrrr-rrrbs       r(test_mutabilityzTestPath.test_mutability
so|H%%,,..1a)U+++-///,''))r4i ctj}tj|d}t	t
t
|jD]}|||d|_	|S)zACreate a read-only zipfile with a huge number of entries entries.rLrZ)
r$r%rRrSmaprur5HUGE_ZIPFILE_NUM_ENTRIESrTrQ)rDrrentrys    r(huge_zipfilezTestPath.huge_zipfile
sez||
_T3
'
'eD$ABBCC	&	&EKKu%%%%	r4ctj|}tj|}|D]}|ddS)zE
        Ensure joinpath on items in zipfile is linear time.
        suffixN)rRrrrrrrr)rDrentriesrs    r(test_joinpath_constant_timez$TestPath.test_joinpath_constant_time!
sk|D--//00"**4<<>>::	%	%ENN8$$$$	%	%r4cvdtdD}tj|dS)Nclg|]1}dtjt|z2S)rM)r8stringascii_lowercaseru)r1rs  r(r3z:TestPath.test_implied_dirs_performance.<locals>.<listcomp>.
s2PPPa/#a&&899PPPr4r)r5rRrrrs  r(test_implied_dirs_performancez&TestPath.test_implied_dirs_performance-
s8PP5<<PPP**400000r4c||}tj|5}tdD]+}tj|dd,	ddddS#1swxYwYdS)Nrrr;r<)rrRrSr5rr)rDrr[reps    r(test_read_does_not_closez!TestPath.test_read_does_not_close1
s&&x00
_X
&
&	H$Qxx
H
HT7++55w5GGGG
H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	Hs<A44A8;A8cLGddtj}||}dS)NceZdZdS)(TestPath.test_subclass.<locals>.SubclassN)r
rrrer4r(Subclassr:
sDr4rr)rDrrrs    r(
test_subclasszTestPath.test_subclass8
sC					w|			x!!r4c.tj|}dSr rrs   r(
test_filenamezTestPath.test_filename@
rr4c.tj|}dS)zH
        The name of the root should be the name of the zipfile
        Nrrs   r(test_root_namezTestPath.test_root_nameE
s
|H%%r4cRtj|}|dz}|dzdz}|dz}dS)
        The suffix of the root should be the suffix of the zipfile.
        The suffix of each nested file is the final component's last suffix, if any.
        Includes the leading period, just like pathlib.Path.
        rrfilename.tar.gzrNrrDrrrrrs      r(test_suffixzTestPath.test_suffixM
s>|H%%
7N
3J**
3Jr4c\tj|}|dz}|dzdz}|dz}|dz}dS)rrrrrz.hgrcNr)rDrrrrrrs       r(
test_suffixeszTestPath.test_suffixes`
sI|H%%
7N
3J**
3J
7Nr4c<d|_tj|}dSr )rgrRrrs   r(test_suffix_no_filenamez TestPath.test_suffix_no_filenamev
s |H%%r4cRtj|}|dz}|dzdz}|dz}dS)z>
        The final path component, without its suffix
        rrrrNrrs      r(	test_stemzTestPath.test_stem}
s>
|H%%
7N
3J**
3Jr4cFtj|}d|j_dS)Nzfoo/bar.zip)rRrrrgrs   r(test_root_parentzTestPath.test_root_parent
s!|H%%*	r4c*d|_tj|}|t5|jdddn#1swxYwY|t5|jdddn#1swxYwY|dz}dS)zd
        It is an error to attempt to get the name
        or parent of an unnamed zipfile.
        Nr)rgrRrrrAr=parent)rDrrsubs    r(test_root_unnamedzTestPath.test_root_unnamed
s
!|H%%


y
)
)		II															


y
)
)		KK															Sjs#A

AA/BB
Bctdtjfi}|D]%}||dj}&dS)N	PathChildzsome dir)typerRrrrr()rDrr;r[s    r(test_inheritancezTestPath.test_inheritance
s\;44--//	)	)H3x==))*55<DD	)	)r4c||}tj|}tj|||jdS)zU
        A zip file wrapped in a Path should extract even with implied dirs.
        N)rrRrSrrr()rDrsource_pathrs    r(#test_extract_orig_with_implied_dirsz,TestPath.test_extract_orig_with_implied_dirs
sQ
))(33
_[
)
)R


k()))))r4N).r
rrrFrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
rrrrrr r"r$r&r*r.r1rer4r(rrs---555

]
::]:]&&]&//]/
2
2
22III&	$	$	$$$$77]7$$$11]1??]???]?
??]?

]
]!!]!44]4
--]-
77]788]8 '	>	>	>111HH]H00]0==]=AA]A]$  ] *77]7::]:$22]2]"))])**]***r4rceZdZgdZddddddgZdZd	Zd
ZdZ	dZ
d
ZdZdZ
dZdZdS)EncodedMetadataTests)u一u二u三zThis is pure ASCII.
r.u%これは現代的日本語です。
r;u"これは古い日本語です。
	shift_jisc|ttddg|jddz}t	jtd5}t
||jD]&\}}|||tj	'	dddn#1swxYwYttd5}|}dddn#1swxYwYt
|j|ddD]A\}}||
d|
d}Bttd	5}||ddddS#1swxYwYdS)
Nn1n2rrLrPr1r.r4r?)rrr
file_namesrRrSrfile_contentrTrrArjrrrB)rDplaceholdersrdtemprr9r=s       r(rFzEncodedMetadataTests.setUp
s$'''d|doabb&99
_V#
.
.
.	?"!$\43D!E!E
?
?
gD'7+=>>>>
?	?	?	?	?	?	?	?	?	?	?	?	?	?	?	?&$

	27799D															do|BQB/?@@	:	:JD$<<G 4 4 $K 8 8::DD
&$

	2HHTNNN																		s6=BB!B:CC"CE==FFc\|}|t|t||}d|D}|t|t|t	||D]\}}||}||j|||jt|||	||dS)Ncg|]	}|j
Srerf)r1rs  r(r3z3EncodedMetadataTests._test_read.<locals>.<listcomp>
s------r4)
rvrisortedrwrryrgrxrorj)	rDrVexpected_namesrrrr=rrs	         r(
_test_readzEncodedMetadataTests._test_read
s  ~(>(>???  --u---~(>(>???!1ABB	8	8MD'==&&DT]D111T^S\\:::UZZ--w7777		8	8r4ctjtdd5}|||j|jddddS#1swxYwYdS)NrZr4metadata_encoding)rRrSrr@r8r9r*s  r( test_read_with_metadata_encodingz5EncodedMetadataTests.test_read_with_metadata_encoding
s
_VSK
H
H
H	GEOOE4?D4EFFF	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	Gs"AAAcd|jddD|jddz}tjtd5}||||jddddS#1swxYwYdS)Nc^g|]*}|dd+Sr4cp437rrr1r=s  r(r3zLEncodedMetadataTests.test_read_without_metadata_encoding.<locals>.<listcomp>
B;;;"++k2299'BB;;;r4rrZr8rRrSrr@r9rDr?rVs   r(#test_read_without_metadata_encodingz8EncodedMetadataTests.test_read_without_metadata_encoding
s;;&*obqb&9;;;=A_QRR=PQ
_VS
)
)	FUOOE>43DEEE	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	FsA..A25A2cd|jddD|jddz}tjtdd5}||||jddddS#1swxYwYdS)Nc^g|]*}|dd+S)r4koi8-urIrJs  r(r3zSEncodedMetadataTests.test_read_with_incorrect_metadata_encoding.<locals>.<listcomp>
sB;;;"++k2299(CC;;;r4rrZrQrBrLrMs   r(*test_read_with_incorrect_metadata_encodingz?EncodedMetadataTests.test_read_with_incorrect_metadata_encoding
s;;&*obqb&9;;;=A_QRR=PQ
_VSH
E
E
E	FOOE>43DEEE	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F	FsA00A47A4c@|t5tjtdddddn#1swxYwY|t5tjtddddddS#1swxYwYdS)NrZr.rBr;)rrrRrSrrs r(+test_read_with_unsuitable_metadata_encodingz@EncodedMetadataTests.test_read_with_unsuitable_metadata_encoding
s:

1
2
2	D	DOFC7CCCC	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D


1
2
2	D	DOFC7CCCC	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	D	Ds#AAA)BBBc(d}d|jddD|jddz}||g|jdR}tjt
d5}||d|t|	t|dddn#1swxYwYtjt
d5}|
|||dddn#1swxYwYtjt
dd	5}|t|	t|tt||D]\}\}}|
|}||j|||jt!||dkrM|tj5||dddn#1swxYwY||||	ddddS#1swxYwYdS)
Nu四c^g|]*}|dd+SrGrIrJs  r(r3z?EncodedMetadataTests.test_read_after_append.<locals>.<listcomp>rKr4rs
newcontentr-
newcontentrZr4rB)r8rr9rRrSrrTrir>rvr@	enumeraterryrgrxrorrrj)	rDnewnamer?rrVr2r=rrs	         r(test_read_after_appendz+EncodedMetadataTests.test_read_after_appends;;&*obqb&9;;;=A_QRR=PQg&&&>T.>
>>
_VS
)
)	OUNN7L111VENN$4$455vn7M7MNNN	O	O	O	O	O	O	O	O	O	O	O	O	O	O	O_VS
)
)	EUOOE>3CDDD	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E_VSK
H
H
H
	@EVENN$4$455vn7M7MNNN&/NDT0U0U&V&V
@
@"?D'}}T**  555  W>>>q55**7+=>>))

4((()))))))))))))))$$UZZ%5%5w????
@
	@
	@
	@
	@
	@
	@
	@
	@
	@
	@
	@
	@
	@
	@
	@
	@
	@
	@s\'ACCC1DDD<C%J!I7JIJ
I.JJJctj}dD]C}|td5|d|ddddn#1swxYwYDdS)N)rLrr-z^metadata_encoding is onlyznonesuch.zipr4rB)rRrSrrJ)rDZFrQs   r(!test_write_with_metadata_encodingz6EncodedMetadataTests.test_write_with_metadata_encoding s
_#	H	HD''
(DFF
H
H>4;GGGG
H
H
H
H
H
H
H
H
H
H
H
H
H
H
H	H	HsAA	A	c.d}gd}t5}t5}|ttj|dddn#1swxYwYdddn#1swxYwY||d|||t5}t	jddtgdddn#1swxYwY|}t5}t	jddtgdddn#1swxYwY|}|j
D]}|||dS)Nz/Non-conforming encodings not supported with -c.)--metadata-encoding=shift_jisrinonesuchr`r8r_r\rW)r
rr
SystemExitrRmainrirmrprr8)rDerrmsgrNstdoutstderrlistingr=s       r(test_cli_with_metadata_encodingz4EncodedMetadataTests.test_cli_with_metadata_encoding'sBNNN


	B& ""
Bf!!*glDAAA
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B	B	B	B	B	B	B	B	B	B	B	B	B	B	B	B	
**B///

ffoo//000


	J&L94HIII	J	J	J	J	J	J	J	J	J	J	J	J	J	J	J//##


	J&L94HIII	J	J	J	J	J	J	J	J	J	J	J	J	J	J	J//##O	)	)DMM$((((	)	)sXA.'AA.A	A.A	A..A25A2DDD-EEEctjt|tt|jD]m}	tjtjt|;#t$rYGt$r|d|YjwxYwtj
ddttgtjt}|jD]}|||dS)Nzcannot encode file name r_rn)rUrr!rrr8rarr8rUnicodeEncodeErrorr`rRrbrr"rp)rDr}rfr=s    r('test_cli_with_metadata_encoding_extractz<EncodedMetadataTests.test_cli_with_metadata_encoding_extract:s
(((/	A	AB
AWb112222


%
A
A
A

???@@@@@
A	5tVWMNNN*W%%O	)	)DMM$((((	)	)s7A<<
B,!B,+B,N)r
rrr8rr9rFr@rDrNrRrTrZr]rgrjrer4r(r3r3
s///J&&w//T[[\cddNUUVabbL(888"GGG
FFFFFFDDD@@@4HHH)))&)))))r4r3c*eZdZdZdZdZdZdZdS)StripExtraTestsr`c2tjd}||jd}|dd}|dd}|dtj||jf||tj||jf||dztj|dz|jf|||ztj||z|z|jf|||ztj||z|z|jf|||ztj||z|z|jfdS)Nrrrrr4zrcStructrZIP64_EXTRArirR_strip_extrarDrr-rrs     r(test_no_datazStripExtraTests.test_no_dataTs}M%  
FF4#Q''
FF1aLL
FF1aLLg21t7G6IJJKKKG0T5E4GHHIII
dFG(4$2B1DEE	G	G	G	
1g21Q3q54;K:MNNOOO1g21Q3q54;K:MNNOOO1g21Q3q54;K:MNNOOOOOr4cDtjd}||jddz}|dddz}|dddz}|dtj||jf||tj||jf||d	ztj|d	z|jf|||ztj||z|z|jf|||ztj||z|z|jf|||ztj||z|z|jfdS)
Nrr`rrrbbrscccr4rnrorss     r(test_with_datazStripExtraTests.test_with_datacsM%  
FF4#Q''$.
FF1aLL5 
FF1aLL6!g21t7G6IJJKKKG0T5E4GHHIII
dFG(4$2B1DEE	G	G	G	
1g21Q3q54;K:MNNOOO1g21Q3q54;K:MNNOOO1g21Q3q54;K:MNNOOOOOr4ctjd}||jddz}|dddz}|dtj||z|jf|dtj||z|z|jf|dtj||zdz|jf||dztj||z|zdz|jf||tj||z|z|jf||tj||z|z|jf||tj||z|z|jfdS)Nrr`rrrrvr4rnro)rDrr-rs    r(test_multipleszStripExtraTests.test_multiplesrsM%  
FF4#Q''$.
FF1aLL5 g21Q39I8KLLMMMg21Q3q54;K:MNNOOO'&qs4x$2B1DEE	G	G	G
dFG(1Qtd6F5HII	K	K	K	
G01Q9I8KLLMMMG01Q9I8KLLMMMG01Q9I8KLLMMMMMr4c~|dtjd|jf|dtjd|jf|dtjd|jf|dtjd|jfdS)Nr4rnszzszzz)rirRrrrqrs r(test_too_shortzStripExtraTests.test_too_shortsg239I8KLLMMMw3D4;K:MNNOOO7'0@/BCC	E	E	EG($2B1DEE	G	G	G	G	Gr4N)r
rrrqrtrwryr{rer4r(rlrlMse
K
P
P
P
P
P
PNNN GGGGGr4rl__main__)ar+rimportlib.utilrUr$rrUrr:rrcrrtest.support.script_helperrrsr
unittest.mockrsrRrtempfilerrrrtest.supportrr	r
rrr
rrtest.support.os_helperrrrrrrr!rjr6
DATAFILES_DIRrr)r+TestCaserrirrrwr|rrrrr r1r4r6r8r:rrryrrrrrrrrrrrrrrrr6rJrqtupleconsumerrrrrr3rlr
rbrer4r(<module>rs}								











777777#"""""----------&&&&&&
3,SL	#
TTT
###QQQQQQQQhJJJJJ ; ( 1JJJD
H
H
H
H
H!<!)!2
H
H
H$$$$$:'0$$$#####9&/###
OOOOOOOOd\0\0\0\0\0"?"*"3\0\0\0~'''''#@#+#4'''$$$$$!>!)!2$$$##### = ( 1###
 D D D D D D D DD%%%%%+X->%%%''''',h.?'''$$$$$*H,=$$$#####)8+<###~~~~~X&~~~B}}}}}8$}}}@SSSSS"SSSl>




+X->



7
7
7
7
7,h.?
7
7
7




*H,=


&&&&&)8+<&&&qqqqqh'qqqhX;X;X;X;X;X;X;X;v%%%%%'I'/'8%%%'''''(J(0(9'''$$$$$&H&.&7$$$#####%G%-%6### 4@4@4@4@4@h'4@4@4@nzzzzzX.zzzzsssss)sssl * * * * *8$ * * *FMHMHMHMHMHh'MHMHMH`%:%:%:%:%:!2%:%:%:R







 !!!H]*]*]*]*]*x ]*]*]*@
N)N)N)N)N)8,N)N)N)b;G;G;G;G;Gh';G;G;G|zHMOOOOOr4