Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.222.38.196
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_zipapp.cpython-310.pyc
o

ab�?�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZGdd�dej
�ZGdd�dej
�Zed	krJe��dSdS)
z#Test harness for the zipapp module.�N)�
requires_zlib)�patchc@s
eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
e�dd��Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Ze�ej d2kd3�d4d5��Z!e�ej d2kd3�d6d7��Z"d8S)9�
ZipAppTestz!Test zipapp module functionality.cC�&t��}|�|j�t�|j�|_dS�N��tempfile�TemporaryDirectoryZ
addCleanup�cleanup�pathlib�Path�name�tmpdir��selfr�r�9/usr/local/python-3.10/lib/python3.10/test/test_zipapp.py�setUp�zZipAppTest.setUpcCsN|jd}|��|d��|jd}t�t|�t|��|�|���dS�N�source�__main__.py�
source.pyz�r�mkdir�touch�zipapp�create_archive�str�
assertTrue�is_file�rr�targetrrr�test_create_archives

zZipAppTest.test_create_archivecCsF|jd}|��|d��|jd}t�||�|�|���dSr)rrrrrrr r!rrr� test_create_archive_with_pathlib!s

z+ZipAppTest.test_create_archive_with_pathlibcCs�|jd}|��|d��|d��|d��|dd��t��}t�t|�|�|�d�t	�
|d��}|�d|���|�d	|���Wd�dS1sVwYdS)
Nrr�fooZbarz__init__.pyr�rzfoo/zbar/)
rrr�io�BytesIOrrr�seek�zipfile�ZipFile�assertIn�namelist�rrr"�zrrr� test_create_archive_with_subdirs*s

"�z+ZipAppTest.test_create_archive_with_subdirscCs�dd�}|jd}|��|d��|d��|d��|jd}tj|||d�t�|d	��!}|�d|���|�d|���|�	d|���Wd�dS1sVwYdS)
NcSs
|jdkS)Nz.pyc)�suffix��pathrrr�skip_pyc_files<s
zBZipAppTest.test_create_archive_with_filter.<locals>.skip_pyc_filesrr�test.pyztest.pycr��filterr&)
rrrrrr*r+r,r-ZassertNotIn)rr4rr"r/rrr�test_create_archive_with_filter9s

