Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/test/test_importlib/resources/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/test/test_importlib/resources/__pycache__/test_files.cpython-312.pyc

�

)Μg�����ddlZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddl	mZddl	mZddl
mZdd	l
mZej d
��ZGd�d�ZGd
�deej&�ZGd�deej*ej&�ZGd�deej&�ZGd�d�ZGd�deej&�ZGd�deej&�Zedk(rej8�yy)�N)�	resources)�Traversable�)�data01)�util)�_path)�	os_helper)�
import_helperc#�K�tjd��5}tjdt��|��ddd�y#1swYyxYw�w)NT)�record�default)�category)�warnings�catch_warnings�simplefilter�DeprecationWarning)�ctxs �E/usr/local/lib/python3.12/test/test_importlib/resources/test_files.py�suppress_known_deprecationrs7����	�	 �	 ��	-�����i�2D�E��	�
.�	-�	-�s�A� A�	A�A�Ac�^�eZdZd�Zd�Zejeed�d�d��Z	d�Z
y)�
FilesTestsc��tj|j�}|jd�j	�}|dk(sJ�y)N�
utf-8.filesHello, UTF-8 world!
)r�files�data�joinpath�
read_bytes��selfr�actuals   r�test_read_byteszFilesTests.test_read_bytess:������	�	�*������-�8�8�:���1�1�1�1�c��tj|j�}|jd�j	d��}|dk(sJ�y)Nr�utf-8��encodingzHello, UTF-8 world!
)rrrr�	read_textrs   r�test_read_textzFilesTests.test_read_texts?������	�	�*������-�7�7��7�I���0�0�0�0r"�runtime_checkablez4Only suitable when typing supports runtime_checkablec�b�ttj|j�t�sJ�y�N)�
isinstancerrrr�rs r�test_traversablezFilesTests.test_traversable#s!��
�)�/�/�$�)�)�4�k�B�B�Br"c��t�5tj|j��ddd�y#1swYyxYw)zx
        Files used to take a 'package' parameter. Make sure anyone
        passing by name is still supported.
        )�packageN)rrrrr-s r�test_old_parameterzFilesTests.test_old_parameter*s&��
(�
)��O�O�D�I�I�.�*�
)�
)�s�!5�>N)�__name__�
__module__�__qualname__r!r(�unittest�
skipUnless�hasattr�typingr.r1�r"rrrsB��2�
1�
�X�����+�,�>��C�	�C�/r"rc��eZdZd�Zy)�
OpenDiskTestsc��t|_yr+)rrr-s r�setUpzOpenDiskTests.setUp4s	����	r"N�r2r3r4r=r9r"rr;r;3s��r"r;c��eZdZy)�OpenZipTestsN)r2r3r4r9r"rr@r@8s��r"r@c��eZdZd�Zy)�OpenNamespaceTestsc��ddlm}||_y)Nr)�namespacedata01)�rDr)rrDs  rr=zOpenNamespaceTests.setUp=s��%�#��	r"Nr>r9r"rrBrB<s��$r"rBc��eZdZd�Zy)�SiteDirc��tj�|_|j|jj�|jjt
j��|_|jjtj|j��|jjtj��yr+)�
contextlib�	ExitStack�fixtures�
addCleanup�close�
enter_contextr	�temp_dir�site_dirr
�
DirsOnSysPath�isolated_modulesr-s rr=z
SiteDir.setUpDs���"�,�,�.��
�����
�
�+�+�,��
�
�3�3�I�4F�4F�4H�I��
��
�
�#�#�M�$?�$?��
�
�$N�O��
�
�#�#�M�$B�$B�$D�Er"Nr>r9r"rrGrGCs��Fr"rGc��eZdZd�Zy)�ModulesFilesTestsc���ddd�}tj||j�ddl}t	j
|�j
d�jd��}||dk(sJ�y)	zK
        A module can have resources found adjacent to the module.
        rE�resources are the best)zmod.py�res.txtrNrWr$r%)r�buildrP�modrrrr')r�specrYr s    r�test_module_resourcesz'ModulesFilesTests.test_module_resourcesMsa��
�/�
��	���D�$�-�-�(������%�.�.�y�9�C�C�W�C�U����i��(�(�(r"N)r2r3r4r[r9r"rrTrTLs��)r"rTc��eZdZd�Zd�Zy)�ImplicitContextFilesTestsc��dtjd�dd�i}tj||j�tjd�jdk(sJ�y)zW
        Without any parameter, files() will infer the location as the caller.
        �somepkgz�
                    import importlib.resources as res
                    val = res.files().joinpath('res.txt').read_text(encoding='utf-8')
                    rV)�__init__.pyrWN)�textwrap�dedentrrXrP�	importlib�
import_module�val)rrZs  r�test_implicit_filesz-ImplicitContextFilesTests.test_implicit_files]s]��

�'���� �4��

��	���D�$�-�-�(��&�&�y�1�5�5�9Q�Q�Q�Qr"c�����ddl�ddl���fd�}tjd�}d||dd�i}|jjt
j��}tj||��jj|jd�}|||�|jjtj|��tj d	�j"dk(sJ�y)
z=
        Special test for gh-121735 for Python 3.12.
        rNc�,���
j|d�5}�	j|�D]W\}}}|D]L}�	jj||�}�	jj	||�}|j||��N�Y	ddd�y#1swYyxYw)N�w)�ZipFile�walk�path�join�relpath�write)�
source_dir�zip_filename�zipf�root�_r�file�	file_path�arcname�os�zipfiles         ��r�create_zip_from_directoryz^ImplicitContextFilesTests.test_implicit_files_zip_submodule.<locals>.create_zip_from_directoryvsx�������s�3�t�&(�g�g�j�&9�N�D�!�U� %��$&�G�G�L�L��t�$<�	�"$�'�'�/�/�)�Z�"H���
�
�9�g�6�	!&�':�4�3�3�s�A,B
�
Bz�
            import importlib.resources as res
            val = res.files().joinpath('res.txt').read_text(encoding='utf-8')
            r_rV)r`z	submod.pyrWz
thepkg.zipzsomepkg.submod)rxryrarbrKrNr	rOrrXrlrmrPr
rQrcrdre)rrz�set_valrZ�	build_dir�zip_filerxrys      @@r�!test_implicit_files_zip_submodulez;ImplicitContextFilesTests.test_implicit_files_zip_submoduleos����	��	7��/�/�
�
��
�&�$�3��
���M�M�/�/�	�0B�0B�0D�E�	�
���D�)�$��7�7�<�<��
�
�|�<��!�)�X�6��
�
�#�#�M�$?�$?��$I�J��&�&�'7�8�<�<�@X�X�X�Xr"N)r2r3r4rfr~r9r"rr]r]\s��R�$"Yr"r]�__main__)r8rar5rrcrIr�importlib.resources.abcrrErrr�test.supportr	r
�contextmanagerrr�TestCaser;�ZipSetupr@rBrGrTr]r2�mainr9r"r�<module>r�s���
�������/����"�&�������/�/�6�J�� 1� 1��
	�:�t�}�}�h�.?�.?�	�$��X�%6�%6�$�F�F�
)���!2�!2�
)� 5Y���):�):�5Y�p�z���H�M�M�O�r"

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