Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_zipapp.cpython-39.opt-2.pyc

a

��g�?�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZGdd�dej�Z
Gdd�dej�Zedkr�e��dS)	�N)�
requires_zlib)�patchc@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
�dd��Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Ze�ejd1kd2�d3d4��Z e�ejd1kd2�d5d6��Z!d7S)8�
ZipAppTestcCs&t��}|�|j�t�|j�|_dS�N��tempfile�TemporaryDirectoryZ
addCleanup�cleanup�pathlib�Path�name�tmpdir��selfr
�r�,/usr/local/lib/python3.9/test/test_zipapp.py�setUps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)r
rrrrrrrrrr� test_create_archive_with_pathlib!s

z+ZipAppTest.test_create_archive_with_pathlibcCs�|jd}|��|d��|d��|d��|dd��t��}t�t|�|�|�d�t	�
|d��0}|�d|���|�d	|���Wd�n1s�0YdS)
Nrr�fooZbarz__init__.pyr�rzfoo/zbar/)
r
rr�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�n1s�0YdS)
NcSs
|jdkS)Nz.pyc)�suffix��pathrrr�skip_pyc_files<szBZipAppTest.test_create_archive_with_filter.<locals>.skip_pyc_filesrr�test.pyztest.pycr��filterr$)
r
rrrrr(r)r*r+ZassertNotIn)rr2rr 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
��D}|�t|�	��d�|�
d|�	��|�
d|�	��Wd�n1s�0YdS)NcSs|jddkS)Nr�dummy)�partsr0rrr�skip_dummy_dirOszIZipAppTest.test_create_archive_filter_exclude_dir.<locals>.skip_dummy_dirrrr3r7ztest2.pyrr4r$�)r
rrrrr(r)�assertEqual�lenr+r*)rr9rr 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��0}dD]}|�|�|�j	tj
�qVWd�n1s�0YdS)	Nrrr3rT)�
compressedr$)rr3)r
rrrrr(r)r;ZgetinfoZ
compress_type�ZIP_DEFLATED)rrr r-rrrr�$test_create_archive_with_compressionhs

�z/ZipAppTest.test_create_archive_with_compressioncCsl|jd}|��|d��|jd}|�tj��$t�t|�t|��Wd�n1s^0YdS)Nr�foo.pyr�r
rr�assertRaisesr�ZipAppErrorrrrrrr�test_no_mainws

zZipAppTest.test_no_maincCsp|jd}|��|d��|jd}|�tj��(tjt|�t|�dd�Wd�n1sb0YdS)Nrrr�
pkg.mod:fn��mainrCrrrr�test_main_and_main_py�s

z ZipAppTest.test_main_and_main_pycCs�|jd}|��|d��|jd}tjt|�t|�dd�t�t|�d��2}|�d|�	��|�d|�
d��Wd�n1s�0YdS)	NrrBrrGrHr$rspkg.mod.fn())r
rrrrrr(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�n1s�0YdS)
NrrBzbar.pyrrGrHr$�r)r
rrrrrr(r)r;r+�countr,rrr�test_main_only_written_once�s

z&ZipAppTest.test_main_only_written_oncec
Cs�|jd}|��|jd}gd�}|D]t}|j|d��T|�tj��(tjt|�t|�|d�Wd�n1st0YWd�q(1s�0Yq(dS)Nrr)
�r#zfoo:z:barz12:barza.b.c.:dz.a:bza:b.za:.bza:silly namerH)r
rZsubTestrDrrErr)rrr ZproblemsrIrrr�test_main_validation�s

zZipAppTest.test_main_validationcCs||jd}|��|d��|jd}t�t|�t|��|�d��"}|�|�d�d�Wd�n1sn0YdS)Nrrr�rbr:�#!)	r
rrrrr�openZassertNotEqualrK�rrr �frrr�test_default_no_shebang�s

z"ZipAppTest.test_default_no_shebangcCs�|jd}|��|d��|jd}tjt|�t|�dd�|�d��2}|�|�d�d�|�d	|�	��Wd�n1s�0YdS)
Nrrr�python�ZinterpreterrRr:rSspython
)
r
rrrrrrTr;rK�readlinerUrrr�test_custom_interpreter�s

z"ZipAppTest.test_custom_interpretercCsR|jd}|��|d��t��}tjt|�|dd�|�|�	��
d��dS)NrrrXrYs	#!python
)r
rrr%r&rrrr�getvalue�
startswithrrrr�test_pack_to_fileobj�s
zZipAppTest.test_pack_to_fileobjcCsZ|jd}|��|d��|jd}tjt|�t|�dd�|�t�t|��d�dS�NrrrrXrY�r
rrrrrr;�get_interpreterrrrr�test_read_shebang�s

