+
    BiH                         R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
 ^ RI	Ht ^ RIHt  ! R R]P                  4      t ! R R]P                  4      t]R	8X  d   ]P$                  ! 4        R# R# )
z#Test harness for the zipapp module.N)requires_zlib)	os_helper)patchc                     a  ] tR t^t o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR t]! 4       R 4       tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!]"PF                  ! ]$PJ                  R8H  R4      ]&PN                  R  4       4       t(]"PF                  ! ]$PJ                  R8H  R4      R! 4       t)R"t*V t+R## )$
ZipAppTestz!Test zipapp module functionality.c                    \         P                  ! 4       pV P                  VP                  4       \        P
                  ! VP                  4      V n        R # NtempfileTemporaryDirectory
addCleanupcleanuppathlibPathnametmpdirselfr   s   & '/usr/lib/python3.14/test/test_zipapp.pysetUpZipAppTest.setUp   4    ,,.'ll6;;/    c                0   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      4       V P                  VP                  4       4       R# source__main__.py
source.pyzNr   mkdirtouchzipappcreate_archivestr
assertTrueis_filer   r   targets   &  r   test_create_archiveZipAppTest.test_create_archive   sc    x'	-	&&(|+c&k3v;7()r   c                
   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! W4       V P                  VP                  4       4       R# r   )r   r   r    r!   r"   r$   r%   r&   s   &  r    test_create_archive_with_pathlib+ZipAppTest.test_create_archive_with_pathlib"   sY    x'	-	&&(|+f-()r   c                   V P                   R ,          pVP                  4        VR,          P                  4        VR,          P                  4        VR,          P                  4        VR,          R,          P                  4        \        P                  ! 4       p\
        P                  ! \        V4      V4       VP                  ^ 4       \        P                  ! VR4      ;_uu_ 4       pV P                  RVP                  4       4       V P                  RVP                  4       4       RRR4       R#   + '       g   i     R# ; i)	r   r   foobarz__init__.pyrzfoo/zbar/N)r   r   r    ioBytesIOr!   r"   r#   seekzipfileZipFileassertInnamelistr   r   r'   zs   &   r    test_create_archive_with_subdirs+ZipAppTest.test_create_archive_with_subdirs+   s    x'	-	&&(	% 	% 	%-	'..0c&k62A__VS))QMM&!**,/MM&!**,/ *)))s   ,AD77E	c                   V P                   R ,          pVP                  4        VR,          P                  4        VR,          P                  4        VR,          R,          P                  4        VR,          R,          P                  4        VR,          P                  4        \        P                  ! 4       p\
        P                  ! \        V4      V4       VP                  ^ 4       \        P                  ! VR4      ;_uu_ 4       pV P                  VP                  4       . RO4       RRR4       R#   + '       g   i     R# ; i)	r   zed.pybinquxbazr   r0   N)r   zbin/zbin/bazzbin/quxr=   )r   r   r    r1   r2   r!   r"   r#   r3   r4   r5   assertEqualr7   )r   r   r'   zfs   &   r   test_create_sorted_archive%ZipAppTest.test_create_sorted_archive:   s    x'	(	!!#	% 	%%	&&(	%%	&&(	-	&&(c&k62A__VS))RR[[]GI *)))s   
#D77E	c                j   R  pV P                   R,          pVP                  4        VR,          P                  4        VR,          P                  4        VR,          P                  4        V P                   R,          p\        P                  ! W#VR7       \
        P                  ! VR4      ;_uu_ 4       pV P                  RVP                  4       4       V P                  RVP                  4       4       V P                  RVP                  4       4       RRR4       R#   + '       g   i     R# ; i)	c                      V P                   R 8g  # )z.pyc)suffixpaths   &r   skip_pyc_filesBZipAppTest.test_create_archive_with_filter.<locals>.skip_pyc_filesM   s    ;;&((r   r   r   test.pyztest.pycr   filterr0   N)
r   r   r    r!   r"   r4   r5   r6   r7   assertNotIn)r   rJ   r   r'   r9   s   &    r   test_create_archive_with_filter*ZipAppTest.test_create_archive_with_filterJ   s    	)x'	-	&&(	)	""$	*	##%|+f^D__VS))QMM-6MM)QZZ\2Z6 *)))s   6A!D!!D2	c                   V P                   pVR ,          P                  4        VR,          P                  4        V P                   R,          p\        P                  ! W4       \        P
                  ! VR4      ;_uu_ 4       pV P                  \        VP                  4       4      ^4       V P                  R VP                  4       4       V P                  RVP                  4       4       RRR4       R#   + '       g   i     R# ; i)r   rL   
