
    Xj_                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZddl	m
Z
 ddlmZ ddlmZmZ e j        d             Z G d d	          Z G d
 deej        ej                  Z G d deej        ej                  Z G d deej        ej                  Z G d deej        ej                  Z G d d          Z G d d          Z G d deej        eej                  Z G d deej        eej                  Z G d d          Z G d deej        eej                  Z G d deej        eej                  Z e!d k    r ej"                     dS dS )!    N   )Traversable   )util)import_helper	os_helperc               #      K   t          j        d          5 } t          j        dt                     | V  d d d            d S # 1 swxY w Y   d S )NT)recorddefault)category)warningscatch_warningssimplefilterDeprecationWarning)ctxs    a/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/importlib_resources/tests/test_files.pysuppress_known_deprecationr      s      		 	-	-	- i2DEEEE			                 s    AA	A	c                   &    e Zd Zd Zd Zd Zd ZdS )
FilesTestsc                     t          j        | j                  }|                    d                                          }|dk    sJ d S )N
utf-8.files   Hello, UTF-8 world!
)	resourcesfilesdatajoinpath
read_bytesselfr   actuals      r   test_read_byteszFilesTests.test_read_bytes   sH    	**--88::1111111    c                     t          j        | j                  }|                    d                              d          }|dk    sJ d S )Nr   utf-8encodingzHello, UTF-8 world!
)r   r   r   r   	read_textr   s      r   test_read_textzFilesTests.test_read_text   sM    	**--777II0000000r!   c                 b    t          t          j        | j                  t                    sJ d S N)
isinstancer   r   r   r   r   s    r   test_traversablezFilesTests.test_traversable"   s*    )/$)44kBBBBBBBr!   c                     t          j        | j                  }|                    dd          }|                                sJ d S )Nsubdirectoryzbinary.file)r   r   r   r   is_file)r   r   binfiles      r    test_joinpath_with_multiple_argsz+FilesTests.test_joinpath_with_multiple_args%   sB    	**..??       r!   N)__name__
__module____qualname__r    r'   r,   r1    r!   r   r   r      sS        2 2 2
1 1 1
C C C! ! ! ! !r!   r   c                       e Zd ZdS )OpenDiskTestsNr2   r3   r4   r5   r!   r   r7   r7   +           Dr!   r7   c                       e Zd ZdS )OpenZipTestsNr8   r5   r!   r   r;   r;   /   r9   r!   r;   c                       e Zd ZdZd ZdS )OpenNamespaceTestsnamespacedata01c                 j    ddl }|j                            d           t          j        |           dS )a  
        Non-path items in a namespace package's ``__path__`` are ignored.

        As reported in python/importlib_resources#311, some tools
        like Setuptools, when creating editable packages, will inject
        non-paths into a namespace package's ``__path__``, a
        sentinel like
        ``__editable__.sample_namespace-1.0.finder.__path_hook__``
        to cause the ``PathEntryFinder`` to be called when searching
        for packages. In that case, resources should still be loadable.
        r   Nz6__editable__.sample_namespace-1.0.finder.__path_hook__)r>   __path__appendr   r   )r   r>   s     r   test_non_paths_in_dunder_pathz0OpenNamespaceTests.test_non_paths_in_dunder_path6   sF     	 ''D	
 	
 	
 	(((((r!   N)r2   r3   r4   MODULErB   r5   r!   r   r=   r=   3   s(        F) ) ) ) )r!   r=   c                       e Zd ZdZdS )OpenNamespaceZipTestsr>   N)r2   r3   r4   
ZIP_MODULEr5   r!   r   rE   rE   K   s        "JJJr!   rE   c                       e Zd ZdZdZd ZdS )
DirectSpeczI
    Override behavior of ModuleSetup to write a full spec directly.
    unusedc                 :    |                      | j                   d S r)   )tree_on_pathspec)r   names     r   load_fixturezDirectSpec.load_fixtureV   s    $)$$$$$r!   N)r2   r3   r4   __doc__rC   rN   r5   r!   r   rH   rH   O   s4          F% % % % %r!   rH   c                       e Zd ZdddZd ZdS )ModulesFiles resources are the best)zmod.pyres.txtc                     ddl }t          j        |                              d                              d          }|| j        d         k    sJ dS )zK
        A module can have resources found adjacent to the module.
        r   NrT   r#   r$   )modr   r   r   r&   rL   )r   rV   r   s      r   test_module_resourcesz"ModulesFiles.test_module_resources`   sY     	


