python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_zipapp.cpython-312.pyc

ΑejBdZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddlm
Z
GddejZGdd	ejZed
k(rej$yy)z#Test harness for the zipapp module.N)
requires_zlib)	os_helper)patchcpeZdZdZdZdZdZdZdZdZ	dZ
d	Zed
Z
dZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZej>e jBdk(de"jFdZ$ej>e jBdk(ddZ%y) 
ZipAppTestz!Test zipapp module functionality.ctj}|j|jt	j
|j|_yNtempfileTemporaryDirectory
addCleanupcleanuppathlibPathnametmpdirselfrs  D/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_zipapp.pysetUpzZipAppTest.setUp4,,.'ll6;;/c|jdz}|j|dzj|jdz}tjt|t||j
|jyNsource__main__.py
source.pyzrmkdirtouchzipappcreate_archivestr
assertTrueis_filerrtargets   rtest_create_archivezZipAppTest.test_create_archivescx'	-	&&(|+c&k3v;7()rc|jdz}|j|dzj|jdz}tj|||j|j
yr)rrr r!r"r$r%r&s   r test_create_archive_with_pathlibz+ZipAppTest.test_create_archive_with_pathlib"s[x'	-	&&(|+ff-()rc>|jdz}|j|dzj|dzj|dzj|dzdzjtj}tjt|||jdtj|d5}|jd|j|jd	|jdddy#1swYyxYw)
Nrrfoobarz__init__.pyrrzfoo/zbar/)
rrr ioBytesIOr!r"r#seekzipfileZipFileassertInnamelistrrr'zs    r test_create_archive_with_subdirsz+ZipAppTest.test_create_archive_with_subdirs+sx'	-	&&(	% 	% 	%-	'..0c&k62A
__VS
)	0QMM&!**,/MM&!**,/	0	0	0s
	ADDc.|jdz}|j|dzj|dzj|dzdzj|dzdzj|dzjtj}tjt|||jdtj|d5}|j|jgd	dddy#1swYyxYw)
Nrzed.pybinquxbazrrr.)rzbin/zbin/bazzbin/quxr:)
rrr r/r0r!r"r#r1r2r3assertEqualr5)rrr'zfs    rtest_create_sorted_archivez%ZipAppTest.test_create_sorted_archive:sx'	(	!!#	% 	%%	&&(	%%	&&(	-	&&(c&k62A
__VS
)	IRR[[]G
I	I	I	Is#DDcd}|jdz}|j|dzj|dzj|dzj|jdz}tj|||tj|d5}|jd|j|jd|j|jd|jdddy#1swYyxYw)	Nc |jdk7S)Nz.pyc)suffixpaths rskip_pyc_fileszBZipAppTest.test_create_archive_with_filter.<locals>.skip_pyc_filesMs;;&((rrrtest.pyztest.pycrfilterr.)
rrr r!r"r2r3r4r5assertNotIn)rrFrr'r7s     rtest_create_archive_with_filterz*ZipAppTest.test_create_archive_with_filterJs	)x'	-	&&(	)	""$	*	##%|+ff^D
__VS
)	7QMM-6MM)QZZ\2Z6	7	7	7s
A!DDc\d}|jdz}|j|dzj|dzj|dzj|dzdzj|jdz}tj|||tj|d	5}|jt|jd
|jd|j|jd|jdddy#1swYyxYw)Nc&|jddk7S)Nrdummy)partsrDs rskip_dummy_dirzIZipAppTest.test_create_archive_filter_exclude_dir.<locals>.skip_dummy_dir`s::a=G++rrrrGrNztest2.pyrrHr.)rrr r!r"r2r3r>lenr5r4)rrPrr'r7s     r&test_create_archive_filter_exclude_dirz1ZipAppTest.test_create_archive_filter_exclude_dir\s	,x'	-	&&(	)	""$	'	  "	'	J	&--/|+ff^D
__VS
)	3QS.2MM-6MM)QZZ\2	3	3	3s
/A*D""D+c|jdz}|j|dzjtjt||jdz}|j
|jyrr)rrexpected_targets   r"test_create_archive_default_targetz-ZipAppTest.test_create_archive_default_targetps_x'	-	&&(c&k*++4//12rc|jdz}|j|dzj|dzj|jdz}tj||dtj|d5}dD];}|j|j|jt
j=	dddy#1swYyxYw)	NrrrGrT)
compressedr.)rrG)rrr r!r"r2r3r>getinfo
compress_typeZIP_DEFLATED)rrr'r7rs     r$test_create_archive_with_compressionz/ZipAppTest.test_create_archive_with_compressionysx'	-	&&(	)	""$|+ff>
__VS
)	7Q2
7  4!>!>!(!5!57
7	7	7	7s
ACCc>|jdz}|j|dzj|jdz}|jtj
5t	jt|t|dddy#1swYyxYw)Nrfoo.pyrrrr assertRaisesr!ZipAppErrorr"r#r&s   rtest_no_mainzZipAppTest.test_no_mainsyx'	(	!!#|+