"�z*ZipAppTest.test_create_archive_with_filtercCs�dd�}|jd}|��|d��|d��|d��|dd��|jd}tj|||d	�t�|d
��#}|�t|�	��d�|�
d|�	��|�
d|�	��Wd�dS1s`wYdS)NcSs|jddkS)Nr�dummy)�partsr2rrr�skip_dummy_dirOszIZipAppTest.test_create_archive_filter_exclude_dir.<locals>.skip_dummy_dirrrr5r9ztest2.pyrr6r&�)rrrrrr*r+�assertEqual�lenr-r,)rr;rr"r/rrr�&test_create_archive_filter_exclude_dirKs

"�z1ZipAppTest.test_create_archive_filter_exclude_dircCsH|jd}|��|d��t�t|��|jd}|�|���dSrr)rrZexpected_targetrrr�"test_create_archive_default_target_s

z-ZipAppTest.test_create_archive_default_targetcCs�|jd}|��|d��|d��|jd}tj||dd�t�|d��}dD]
}|�|�|�j	tj
�q+Wd�dS1sDwYdS)	Nrrr5rT)�
compressedr&)rr5)rrrrrr*r+r=ZgetinfoZ
compress_type�ZIP_DEFLATED)rrr"r/r
rrr�$test_create_archive_with_compressionhs

��"�z/ZipAppTest.test_create_archive_with_compressioncCsn|jd}|��|d��|jd}|�tj��t�t|�t|��Wd�dS1s0wYdS)Nr�foo.pyr�rrr�assertRaisesr�ZipAppErrorrrr!rrr�test_no_mainws

"�zZipAppTest.test_no_maincCsr|jd}|��|d��|jd}|�tj��tjt|�t|�dd�Wd�dS1s2wYdS)Nrrr�
pkg.mod:fn��mainrEr!rrr�test_main_and_main_py�s

"�z ZipAppTest.test_main_and_main_pycCs�|jd}|��|d��|jd}tjt|�t|�dd�t�t|�d��}|�d|�	��|�d|�
d��Wd�dS1sEwYdS)	NrrDrrIrJr&rspkg.mod.fn())rrrrrrr*r+r,r-�readr.rrr�test_main_written�s

"�zZipAppTest.test_main_writtencCs�|jd}|��|d��|d��|jd}tjt|�t|�dd�t�t|�d��}|�d|�	��
d	��Wd�dS1sEwYdS)
NrrDzbar.pyrrIrJr&�r)rrrrrrr*r+r=r-�countr.rrr�test_main_only_written_once�s

"�z&ZipAppTest.test_main_only_written_oncec
Cs�|jd}|��|jd}gd�}|D]:}|j|d��*|�tj��tjt|�t|�|d�Wd�n1s:wYWd�n1sIwYqdS)Nrr)
�r%zfoo:z:barz12:barza.b.c.:dz.a:bza:b.za:.bza:silly namerJ)rrZsubTestrFrrGrr)rrr"ZproblemsrKrrr�test_main_validation�s

�����zZipAppTest.test_main_validationcCs~|jd}|��|d��|jd}t�t|�t|��|�d��}|�|�d�d�Wd�dS1s8wYdS)Nrrr�rbr<�#!)	rrrrrr�openZassertNotEqualrM�rrr"�frrr�test_default_no_shebang�s

"�z"ZipAppTest.test_default_no_shebangcCs�|jd}|��|d��|jd}tjt|�t|�dd�|�d��}|�|�d�d�|�d	|�	��Wd�dS1sBwYdS)
Nrrr�python�ZinterpreterrTr<rUspython
)
rrrrrrrVr=rM�readlinerWrrr�test_custom_interpreter�s

"�z"ZipAppTest.test_custom_interpretercCsR|jd}|��|d��t��}tjt|�|dd�|�|�	��
d��dS)NrrrZr[s	#!python
)rrrr'r(rrrr�getvalue�
startswithr!rrr�test_pack_to_fileobj�s
zZipAppTest.test_pack_to_fileobjcCsZ|jd}|��|d��|jd}tjt|�t|�dd�|�t�t|��d�dS�NrrrrZr[�rrrrrrr=�get_interpreterr!rrr�test_read_shebang�s

zZipAppTest.test_read_shebangcCsV|jd}|��|d��|jd}t�t|�t|��|�t�t|��d�dSrrbr!rrr�test_read_missing_shebang�s

z$ZipAppTest.test_read_missing_shebangcCs||jd}|��|d��|jd}tjt|�t|�dd�|jd}tjt|�t|�dd�|�t�t|��d�dS)NrrrrZr[�changed.pyz�	python2.7rb�rrr"�
new_targetrrr�test_modify_shebang��


zZipAppTest.test_modify_shebangcCst|jd}|��|d��|jd}tjt|�t|�dd�t��}tjt|�|dd�|�|�	��
d��dS)NrrrrZr[rg�#!python2.7
)rrrrrrr'r(rr^r_rhrrr�test_write_shebang_to_fileobj�s

z(ZipAppTest.test_write_shebang_to_fileobjcCsh|jd}|��|d��|jd}|jd}tj||dd�tj||dd�|�t�|�d�dS)Nrrztarget1.pyzztarget2.pyzrZr[rg)rrrrrr=rc)rrZtarget1Ztarget2rrr�test_read_from_pathobj�s


z!ZipAppTest.test_read_from_pathobjcCs~|jd}|��|d��|jd}t��}tjt|�|dd�t��}|�d�tj||dd�|�	|�
��d��dS)	NrrrrZr[rrgrl)rrrr'r(rrrr)rr^r_)rrr"Ztemp_archiverirrr�test_read_from_fileobjs


z!ZipAppTest.test_read_from_fileobjcCs||jd}|��|d��|jd}tjt|�t|�dd�|jd}tjt|�t|�dd�|�t�t|��d�dS)NrrrrZr[rfrbrhrrr�test_remove_shebangrkzZipAppTest.test_remove_shebangcCs�|jd}|��|d��t��}tjt|�|dd�t��}|�d�tj||dd�|�d�t	�
|d��}|�t|�
��dh�Wd�dS1sPwYdS)NrrrZr[rr&)rrrr'r(rrrr)r*r+r=�setr-)rrr"rir/rrr�test_content_of_copied_archives


"�z)ZipAppTest.test_content_of_copied_archive�win32z*Windows does not support an executable bitcCsZ|jd}|��|d��|jd}tjt|�t|�dd�|�|��jtj	@�dSra)
rrrrrrr�stat�st_mode�S_IEXECr!rrr�test_shebang_is_executable.�

z%ZipAppTest.test_shebang_is_executablecCsZ|jd}|��|d��|jd}tjt|�t|�dd�|�|��jtj	@�dS)Nrrrr[)
rrrrrrZassertFalsertrurvr!rrr�!test_no_shebang_is_not_executable9rxz,ZipAppTest.test_no_shebang_is_not_executableN)#�__name__�
__module__�__qualname__�__doc__rr#r$r0r8r?r@rrCrHrLrNrQrSrYr]r`rdrerjrmrnrorprr�unittestZskipIf�sys�platformrwryrrrrrsF			
		
			
�
	�rc@s^eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