target.pyzr0   N
r   r    r!   r"   r4   r5   rA   lenr7   r6   r8   s   &   r   "test_create_archive_self_insertion-ZipAppTest.test_create_archive_self_insertion\   s     	-	&&(	)	""$|+f-__VS))QS.2MM-6MM)QZZ\2 *)))s   A*C77D	c                2   V P                   pVR ,          P                  4        VR,          pVP                  4        V P                  \        P                  4      ;_uu_ 4        \        P
                  ! W4       RRR4       R#   + '       g   i     R# ; i)r   rS   N)r   r    assertRaisesr!   ZipAppErrorr"   r&   s   &  r   "test_target_overwrites_source_file-ZipAppTest.test_target_overwrites_source_filej   sc    	-	&&(,&v1122!!&1 3222s   $BB	c                   V P                   pVR ,          P                  4        VR,          pVP                  4        R p\        P                  ! WVR7       \        P
                  ! VR4      ;_uu_ 4       pV P                  \        VP                  4       4      ^4       V P                  R VP                  4       4       RRR4       R#   + '       g   i     R# ; i)r   rS   c                 .    V P                  R 4      '       * # )z*.pyz)match)ps   &r   <lambda>HZipAppTest.test_target_overwrites_filtered_source_file.<locals>.<lambda>{   s    1777#33r   rM   r0   NrT   )r   r   r'   
pyz_filterr9   s   &    r   +test_target_overwrites_filtered_source_file6ZipAppTest.test_target_overwrites_filtered_source_filet   s     	-	&&(,&3
fZ@__VS))QS.2MM-6 *)))s   7A
CC	c                   R  pV P                   R,          pVP                  4        VR,          P                  4        VR,          P                  4        VR,          P                  4        VR,          R,          P                  4        V P                   R,          p\        P                  ! W#VR7       \
        P                  ! VR4      ;_uu_ 4       pV P                  \        VP                  4       4      ^4       V P                  RVP                  4       4       V P                  RVP                  4       4       R	R	R	4       R	#   + '       g   i     R	# ; i)
c                 .    V P                   ^ ,          R8g  # )    dummy)partsrH   s   &r   skip_dummy_dirIZipAppTest.test_create_archive_filter_exclude_dir.<locals>.skip_dummy_dir   s    ::a=G++r   r   r   rL   ri   ztest2.pyr   rM   r0   N)r   r   r    r!   r"   r4   r5   rA   rU   r7   r6   )r   rk   r   r'   r9   s   &    r   &test_create_archive_filter_exclude_dir1ZipAppTest.test_create_archive_filter_exclude_dir   s    	,x'	-	&&(	)	""$	'	  "	'	J	&--/|+f^D__VS))QS.2MM-6MM)QZZ\2 *)))s   A*EE	c                   V P                   R ,          pVP                  4        VR,          P                  4        \        P                  ! \        V4      4       V P                   R,          pV P                  VP                  4       4       R# r   r   )r   r   expected_targets   &  r   "test_create_archive_default_target-ZipAppTest.test_create_archive_default_target   s_    x'	-	&&(c&k*++4//12r   c                   V P                   R ,          pVP                  4        VR,          P                  4        VR,          P                  4        V P                   R,          p\        P                  ! WRR7       \
        P                  ! VR4      ;_uu_ 4       pR F<  pV P                  VP                  V4      P                  \
        P                  4       K>  	  RRR4       R#   + '       g   i     R# ; i)	r   r   rL   r   T)
compressedr0   N)r   rL   )r   r   r    r!   r"   r4   r5   rA   getinfocompress_typeZIP_DEFLATED)r   r   r'   r9   r   s   &    r   $test_create_archive_with_compression/ZipAppTest.test_create_archive_with_compression   s     x'	-	&&(	)	""$|+f>__VS))Q2  4!>!>!(!5!57 3 *)))s   AC))C:	c                z   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          pV P                  \        P
                  4      ;_uu_ 4        \        P                  ! \        V4      \        V4      4       RRR4       R#   + '       g   i     R# ; i)r   foo.pyr   Nr   r   r    rY   r!   rZ   r"   r#   r&   s   &  r   test_no_mainZipAppTest.test_no_main   sv    x'	(	!!#|+v1122!!#f+s6{; 3222s   5*B))B:	c                ~   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          pV P                  \        P
                  4      ;_uu_ 4        \        P                  ! \        V4      \        V4      RR7       RRR4       R#   + '       g   i     R# ; i)r   r   r   