v11
2	<!!#f+s6{;	<	<	<s!)BBcB|jdz}|j|dzj|jdz}|jtj
5t	jt|t|ddddy#1swYyxYw)Nrrr
pkg.mod:fnmainr_r&s   rtest_main_and_main_pyz ZipAppTest.test_main_and_main_pysx'	-	&&(|+


v11
2	O!!#f+s6{N	O	O	Os!+BBc|jdz}|j|dzj|jdz}tjt|t|dt
jt|d5}|jd|j|jd|jddddy#1swYyxYw)	Nrr^rrdrer.rspkg.mod.fn())rrr r!r"r#r2r3r4r5readr6s    rtest_main_writtenzZipAppTest.test_main_writtensx'	(	!!#|+c&k3v;\J
__S[#
.	B!MM-6MM/166-+@A	B	B	Bs
ACCc|jdz}|j|dzj|dzj|jdz}tjt|t|dt
jt|d5}|jd|jjd	dddy#1swYyxYw)
Nrr^zbar.pyrrdrer.r)rrr r!r"r#r2r3r>r5countr6s    rtest_main_only_written_oncez&ZipAppTest.test_main_only_written_oncesx'

(	!!#	(	!!#|+c&k3v;\J
__S[#
.	C!Q

 2 2= AB	C	C	Cs0CC c	|jdz}|j|jdz}gd}|D]o}|j|5|jtj