dejd�dd��Z
dd�ZdS)�ZipAppCmdlineTestz$Test zipapp module command line API.cCrrrrrrrrIrzZipAppCmdlineTest.setUpcCs8|jd}|��|d��|jd}t�||�|Sr)rrrrrr!rrr�make_archiveNs

zZipAppCmdlineTest.make_archivecCsN|jd}|��|d��t|�g}t�|�|�d�}|�|���dS)Nrrz.pyz)	rrrrrrK�with_suffixrr )rr�argsr"rrr�test_cmdline_createWs



z%ZipAppCmdlineTest.test_cmdline_createcCs@|��}|jd}t|�dt|�g}t�|�|�|���dS�N�
target.pyz�-o)r�rrrrKrr )r�originalr"r�rrr�test_cmdline_copyas


z#ZipAppCmdlineTest.test_cmdline_copycCsj|��}|jd}t|�dt|�g}|�t��
}t�|�Wd�n1s'wY|�|jj	�dSr��
r�rrrF�
SystemExitrrKr�	exception�code�rr�r"r��cmrrr�test_cmdline_copy_inplaceis
�z+ZipAppCmdlineTest.test_cmdline_copy_inplacecCsn|��}|jd}t|�dt|�ddg}|�t��
}t�|�Wd�n1s)wY|�|jj	�dS)Nr�r�z-mzfoo:barr�r�rrr�test_cmdline_copy_change_mainss
�z/ZipAppCmdlineTest.test_cmdline_copy_change_mainz
sys.stdout)Znew_callablecCsl|��}t|�dg}|�t��
}t�|�Wd�n1swY|�|jjd�|�|�	�d�dS)N�--inforzInterpreter: <none>
)
r�rrFr�rrKr=r�r�r^)rZmock_stdoutr"r�r�rrr�test_info_command}s�z#ZipAppCmdlineTest.test_info_commandcCs\|jd}t|�dg}|�t��
}t�|�Wd�n1s wY|�|jj�dS)Nz	dummy.pyzr�)	rrrFr�rrKrr�r�)rr"r�r�rrr�test_info_error�s
�z!ZipAppCmdlineTest.test_info_errorN)rzr{r|r}rr�r�r�r�r�rr'�StringIOr�r�rrrrr�Es	




r��__main__)r}r'rrtrrr~rr*Ztest.supportrZ
unittest.mockrZTestCaserr�rzrKrrrr�<module>s$8M�
© 2025 GrazzMean