pkg.mod:fnmainNr|   r&   s   &  r   test_main_and_main_py ZipAppTest.test_main_and_main_py   sx    x'	-	&&(|+v1122!!#f+s6{N 3222s   5,B++B<	c                   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      RR7       \        P                  ! \        V4      R4      ;_uu_ 4       pV P                  RVP                  4       4       V P                  RVP                  R4      4       RRR4       R#   + '       g   i     R# ; i)	r   r{   r   r   r   r0   r   s   pkg.mod.fn()N)r   r   r    r!   r"   r#   r4   r5   r6   r7   readr8   s   &   r   test_main_writtenZipAppTest.test_main_written   s    x'	(	!!#|+c&k3v;\J__S[#..!MM-6MM/166-+@A /...s   !AC--C>	c                   V P                   R ,          pVP                  4        VR,          P                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      RR7       \        P                  ! \        V4      R4      ;_uu_ 4       pV P                  ^VP                  4       P                  R4      4       RRR4       R#   + '       g   i     R# ; i)	r   r{   zbar.pyr   r   r   r0   r   N)r   r   r    r!   r"   r#   r4   r5   rA   r7   countr8   s   &   r   test_main_only_written_once&ZipAppTest.test_main_only_written_once   s     x'
 
(	!!#	(	!!#|+c&k3v;\J__S[#..!Q

 2 2= AB /...s   80C22D	c                   V P                   R ,          pVP                  4        V P                   R,          p. ROpV F  pV P                  VR7      ;_uu_ 4        V P                  \        P
                  4      ;_uu_ 4        \        P                  ! \        V4      \        V4      VR7       RRR4       RRR4       K  	  R#   + '       g   i     L; i  + '       g   i     K  ; i)r   r   r   N)
 r.   zfoo:z:barz12:barza.b.c.:dz.a:bza:b.za:.bza:silly name)r   r   subTestrY   r!   rZ   r"   r#   )r   r   r'   problemsr   s   &    r   test_main_validationZipAppTest.test_main_validation   s    x'|+
 D4((&&v'9'9::))#f+s6{N ; )( :: )((s$   (C,C.CCCC(c                   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      4       VP                  R4      ;_uu_ 4       pV P                  VP                  ^4      R4       RRR4       R#   + '       g   i     R# ; i)r   r   r   rb   #!N)	r   r   r    r!   r"   r#   openassertNotEqualr   r   r   r'   fs   &   r   test_default_no_shebang"ZipAppTest.test_default_no_shebang   s    x'	-	&&(|+c&k3v;7[[!q	51 s   "B<<C	c                   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      RR7       VP                  R4      ;_uu_ 4       pV P                  VP                  ^4      R4       V P                  RVP                  4       4       RRR4       R#   + '       g   i     R# ; i)	r   r   r   pythoninterpreterr   r   s   python
N)
r   r   r    r!   r"   r#   r   rA   r   readliner   s   &   r   test_custom_interpreter"ZipAppTest.test_custom_interpreter   s     x'	-	&&(|+c&k3v;HM[[!QVVAY.[!**,7 s   ACC/	c                (   V P                   R ,          pVP                  4        VR,          P                  4        \        P                  ! 4       p\
        P                  ! \        V4      VRR7       V P                  VP                  4       R4       R# )r   r   r   r   s	   #!python
