
    XIg                     6   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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j0                  ej,                        Z G d deej*                  ej,                        Z G d deej0                  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j0                  eej,                        Z G d d      Z  G d deej*                  e ej,                        Z! G d deej0                  e ej,                        Z"e#d k(  r ejH                          yy)!    N   )Traversable   )util)	os_helperimport_helperc               #      K   t        j                  d      5 } t        j                  dt               |  d d d        y # 1 sw Y   y xY ww)NT)recorddefault)category)warningscatch_warningssimplefilterDeprecationWarning)ctxs    a/var/www/html/answerous/venv/lib/python3.12/site-packages/importlib_resources/tests/test_files.pysuppress_known_deprecationr      s@     		 	 	- i2DE	  s   A A	AAAc                   *    e Zd Zd Zd Zd Zd Zd Zy)
FilesTestsc                     t        j                  | j                        }|j                  d      j	                         }|dk(  sJ y )N
utf-8.files   Hello, UTF-8 world!
)	resourcesfilesdatajoinpath
read_bytesselfr   actuals      r   test_read_byteszFilesTests.test_read_bytes   s:    		*-88:1111    c                     t        j                  | j                        }|j                  d      j	                  d      }|dk(  sJ y )Nr   utf-8encodingzHello, UTF-8 world!
)r   r   r   r   	read_textr   s      r   test_read_textzFilesTests.test_read_text   s?    		*-777I0000r!   c                 b    t        t        j                  | j                        t              sJ y N)
isinstancer   r   r   r   r   s    r   test_traversablezFilesTests.test_traversable#   s    )//$))4kBBBr!   c                     t        j                  | j                        }|j                  dd      }| j	                  |j                                y )Nsubdirectoryzbinary.file)r   r   r   r   
assertTrueis_file)r   r   binfiles      r    test_joinpath_with_multiple_argsz+FilesTests.test_joinpath_with_multiple_args&   s7    		*..?)*r!   c                     t               5  t        j                  | j                         ddd       y# 1 sw Y   yxY w)zx
        Files used to take a 'package' parameter. Make sure anyone
        passing by name is still supported.
        )packageN)r   r   r   r   r+   s    r   test_old_parameterzFilesTests.test_old_parameter+   s/    
 () 	/OODII.	/ 	/ 	/s   !5>N)__name__
__module____qualname__r    r'   r,   r2   r5    r!   r   r   r      s    2
1
C+
/r!   r   c                       e Zd Zy)OpenDiskTestsNr6   r7   r8   r9   r!   r   r;   r;   4       r!   r;   c                       e Zd Zy)OpenZipTestsNr<   r9   r!   r   r?   r?   8   r=   r!   r?   c                       e Zd ZdZd Zy)OpenNamespaceTestsnamespacedata01c                 l    ddl }|j                  j                  d       t        j                  |       y)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__)rB   __path__appendr   r   )r   rB   s     r   test_non_paths_in_dunder_pathz0OpenNamespaceTests.test_non_paths_in_dunder_path?   s,     	  ''D	
 	(r!   N)r6   r7   r8   MODULErF   r9   r!   r   rA   rA   <   s    F)r!   rA   c                       e Zd ZdZy)OpenNamespaceZipTestsrB   N)r6   r7   r8   
ZIP_MODULEr9   r!   r   rI   rI   T   s    "Jr!   rI   c                       e Zd ZdZdZd Zy)
DirectSpeczI
    Override behavior of ModuleSetup to write a full spec directly.
    unusedc                 :    | j                  | j                         y r)   )tree_on_pathspec)r   names     r   load_fixturezDirectSpec.load_fixture_   s    $))$r!   N)r6   r7   r8   __doc__rG   rR   r9   r!   r   rL   rL   X   s     F%r!   rL   c                       e Zd ZdddZd Zy)ModulesFiles resources are the best)zmod.pyres.txtc                     ddl }t        j                  |      j                  d      j	                  d      }|| j
                  d   k(  sJ y)zK
        A module can have resources found adjacent to the module.
        r   NrX   r#   r$   )modr   r   r   r&   rP   )r   rZ   r   s      r   test_module_resourcesz"ModulesFiles.test_module_resourcesi   sE     	%..y9CCWCU9----r!   N)r6   r7   r8   rP   r[   r9   r!   r   rU   rU   c   s    +D
