Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_zipapp.cpython-312.opt-2.pyc

�

'Μg�B����	ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZGd�dej�ZGd�dej�Zed	k(rej"�yy)
�N)�
requires_zlib)�	os_helper)�patchc�n�eZdZ	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
e�d	��Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zej<ej@dk(d�e!jDd���Z#ej<ej@dk(d�d��Z$y)�
ZipAppTestc��tj�}|j|j�t	j
|j�|_y�N��tempfile�TemporaryDirectory�
addCleanup�cleanup�pathlib�Path�name�tmpdir��selfrs  �-/usr/local/lib/python3.12/test/test_zipapp.py�setUpzZipAppTest.setUp�4���,�,�.��������'��l�l�6�;�;�/���c��|jdz}|j�|dzj�|jdz}tjt|�t|��|j
|j��y�N�source�__main__.py�
source.pyz�r�mkdir�touch�zipapp�create_archive�str�
assertTrue�is_file�rr�targets   r�test_create_archivezZipAppTest.test_create_archivesc�����x�'������	�-�	�&�&�(����|�+�����c�&�k�3�v�;�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�'������	�-�	�&�&�(����|�+�����f�f�-�������(�)rc�>�|jdz}|j�|dzj�|dzj�|dzj�|dzdzj�tj�}tjt|�|�|jd�tj|d�5}|jd|j��|jd	|j��ddd�y#1swYyxYw)
Nrr�foo�barz__init__.pyr�rzfoo/zbar/)
rrr �io�BytesIOr!r"r#�seek�zipfile�ZipFile�assertIn�namelist�rrr'�zs    r� test_create_archive_with_subdirsz+ZipAppTest.test_create_archive_with_subdirs+s������x�'������	�-�	�&�&�(�	�%���� �	�%���� �	�%��-�	'�.�.�0���������c�&�k�6�2����A��
�_�_�V�S�
)�Q��M�M�&�!�*�*�,�/��M�M�&�!�*�*�,�/�*�
)�
)�s
�	AD�Dc�.�|jdz}|j�|dzj�|dzj�|dzdzj�|dzdzj�|dzj�tj�}tjt|�|�|jd�tj|d�5}|j|j�gd	��ddd�y#1swYyxYw)
Nr�zed.py�bin�qux�bazrrr.)rzbin/zbin/bazzbin/quxr:)
rrr r/r0r!r"r#r1r2r3�assertEqualr5)rrr'�zfs    r�test_create_sorted_archivez%ZipAppTest.test_create_sorted_archive:s������x�'������	�(�	�!�!�#�	�%���� �	�%��%�	�&�&�(�	�%��%�	�&�&�(�	�-�	�&�&�(���������c�&�k�6�2����A��
�_�_�V�S�
)�R����R�[�[�]�G�
I�*�
)�
)�s�#D�Dc��d�}|jdz}|j�|dzj�|dzj�|dzj�|jdz}tj|||��tj|d�5}|jd|j��|jd|j��|jd|j��ddd�y#1swYyxYw)	Nc� �|jdk7S)Nz.pyc)�suffix��paths r�skip_pyc_fileszBZipAppTest.test_create_archive_with_filter.<locals>.skip_pyc_filesMs���;�;�&�(�(rrr�test.pyztest.pycr��filterr.)
rrr r!r"r2r3r4r5�assertNotIn)rrFrr'r7s     r�test_create_archive_with_filterz*ZipAppTest.test_create_archive_with_filterJs���	)����x�'������	�-�	�&�&�(�	�)�	�"�"�$�	�*�	�#�#�%����|�+�����f�f�^�D�
�_�_�V�S�
)�Q��M�M�-�����6��M�M�)�Q�Z�Z�\�2����Z�����6�*�
)�
)�s
�A!D�Dc�\�d�}|jdz}|j�|dzj�|dzj�|dzj�|dzdzj�|jdz}tj|||��tj|d	�5}|jt|j��d
�|jd|j��|jd|j��ddd�y#1swYyxYw)Nc�&�|jddk7S)Nr�dummy)�partsrDs r�skip_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�	&�-�-�/����|�+�����f�f�^�D�
�_�_�V�S�
)�Q����S�����.��2��M�M�-�����6��M�M�)�Q�Z�Z�\�2�*�
)�
)�s
�/A*D"�"D+c��|jdz}|j�|dzj�tjt|��|jdz}|j
|j��yrr)rr�expected_targets   r�"test_create_archive_default_targetz-ZipAppTest.test_create_archive_default_targetps_�����x�'������	�-�	�&�&�(����c�&�k�*��+�+��4������/�/�1�2rc��|jdz}|j�|dzj�|dzj�|jdz}tj||d��tj|d�5}dD];}|j|j|�jt
j��=	ddd�y#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_compressionys������x�'������	�-�	�&�&�(�	�)�	�"�"�$����|�+�����f�f��>�
�_�_�V�S�
)�Q�2��� � ����4��!>�!>�!(�!5�!5�7�3�*�
)�
)�s
�AC�Cc�>�|jdz}|j�|dzj�|jdz}|jtj
�5t	jt|�t|��ddd�y#1swYyxYw)Nr�foo.pyr�rrr �assertRaisesr!�ZipAppErrorr"r#r&s   r�test_no_mainzZipAppTest.test_no_main�sp�����x�'������	�(�	�!�!�#����|�+��
�
�
�v�1�1�
2��!�!�#�f�+�s�6�{�;�3�
2�
2�s�!)B�Bc�B�|jdz}|j�|dzj�|jdz}|jtj
�5t	jt|�t|�d��ddd�y#1swYyxYw)Nrrr�
pkg.mod:fn��mainr_r&s   r�test_main_and_main_pyz ZipAppTest.test_main_and_main_py�sr�����x�'������	�-�	�&�&�(����|�+��
�
�
�v�1�1�
2��!�!�#�f�+�s�6�{��N�3�
2�
2�s�!+B�Bc���|jdz}|j�|dzj�|jdz}tjt|�t|�d��t
jt|�d�5}|jd|j��|jd|jd��ddd�y#1swYyxYw)	Nrr^rrdrer.rspkg.mod.fn())rrr r!r"r#r2r3r4r5�readr6s    r�test_main_writtenzZipAppTest.test_main_written�s������x�'������	�(�	�!�!�#����|�+�����c�&�k�3�v�;�\�J�
�_�_�S��[�#�
.�!��M�M�-�����6��M�M�/�1�6�6�-�+@�A�/�
.�
.�s
�AC�Cc���|jdz}|j�|dzj�|dzj�|jdz}tjt|�t|�d��t
jt|�d�5}|jd|j�jd	��ddd�y#1swYyxYw)
Nrr^zbar.pyrrdrer.�r)rrr r!r"r#r2r3r>r5�countr6s    r�test_main_only_written_oncez&ZipAppTest.test_main_only_written_once�s������x�'������

�(�	�!�!�#�	�(�	�!�!�#����|�+�����c�&�k�3�v�;�\�J�
�_�_�S��[�#�
.�!����Q��
�
�� 2� 2�=� A�B�/�
.�
.�s�0C�C c	��|jdz}|j�|jdz}gd�}|D]o}|j|��5|jtj
�5t	jt|�t|�|��ddd�ddd��qy#1swY�xYw#1swY��xYw)Nrr)
�r,zfoo:z:barz12:barza.b.c.:dz.a:bza:b.za:.bza:silly namere)rr�subTestr`r!rar"r#)rrr'�problemsrfs     r�test_main_validationzZipAppTest.test_main_validation�s������x�'���������|�+��
���D����4��(��&�&�v�'9�'9�:��)�)�#�f�+�s�6�{��N�;�)�(��:�:��)�(�s$�
 B4�*+B(�B4�(B1�-B4�4B=	c�d�|jdz}|j�|dzj�|jdz}tjt|�t|��|j
d�5}|j|jd�d�ddd�y#1swYyxYw)Nrrr�rbrQ�#!)	rrr r!r"r#�open�assertNotEqualri�rrr'�fs    r�test_default_no_shebangz"ZipAppTest.test_default_no_shebang�s������x�'������	�-�	�&�&�(����|�+�����c�&�k�3�v�;�7�
�[�[��
�!�������q�	�5�1��
�
�s�;"B&�&B/c��|jdz}|j�|dzj�|jdz}tjt|�t|�d��|j
d�5}|j|jd�d�|jd	|j��ddd�y#1swYyxYw)
Nrrr�python��interpreterrurQrvspython
)
rrr r!r"r#rwr>ri�readlinerys    r�test_custom_interpreterz"ZipAppTest.test_custom_interpreter�s������x�'������	�-�	�&�&�(����|�+�����c�&�k�3�v�;�H�M�
�[�[��
�!����Q�V�V�A�Y��.����[�!�*�*�,�7��
�
�s
�=AC�Cc�.�|jdz}|j�|dzj�tj�}tjt|�|d��|j|j�jd��y)Nrrr}r~s	#!python
)rrr r/r0r!r"r#r$�getvalue�
startswithr&s   r�test_pack_to_fileobjzZipAppTest.test_pack_to_fileobj�si�����x�'������	�-�	�&�&�(���������c�&�k�6�x�H�������)�4�4�]�C�Drc�6�|jdz}|j�|dzj�|jdz}tjt|�t|�d��|j
tjt|��d�y�Nrrrr}r~�rrr r!r"r#r>�get_interpreterr&s   r�test_read_shebangzZipAppTest.test_read_shebang�sq�����x�'������	�-�	�&�&�(����|�+�����c�&�k�3�v�;�H�M�����/�/��F��<�h�Grc�2�|jdz}|j�|dzj�|jdz}tjt|�t|��|j
tjt|��d�yrr�r&s   r�test_read_missing_shebangz$ZipAppTest.test_read_missing_shebang�so�����x�'������	�-�	�&�&�(����|�+�����c�&�k�3�v�;�7�����/�/��F��<�d�Crc��|jdz}|j�|dzj�|jdz}tjt|�t|�d��|jdz}tjt|�t|�d��|j
tjt|��d�y)Nrrrr}r~�changed.pyz�	python2.7r��rrr'�
new_targets    r�test_modify_shebangzZipAppTest.test_modify_shebang�s������x�'������	�-�	�&�&�(����|�+�����c�&�k�3�v�;�H�M��[�[�=�0�
����c�&�k�3�z�?��T�����/�/��J��@�+�Nrc��|jdz}|j�|dzj�|jdz}tjt|�t|�d��t
j�}tjt|�|d��|j|j�jd��y)Nrrrr}r~r��#!python2.7
)rrr r!r"r#r/r0r$r�r�r�s    r�test_write_shebang_to_fileobjz(ZipAppTest.test_write_shebang_to_fileobjs������x�'������	�-�	�&�&�(����|�+�����c�&�k�3�v�;�H�M��Z�Z�\�
����c�&�k�:�;�O����
�+�+�-�8�8�9I�J�Krc��|jdz}|j�|dzj�tjt|��}tjt|jdz��}tjt|jdz��}t
j||d��t
j||d��|jt
j|�d�y)Nrrztarget1.pyzztarget2.pyzr}r~r�)
rrr r�FakePathr#r!r"r>r�)rr�target1�target2s    r�test_read_from_pathlike_objz&ZipAppTest.test_read_from_pathlike_objs������x�'������	�-�	�&�&�(��#�#�C��K�0���$�$�S����}�)D�%E�F���$�$�S����}�)D�%E�F�����f�g�8�D����g�w�K�H�����/�/��8�+�Frc���|jdz}|j�|dzj�|jdz}tj�}tjt|�|d��tj�}|jd�tj||d��|j|j�jd��y)	Nrrrr}r~rr�r�)rrr r/r0r!r"r#r1r$r�r�)rrr'�temp_archiver�s     r�test_read_from_fileobjz!ZipAppTest.test_read_from_fileobjs������x�'������	�-�	�&�&�(����|�+���z�z�|�����c�&�k�<�X�N��Z�Z�\�
����!�����l�J�K�P����
�+�+�-�8�8�9I�J�Krc��|jdz}|j�|dzj�|jdz}tjt|�t|�d��|jdz}tjt|�t|�d��|j
tjt|��d�y)Nrrrr}r~r�r�r�s    r�test_remove_shebangzZipAppTest.test_remove_shebang&s������x�'������	�-�	�&�&�(����|�+�����c�&�k�3�v�;�H�M��[�[�=�0�
����c�&�k�3�z�?��M�����/�/��J��@�$�Grc��|jdz}|j�|dzj�tj�}tjt|�|d��tj�}|jd�tj||d��|jd�tj|d�5}|jt|j��dh�ddd�y#1swYyxYw)Nrrr}r~rr.)rrr r/r0r!r"r#r1r2r3r>�setr5)rrr'r�r7s     r�test_content_of_copied_archivez)ZipAppTest.test_content_of_copied_archive1s������x�'������	�-�	�&�&�(���������c�&�k�6�x�H��Z�Z�\�
����A�����f�j�d�C������
�_�_�Z��
-�����S�����.���@�.�
-�
-�s�+D�D	�win32z*Windows does not support an executable bitc�N�|jdz}|j�|dzj�|jdz}tjt|�t|�d��|j
|j�jtjz�yr�)
rrr r!r"r#r$�stat�st_mode�S_IEXECr&s   r�test_shebang_is_executablez%ZipAppTest.test_shebang_is_executable@su��
���x�'������	�-�	�&�&�(����|�+�����c�&�k�3�v�;�H�M�������
�-�-����<�=rc�N�|jdz}|j�|dzj�|jdz}tjt|�t|�d��|j
|j�jtjz�y)Nrrrr~)
rrr r!r"r#�assertFalser�r�r�r&s   r�!test_no_shebang_is_not_executablez,ZipAppTest.test_no_shebang_is_not_executableLsw�����x�'������	�-�	�&�&�(����|�+�����c�&�k�3�v�;�D�I��������.�.����=�>rN)%�__name__�
__module__�__qualname__rr(r*r8r@rKrSrVrr\rbrgrjrnrsr{r�r�r�r�r�r�r�r�r�r��unittest�skipIf�sys�platformr�skip_unless_working_chmodr�r��rrrrs
��+�0�
*�*�
0�I� 7�$3�(3��_�7��7�<�O�	B�C�"O�2�
8�E�H�D�	O�
L�G�L�	H�A��X�_�_�S�\�\�W�,�A�C��(�(�>�)�C�>��X�_�_�S�\�\�W�,�A�C�?�C�?rrc�l�eZdZ	d�Zd�Zd�Zd�Zd�Zd�Ze	de
j��d	��Zd
�Z
y)�ZipAppCmdlineTestc��tj�}|j|j�t	j
|j�|_yr	r
rs  rrzZipAppCmdlineTest.setUp\rrc��|jdz}|j�|dzj�|jdz}tj||�|Sr)rrr r!r"r&s   r�make_archivezZipAppCmdlineTest.make_archiveasM�����x�'������	�-�	�&�&�(����|�+�����f�f�-��
rc�
�|jdz}|j�|dzj�t|�g}t	j
|�|j
d�}|j|j��y)Nrrz.pyz)	rrr r#r!rf�with_suffixr$r%)rr�argsr's    r�test_cmdline_createz%ZipAppCmdlineTest.test_cmdline_createjsd�����x�'������	�-�	�&�&�(��F��}�����D���#�#�F�+��������(�)rc���|j�}|jdz}t|�dt|�g}tj|�|j|j
��y�N�
target.pyz�-o)r�rr#r!rfr$r%)r�originalr'r�s    r�test_cmdline_copyz#ZipAppCmdlineTest.test_cmdline_copytsQ���$�$�&�����|�+���H�
�t�S��[�1�����D��������(�)rc�8�|j�}|jdz}t|�dt|�g}|jt�5}tj|�ddd�|jjj�y#1swY�/xYwr��
r�rr#r`�
SystemExitr!rfr$�	exception�code�rr�r'r��cms     r�test_cmdline_copy_inplacez+ZipAppCmdlineTest.test_cmdline_copy_inplace|st���$�$�&�����|�+���H�
�t�S��]�3��
�
�
�z�
*�b��K�K���+�	
������)�)�*�+�
*�s�B�Bc�<�|j�}|jdz}t|�dt|�ddg}|jt�5}tj|�ddd�|jjj�y#1swY�/xYw)Nr�r�z-mzfoo:barr�r�s     r�test_cmdline_copy_change_mainz/ZipAppCmdlineTest.test_cmdline_copy_change_main�sx���$�$�&�����|�+���H�
�t�S��[�$�	�B��
�
�
�z�
*�b��K�K���+�	
������)�)�*�+�
*�s�B�Bz
sys.stdout)�new_callablec�H�|j�}t|�dg}|jt�5}t	j
|�ddd�|j
jjd�|j
|j�d�y#1swY�PxYw)N�--inforzInterpreter: <none>
)
r�r#r`r�r!rfr>r�r�r�)r�mock_stdoutr'r�r�s     r�test_info_commandz#ZipAppCmdlineTest.test_info_command�s����"�"�$���F��X�&��
�
�
�z�
*�b��K�K���+�	
������*�*�A�.�����-�-�/�1H�I�	+�
*�s�B�B!c��|jdz}t|�dg}|jt�5}t	j
|�ddd�|j
jj�y#1swY�/xYw)Nz	dummy.pyzr�)	rr#r`r�r!rfr$r�r�)rr'r�r�s    r�test_info_errorz!ZipAppCmdlineTest.test_info_error�s`�����{�*���F��X�&��
�
�
�z�
*�b��K�K���+�	
������)�)�*�+�
*�s�A6�6A?N)r�r�r�rr�r�r�r�r�rr/�StringIOr�r�r�rrr�r�XsI��.�0�
�*�*�+�+��<�b�k�k�2�J�3�J�+rr��__main__)r/rr�r�rr�r!r2�test.supportrr�
unittest.mockr�TestCaserr�r�rfr�rr�<module>r�sm��)�	���
���
��&�"��E?��"�"�E?�P
J+��)�)�J+�Z�z���H�M�M�O�r

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