N)
r   r   r    r1   r2   r!   r"   r#   assertStartsWithgetvaluer&   s   &  r   test_pack_to_fileobjZipAppTest.test_pack_to_fileobj   sb    x'	-	&&(c&k6xHfoo/?r   c                T   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      RR7       V P                  \        P                  ! \        V4      4      R4       R# r   r   r   r   r   Nr   r   r    r!   r"   r#   rA   get_interpreterr&   s   &  r   test_read_shebangZipAppTest.test_read_shebang  sq    x'	-	&&(|+c&k3v;HM//F<hGr   c                P   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      4       V P                  \        P                  ! \        V4      4      R4       R# r   r   r&   s   &  r   test_read_missing_shebang$ZipAppTest.test_read_missing_shebang  so    x'	-	&&(|+c&k3v;7//F<dCr   c                   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      RR7       V P                   R,          p\        P                  ! \        V4      \        V4      RR7       V P                  \        P                  ! \        V4      4      R4       R# )r   r   r   r   r   changed.pyz	python2.7Nr   r   r   r'   
new_targets   &   r   test_modify_shebangZipAppTest.test_modify_shebang  s    x'	-	&&(|+c&k3v;HM[[=0
c&k3z?T//J@+Nr   c                   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      RR7       \        P                  ! 4       p\        P                  ! \        V4      VRR7       V P                  VP                  4       R4       R# r   r   r   r   r   r   s   #!python2.7
N)
r   r   r    r!   r"   r#   r1   r2   r   r   r   s   &   r   test_write_shebang_to_fileobj(ZipAppTest.test_write_shebang_to_fileobj%  s     x'	-	&&(|+c&k3v;HMZZ\
c&k:;Oj1135EFr   c                $   V P                   R ,          pVP                  4        VR,          P                  4        \        P                  ! \        V4      4      p\        P                  ! \        V P                   R,          4      4      p\        P                  ! \        V P                   R,          4      4      p\        P                  ! WRR7       \        P                  ! W#RR7       V P                  \        P                  ! V4      R4       R# )r   r   ztarget1.pyzztarget2.pyzr   r   r   N)
r   r   r    r   FakePathr#   r!   r"   rA   r   )r   r   target1target2s   &   r   test_read_from_pathlike_obj&ZipAppTest.test_read_from_pathlike_obj1  s     x'	-	&&(##CK0$$S})D%EF$$S})D%EFf8DgKH//8+Fr   c                   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! 4       p\
        P                  ! \        V4      VRR7       \        P                  ! 4       pVP                  ^ 4       \
        P                  ! W4RR7       V P                  VP                  4       R4       R# r   )r   r   r    r1   r2   r!   r"   r#   r3   r   r   )r   r   r'   temp_archiver   s   &    r   test_read_from_fileobj!ZipAppTest.test_read_from_fileobj>  s    x'	-	&&(|+zz|c&k<XNZZ\
!lKPj1135EFr   c                   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      RR7       V P                   R,          p\        P                  ! \        V4      \        V4      RR7       V P                  \        P                  ! \        V4      4      R4       R# )r   r   r   r   r   r   Nr   r   s   &   r   test_remove_shebangZipAppTest.test_remove_shebangK  s    x'	-	&&(|+c&k3v;HM[[=0
c&k3z?M//J@$Gr   c                R   V P                   R ,          pVP                  4        VR,          P                  4        \        P                  ! 4       p\
        P                  ! \        V4      VRR7       \        P                  ! 4       pVP                  ^ 4       \
        P                  ! W#RR7       VP                  ^ 4       \        P                  ! VR4      ;_uu_ 4       pV P                  \        VP                  4       4      R04       RRR4       R#   + '       g   i     R# ; i)r   r   r   r   Nr0   )r   r   r    r1   r2   r!   r"   r#   r3   r4   r5   rA   setr7   )r   r   r'   r   r9   s   &    r   test_content_of_copied_archive)ZipAppTest.test_content_of_copied_archiveV  s    x'	-	&&(c&k6xHZZ\
AfdC__Z--S.@ .---s    +DD&	win32z*Windows does not support an executable bitc                r   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      RR7       V P                  VP                  4       P                  \        P                  ,          4       R# r   )
r   r   r    r!   r"   r#   r$   statst_modeS_IEXECr&   s   &  r   test_shebang_is_executable%ZipAppTest.test_shebang_is_executablee  su    
 x'	-	&&(|+c&k3v;HM--<=r   c                r   V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! \        V4      \        V4      RR7       V P                  VP                  4       P                  \        P                  ,          4       R# )r   r   r   Nr   )
r   r   r    r!   r"   r#   assertFalser   r   r   r&   s   &  r   !test_no_shebang_is_not_executable,ZipAppTest.test_no_shebang_is_not_executableq  sw     x'	-	&&(|+c&k3v;DI..=>r   r   N),__name__
__module____qualname____firstlineno____doc__r   r(   r+   r:   rC   rP   rV   r[   rd   rm   rq   r   rx   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   unittestskipIfsysplatformr   skip_unless_working_chmodr   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s    +0
**0I 7$3273(3 _7 7<O	BC"O2
8@HD	O
GGG	HA __S\\W,AC((> )C> __S\\W,AC?C?r   r   c                      a  ] tR tRt o RtR tR tR tR tR t	R t
]! R	]P                  R
7      R 4       tR tRtV tR# )ZipAppCmdlineTesti}  z$Test zipapp module command line API.c                    \         P                  ! 4       pV P                  VP                  4       \        P
                  ! VP                  4      V n        R # r   r	   r   s   & r   r   ZipAppCmdlineTest.setUp  r   r   c                    V P                   R ,          pVP                  4        VR,          P                  4        V P                   R,          p\        P                  ! W4       V# )r   r   r   )r   r   r    r!   r"   r&   s   &  r   make_archiveZipAppCmdlineTest.make_archive  sK    x'	-	&&(|+f-r   c                   V P                   R ,          pVP                  4        VR,          P                  4        \        V4      .p\        P
                  ! V4       VP                  R4      pV P                  VP                  4       4       R# )r   r   z.pyzN)	r   r   r    r#   r!   r   with_suffixr$   r%   )r   r   argsr'   s   &   r   test_cmdline_create%ZipAppCmdlineTest.test_cmdline_create  sd    x'	-	&&(F}D##F+()r   c                    V P                  4       pV P                  R ,          p\        V4      R\        V4      .p\        P                  ! V4       V P                  VP                  4       4       R# rS   -oN)r   r   r#   r!   r   r$   r%   )r   originalr'   r   s   &   r   test_cmdline_copy#ZipAppCmdlineTest.test_cmdline_copy  sQ    $$&|+HtS[1D()r   c                b   V P                  4       pV P                  R ,          p\        V4      R\        V4      .pV P                  \        4      ;_uu_ 4       p\
        P                  ! V4       RRR4       V P                  XP                  P                  4       R#   + '       g   i     L7; ir   
r   r   r#   rY   
SystemExitr!   r   r$   	exceptioncoder   r   r'   r   cms   &    r   test_cmdline_copy_inplace+ZipAppCmdlineTest.test_cmdline_copy_inplace  sw    $$&|+HtS]3z**bKK + 	))* +*s   BB.	c                f   V P                  4       pV P                  R ,          p\        V4      R\        V4      RR.pV P                  \        4      ;_uu_ 4       p\
        P                  ! V4       RRR4       V P                  XP                  P                  4       R#   + '       g   i     L7; i)rS   r   z-mzfoo:barNr   r   s   &    r   test_cmdline_copy_change_main/ZipAppCmdlineTest.test_cmdline_copy_change_main  s{    $$&|+HtS[$	Bz**bKK + 	))* +*s   B  B0	z
sys.stdout)new_callablec                j   V P                  4       p\        V4      R .pV P                  \        4      ;_uu_ 4       p\        P
                  ! V4       RRR4       V P                  XP                  P                  ^ 4       V P                  VP                  4       R4       R#   + '       g   i     LX; i)--infoNzInterpreter: <none>
)
r   r#   rY   r   r!   r   rA   r   r   r   )r   mock_stdoutr'   r   r   s   &&   r   test_info_command#ZipAppCmdlineTest.test_info_command  s     ""$FX&z**bKK + 	**A.--/1HI	 +*s   B""B2	c                .   V P                   R ,          p\        V4      R.pV P                  \        4      ;_uu_ 4       p\        P
                  ! V4       RRR4       V P                  XP                  P                  4       R#   + '       g   i     L7; i)z	dummy.pyzr  N)	r   r#   rY   r   r!   r   r$   r   r   )r   r'   r   r   s   &   r   test_info_error!ZipAppCmdlineTest.test_info_error  sc    {*FX&z**bKK + 	))* +*s   BB	r   N)r   r   r   r   r   r   r   r   r   r   r  r   r1   StringIOr	  r  r   r   r   s   @r   r   r   }  sQ     .0
**++ <bkk2J 3J+ +r   r   __main__)r   r1   r   r   r   r
   r   r!   r4   test.supportr   r   unittest.mockr   TestCaser   r   r   r    r   r   <module>r     sk    ) 	   
     & " j?"" j?ZJ+)) J+Z zMMO r   