%%..y99CCWCUU9-------r!   N)r2   r3   r4   rL   rW   r5   r!   r   rQ   rQ   Z   s5        + D
. . . . .r!   rQ   c                       e Zd ZdS )ModuleFilesDiskTestsNr8   r5   r!   r   rY   rY   j   r9   r!   rY   c                       e Zd ZdS )ModuleFilesZipTestsNr8   r5   r!   r   r[   r[   n   r9   r!   r[   c                       e Zd Z ej        dej          d          Zeedde                    ej         d          dddZd Z	d	 Z
d
 Zd ZdS )ImplicitContextFilesz
        import zZ as res
        val = res.files().joinpath('res.txt').read_text(encoding='utf-8')
        rS   )__init__.pyz	submod.pyrT   c_resources)r^   rT   )somepkg	frozenpkgc                 D    t          j        d          j        dk    sJ dS )W
        Without any parameter, files() will infer the location as the caller.
        r`   rS   N	importlibimport_modulevalr+   s    r   test_implicit_files_packagez0ImplicitContextFiles.test_implicit_files_package   s*     &y1159QQQQQQQr!   c                 D    t          j        d          j        dk    sJ dS )rc   zsomepkg.submodrS   Nrd   r+   s    r   test_implicit_files_submodulez2ImplicitContextFiles.test_implicit_files_submodule   s+     &'788<@XXXXXXXr!   c                    | j                             t          j                              }t	          j        |d          }t	          j        t          j                  j        }|	                    d          D ]R}|
                    |                    |                                        d          }t          j        ||           S| j                             t          j        |                     dS )z
        Make a compiled-only copy of the importlib resources package.

        Currently only code is copied, as importlib resources doesn't itself
        have any resources.
        r_   z**/*.pyz.pycN)fixturesenter_contextr   temp_dirpathlibPathr   __file__parentglobr   relative_towith_suffix
py_compilecompiler   DirsOnSysPath)r   bin_siter_   sourcessource_pathc_paths         r   _compile_importlibz'ImplicitContextFiles._compile_importlib   s     =..y/A/C/CDDl8];;,y1229"<<	22 	4 	4K ))+*A*A'*J*JKKWW F {F3333##M$?$I$IJJJJJr!   c                 l    |                                   t          j        d          j        dk    sJ dS )zk
        Caller detection works for compiled-only resources module.

        python/cpython#123085
        ra   rS   N)r}   re   rf   rg   r+   s    r   +test_implicit_files_with_compiled_importlibz@ImplicitContextFiles.test_implicit_files_with_compiled_importlib   s<     	!!!&{337;SSSSSSSr!   N)r2   r3   r4   textwrapdedentr   set_valreplacerL   rh   rj   r}   r   r5   r!   r   r]   r]   r   s        ho	"	 	 	 G # /
 
 #??9+=}MM/
 

 
DR R RY Y YK K K$T T T T Tr!   r]   c                       e Zd ZdS )ImplicitContextFilesDiskTestsNr8   r5   r!   r   r   r               	Dr!   r   c                       e Zd ZdS )ImplicitContextFilesZipTestsNr8   r5   r!   r   r   r      r   r!   r   __main__)#
contextlibre   ro   rv   r   unittestr   importlib_resourcesr   abcr   rR   r   compat.py39r   r   contextmanagerr   r   	DiskSetupTestCaser7   ZipSetupr;   r=   rE   rH   rQ   rY   r[   r]   r   r   r2   mainr5   r!   r   <module>r      s'                   ' ' ' '             1 1 1 1 1 1 1 1   ! ! ! ! ! ! ! !(	 	 	 	 	J0A 	 	 		 	 	 	 	:t}h.? 	 	 	) ) ) ) )T^X5F ) ) )0# # # # #Jx7H # # #% % % % % % % %. . . . . . . . 	 	 	 	 	:t~|XEV 	 	 		 	 	 	 	*dm\8CT 	 	 	8T 8T 8T 8T 8T 8T 8T 8Tv	 	 	 	 	 4h6G	 	 		 	 	 	 	3X5F	 	 	 zHMOOOOO r!   