5t	jt|t||ddddddqy#1swYxYw#1swYxYw)Nrr)
r,zfoo:z:barz12:barza.b.c.:dz.a:bza:b.za:.bza:silly namere)rrsubTestr`r!rar"r#)rrr'problemsrfs     rtest_main_validationzZipAppTest.test_main_validationsx'|+
	OD4(
O&&v'9'9:O))#f+s6{NO
O
O	OOO
O
Os$
 B4*+B(B4(B1-B44B=	cd|jdz}|j|dzj|jdz}tjt|t||j
d5}|j|jdddddy#1swYyxYw)NrrrrbrQ#!)	rrr r!r"r#openassertNotEqualrirrr'fs    rtest_default_no_shebangz"ZipAppTest.test_default_no_shebangsx'	-	&&(|+c&k3v;7
[[
	2!q	51	2	2	2s;"B&&B/c|jdz}|j|dzj|jdz}tjt|t|d|j
d5}|j|jdd|jd	|jdddy#1swYyxYw)
NrrrpythoninterpreterrurQrvspython
)
rrr r!r"r#rwr>rireadlinerys    rtest_custom_interpreterz"ZipAppTest.test_custom_interpretersx'	-	&&(|+c&k3v;HM
[[
	8!QVVAY.[!**,7	8	8	8s
=ACCc.|jdz}|j|dzjtj}tjt||d|j|jjdy)Nrrr}r~s	#!python
)rrr r/r0r!r"r#r$getvalue
startswithr&s   rtest_pack_to_fileobjzZipAppTest.test_pack_to_fileobjsix'	-	&&(c&k6xH)44]CDrc6|jdz}|j|dzj|jdz}tjt|t|d|j
tjt|dyNrrrr}r~rrr r!r"r#r>get_interpreterr&s   rtest_read_shebangzZipAppTest.test_read_shebangsqx'	-	&&(|+c&k3v;HM//F<hGrc2|jdz}|j|dzj|jdz}tjt|t||j
tjt|dyrrr&s   rtest_read_missing_shebangz$ZipAppTest.test_read_missing_shebangsox'	-	&&(|+c&k3v;7//F<dCrc|jdz}|j|dzj|jdz}tjt|t|d|jdz}tjt|t|d|j
tjt|dy)Nrrrr}r~changed.pyz	python2.7rrrr'
new_targets    rtest_modify_shebangzZipAppTest.test_modify_shebangsx'	-	&&(|+c&k3v;HM[[=0
c&k3z?T//J@+Nrc|jdz}|j|dzj|jdz}tjt|t|dt
j}tjt||d|j|jjdy)Nrrrr}r~r#!python2.7
)rrr r!r"r#r/r0r$rrrs    rtest_write_shebang_to_fileobjz(ZipAppTest.test_write_shebang_to_fileobjsx'	-	&&(|+c&k3v;HMZZ\
c&k:;O
++-889IJKrcN|jdz}|j|dzj|jdz}|jdz}tj||dtj||d|jtj|dy)Nrrztarget1.pyzztarget2.pyzr}r~r)rrr r!r"r>r)rrtarget1target2s    rtest_read_from_pathobjz!ZipAppTest.test_read_from_pathobjsx'	-	&&(++
-++
-fg8DgwKH//8+Frc|jdz}|j|dzj|jdz}tj}tjt||dtj}|jdtj||d|j|jjdy)	Nrrrr}r~rrr)rrr r/r0r!r"r#r1r$rr)rrr'temp_archivers     rtest_read_from_fileobjz!ZipAppTest.test_read_from_fileobjsx'	-	&&(|+zz|c&k<XNZZ\
!lJKP
++-889IJKrc|jdz}|j|dzj|jdz}tjt|t|d|jdz}tjt|t|d|j
tjt|dy)Nrrrr}r~rrrs    rtest_remove_shebangzZipAppTest.test_remove_shebang%sx'	-	&&(|+c&k3v;HM[[=0
c&k3z?M//J@$Grc|jdz}|j|dzjtj}tjt||dtj}|jdtj||d|jdtj|d5}|jt|jdhdddy#1swYyxYw)Nrrr}r~rr.)rrr r/r0r!r"r#r1r2r3r>setr5)rrr'rr7s     rtest_content_of_copied_archivez)ZipAppTest.test_content_of_copied_archive0sx'	-	&&(c&k6xHZZ\
AfjdC
__Z
-	AS.@	A	A	As+DD	win32z*Windows does not support an executable bitcN|jdz}|j|dzj|jdz}tjt|t|d|j
|jjtjzyr)
rrr r!r"r#r$statst_modeS_IEXECr&s   rtest_shebang_is_executablez%ZipAppTest.test_shebang_is_executable?su
x'	-	&&(|+c&k3v;HM
--<=rcN|jdz}|j|dzj|jdz}tjt|t|d|j
|jjtjzy)Nrrrr~)
rrr r!r"r#assertFalserrrr&s   r!test_no_shebang_is_not_executablez,ZipAppTest.test_no_shebang_is_not_executableKswx'	-	&&(|+c&k3v;DI..=>rN)&__name__
__module____qualname____doc__rr(r*r8r@rKrSrVrr\rbrgrjrnrsr{rrrrrrrrrrunittestskipIfsysplatformrskip_unless_working_chmodrrrrrrs
+0
**
0I 7$3(3_77<O	BC"O2
8EHD	O
L
GL	HAX__S\\W,AC((>)C>X__S\\W,AC?C?rrcneZdZdZdZdZdZdZdZdZ	e
dej	d
Z
dZy)
ZipAppCmdlineTestz$Test zipapp module command line API.ctj}|j|jt	j
|j|_yr	r
rs  rrzZipAppCmdlineTest.setUp[rrc|jdz}|j|dzj|jdz}tj|||Sr)rrr r!r"r&s   rmake_archivezZipAppCmdlineTest.make_archive`sMx'	-	&&(|+ff-
rc
|jdz}|j|dzjt|g}t	j
||j
d}|j|jy)Nrrz.pyz)	rrr r#r!rfwith_suffixr$r%)rrargsr's    rtest_cmdline_createz%ZipAppCmdlineTest.test_cmdline_createisdx'	-	&&(F}D##F+()rc|j}|jdz}t|dt|g}tj||j|j
yN
target.pyz-o)rrr#r!rfr$r%)roriginalr'rs    rtest_cmdline_copyz#ZipAppCmdlineTest.test_cmdline_copyssQ$$&|+H
tS[1D()rc8|j}|jdz}t|dt|g}|jt5}tj|ddd|jjjy#1swY/xYwr
rrr#r`
SystemExitr!rfr$	exceptioncoderrr'rcms     rtest_cmdline_copy_inplacez+ZipAppCmdlineTest.test_cmdline_copy_inplace{s{$$&|+H
tS]3


z
*	bKK		
))*		sBBc<|j}|jdz}t|dt|ddg}|jt5}tj|ddd|jjjy#1swY/xYw)Nrrz-mzfoo:barrrs     rtest_cmdline_copy_change_mainz/ZipAppCmdlineTest.test_cmdline_copy_change_mains$$&|+H
tS[$	B


z
*	bKK		
))*		sBBz
sys.stdout)new_callablecH|j}t|dg}|jt5}t	j
|ddd|j
jjd|j
|jdy#1swYPxYw)N--inforzInterpreter: <none>
)
rr#r`rr!rfr>rrr)rmock_stdoutr'rrs     rtest_info_commandz#ZipAppCmdlineTest.test_info_commands""$FX&


z
*	bKK		
**A.--/1HI			sBB!c|jdz}t|dg}|jt5}t	j
|ddd|j
jjy#1swY/xYw)Nz	dummy.pyzr)	rr#r`rr!rfr$rr)rr'rrs    rtest_info_errorz!ZipAppCmdlineTest.test_info_errorsg{*FX&


z
*	bKK		
))*		sA66A?N)rrrrrrrrrrrr/StringIOrrrrrrrWsI.0
**++<bkk2J3J+rr__main__)rr/rrrrrr!r2test.supportrr
unittest.mockrTestCaserrrrfrrr<module>rsm)	

&"D?""D?N
J+))J+ZzHMMOr