.r!   rU   c                       e Zd Zy)ModuleFilesDiskTestsNr<   r9   r!   r   r]   r]   s   r=   r!   r]   c                       e Zd Zy)ModuleFilesZipTestsNr<   r9   r!   r   r_   r_   w   r=   r!   r_   c                       e Zd Z ej                  dej                    d      Zeeddej                  ej                   d      dddZd Z	d	 Z
d
 Zd Zy)ImplicitContextFilesz
        import zZ as res
        val = res.files().joinpath('res.txt').read_text(encoding='utf-8')
        rW   )__init__.pyz	submod.pyrX   c_resources)rb   rX   )somepkg	frozenpkgc                 L    t        j                  d      j                  dk(  sJ y)W
        Without any parameter, files() will infer the location as the caller.
        rd   rW   N	importlibimport_modulevalr+   s    r   test_implicit_files_packagez0ImplicitContextFiles.test_implicit_files_package   s$     &&y1559QQQQr!   c                 L    t        j                  d      j                  dk(  sJ y)rg   zsomepkg.submodrW   Nrh   r+   s    r   test_implicit_files_submodulez2ImplicitContextFiles.test_implicit_files_submodule   s%     &&'78<<@XXXXr!   c                 x   | j                   j                  t        j                               }t	        j
                  |d      }t	        j
                  t        j                        j                  }t        j                  ||d        t        j                  |      D ]k  \  }}}|D ]`  }t	        j
                  |      |z  }|j                  d      }	t        j                  ||	       t        j
                  j!                  |       b m | j                   j                  t#        j$                  |             y)zO
        Make a compiled-only copy of the importlib resources package.
        rc   c                      dgS )N__pycache__r9   )_s    r   <lambda>z9ImplicitContextFiles._compile_importlib.<locals>.<lambda>   s     r!   )ignorez.pycN)fixturesenter_contextr   temp_dirpathlibPathr   __file__parentshutilcopytreeoswalkwith_suffix
py_compilecompileunlinkr   DirsOnSysPath)
r   bin_siterc   sourcesdirpathrr   	filenamesfilenamesource_pathcfiles
             r   _compile_importlibz'ImplicitContextFiles._compile_importlib   s     ==..y/A/A/CDll8];,,y112995OP%'WW[%9 	1!GQ	% 1%ll73h>#//7"";6##K0	1	1 	##M$?$?$IJr!   c                 l    | j                          t        j                  d      j                  dk(  sJ y)zk
        Caller detection works for compiled-only resources module.

        python/cpython#123085
        re   rW   N)r   ri   rj   rk   r+   s    r   +test_implicit_files_with_compiled_importlibz@ImplicitContextFiles.test_implicit_files_with_compiled_importlib   s0     	!&&{377;SSSSr!   N)r6   r7   r8   textwrapdedentr   set_valreplacerP   rl   rn   r   r   r9   r!   r   ra   ra   {   sz    hoo""# $		G # /
 #??9+=+=}M/

DRYK"Tr!   ra   c                       e Zd Zy)ImplicitContextFilesDiskTestsNr<   r9   r!   r   r   r           	r!   r   c                       e Zd Zy)ImplicitContextFilesZipTestsNr<   r9   r!   r   r   r      r   r!   r   __main__)%r~   rx   r   r|   r   unittestr   ri   
contextlibimportlib_resourcesr   abcr   rV   r   compat.py39r   r   contextmanagerr   r   	DiskSetupTestCaser;   ZipSetupr?   rA   rI   rL   rU   r]   r_   ra   r   r   r6   mainr9   r!   r   <module>r      sg   	         '   1  / /8	J0A0A 		:t}}h.?.? 	)T^^X5F5F )0#Jx7H7H #% %. . 	:t~~|XEVEV 		*dmm\8CTCT 	7T 7Tt	 4h6G6G		3X5F5F	 zHMMO r!   