zZipAppTest.test_read_shebangcCsV|jd}|��|d��|jd}t�t|�t|��|�t�t|��d�dSrr`rrrr�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)NrrrrXrY�changed.pyz�	python2.7r`�rrr �
new_targetrrr�test_modify_shebang�s


zZipAppTest.test_modify_shebangcCst|jd}|��|d��|jd}tjt|�t|�dd�t��}tjt|�|dd�|�|�	��
d��dS)NrrrrXrYre�#!python2.7
)r
rrrrrr%r&rr\r]rfrrr�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.pyzrXrYre)r
rrrrr;ra)rrZtarget1Ztarget2rrr�test_read_from_pathobj�s


z!ZipAppTest.test_read_from_pathobjcCs~|jd}|��|d��|jd}t��}tjt|�|dd�t��}|�d�tj||dd�|�	|�
��d��dS)	NrrrrXrYrreri)r
rrr%r&rrrr'rr\r])rrr Ztemp_archivergrrr�test_read_from_fileobjs


z!ZipAppTest.test_read_from_fileobjcCs||jd}|��|d��|jd}tjt|�t|�dd�|jd}tjt|�t|�dd�|�t�t|��d�dS)NrrrrXrYrdr`rfrrr�test_remove_shebangs


zZipAppTest.test_remove_shebangcCs�|jd}|��|d��t��}tjt|�|dd�t��}|�d�tj||dd�|�d�t	�
|d��&}|�t|�
��dh�Wd�n1s�0YdS)NrrrXrYrr$)r
rrr%r&rrrr'r(r)r;�setr+)rrr rgr-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	@�dSr_)
r
rrrrrr�stat�st_mode�S_IEXECrrrr�test_shebang_is_executable.s

z%ZipAppTest.test_shebang_is_executablecCsZ|jd}|��|d��|jd}tjt|�t|�dd�|�|��jtj	@�dS)NrrrrY)
r
rrrrrZassertFalserqrrrsrrrr�!test_no_shebang_is_not_executable9s

z,ZipAppTest.test_no_shebang_is_not_executableN)"�__name__�
__module__�__qualname__rr!r"r.r6r=r>rrArFrJrLrOrQrWr[r^rbrcrhrjrkrlrmro�unittestZskipIf�sys�platformrtrurrrrrsB			
		
			
�
	�rc@sZeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	d
e
jd�dd��Zdd�Z
dS)�ZipAppCmdlineTestcCs&t��}|�|j�t�|j�|_dSrrrrrrrIszZipAppCmdlineTest.setUpcCs8|jd}|��|d��|jd}t�||�|Sr)r
rrrrrrrr�make_archiveNs

zZipAppCmdlineTest.make_archivecCsN|jd}|��|d��t|�g}t�|�|�d�}|�|���dS)Nrrz.pyz)	r
rrrrrI�with_suffixrr)rr�argsr rrr�test_cmdline_createWs



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


z#ZipAppCmdlineTest.test_cmdline_copycCsj|��}|jd}t|�dt|�g}|�t��}t�|�Wd�n1sN0Y|�|jj	�dSr��
r}r
rrD�
SystemExitrrIr�	exception�code�rr�r r�cmrrr�test_cmdline_copy_inplaceis
(z+ZipAppCmdlineTest.test_cmdline_copy_inplacecCsn|��}|jd}t|�dt|�ddg}|�t��}t�|�Wd�n1sR0Y|�|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�n1s>0Y|�|jjd�|�|�	�d�dS)N�--inforzInterpreter: <none>
)
r}rrDr�rrIr;r�r�r\)rZmock_stdoutr rr�rrr�test_info_command}s(z#ZipAppCmdlineTest.test_info_commandcCs\|jd}t|�dg}|�t��}t�|�Wd�n1s@0Y|�|jj�dS)Nz	dummy.pyzr�)	r
rrDr�rrIrr�r�)rr rr�rrr�test_info_error�s

(z!ZipAppCmdlineTest.test_info_errorN)rvrwrxrr}r�r�r�r�rr%�StringIOr�r�rrrrr|Es	




r|�__main__)r%r
rqrzrryrr(Ztest.supportrZ
unittest.mockrZTestCaserr|rvrIrrrr�<module>s8M

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists