
    2im                     (   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrSSK	J
r
  SSKJr  SSKJrJr  \ R                   S 5       r " S S	5      r " S
 S\\R&                  \R(                  5      r " S S\\R,                  \R(                  5      r " S S\\R&                  \R(                  5      r " S S\\R,                  \R(                  5      r " S S5      r " S S5      r " S S\\R&                  \\R(                  5      r " S S\\R,                  \\R(                  5      r " S S5      r " S S\\R&                  \\R(                  5      r " S S\\R,                  \\R(                  5      r \!S :X  a  \RD                  " 5         gg)!    N   )Traversable   )util)import_helper	os_helperc               #      #    [         R                  " SS9 n [         R                  " S[        S9  U v   S S S 5        g ! , (       d  f       g = f7f)NT)recorddefault)category)warningscatch_warningssimplefilterDeprecationWarning)ctxs    ^/home/james-whalen/.local/lib/python3.13/site-packages/importlib_resources/tests/test_files.pysuppress_known_deprecationr      s6     		 	 	-i2DE	 
.	-	-s   A>	A
AAc                   2    \ rS rSrS rS rS rS rS rSr	g)	
FilesTests   c                     [         R                  " U R                  5      nUR                  S5      R	                  5       nUS:X  d   eg )N
utf-8.files   Hello, UTF-8 world!
)	resourcesfilesdatajoinpath
read_bytesselfr   actuals      r   test_read_bytesFilesTests.test_read_bytes   s:    		*-88:1111    c                     [         R                  " U R                  5      nUR                  S5      R	                  SS9nUS:X  d   eg )Nr   utf-8encodingzHello, UTF-8 world!
)r   r   r   r   	read_textr   s      r   test_read_textFilesTests.test_read_text   s?    		*-777I0000r#   c                 n    [        [        R                  " U R                  5      [        5      (       d   eg N)
isinstancer   r   r   r   r   s    r   test_traversableFilesTests.test_traversable"   s"    )//$))4kBBBBr#   c                     [         R                  " U R                  5      nUR                  SS5      nU R	                  UR                  5       5        g )Nsubdirectoryzbinary.file)r   r   r   r   
assertTrueis_file)r   r   binfiles      r    test_joinpath_with_multiple_args+FilesTests.test_joinpath_with_multiple_args%   s7    		*..?)*r#   c                     [        5          [        R                  " U R                  S9  SSS5        g! , (       d  f       g= f)z`
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_parameterFilesTests.test_old_parameter*   s&    
 ()OODII. *))s	   3
A N)
__name__
__module____qualname____firstlineno__r!   r)   r/   r6   r:   __static_attributes__r<   r#   r   r   r      s    2
1
C+
/r#   r   c                       \ rS rSrSrg)OpenDiskTests3   r<   Nr=   r>   r?   r@   rA   r<   r#   r   rC   rC   3       r#   rC   c                       \ rS rSrSrg)OpenZipTests7   r<   NrE   r<   r#   r   rH   rH   7   rF   r#   rH   c                       \ rS rSrSrS rSrg)OpenNamespaceTests;   namespacedata01c                 n    SSK nUR                  R                  S5        [        R                  " U5        g)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__)rM   __path__appendr   r   )r   rM   s     r   test_non_paths_in_dunder_path0OpenNamespaceTests.test_non_paths_in_dunder_path>   s,     	  ''D	
 	(r#   r<   N)r=   r>   r?   r@   MODULErQ   rA   r<   r#   r   rK   rK   ;   s    F)r#   rK   c                       \ rS rSrSrSrg)OpenNamespaceZipTestsS   rM   r<   N)r=   r>   r?   r@   
ZIP_MODULErA   r<   r#   r   rU   rU   S   s    "Jr#   rU   c                   "    \ rS rSrSrSrS rSrg)
DirectSpecW   zA
Override behavior of ModuleSetup to write a full spec directly.
unusedc                 :    U R                  U R                  5        g r,   )tree_on_pathspec)r   names     r   load_fixtureDirectSpec.load_fixture^   s    $))$r#   r<   N)r=   r>   r?   r@   __doc__rS   r`   rA   r<   r#   r   rY   rY   W   s     F%r#   rY   c                   $    \ rS rSrSSS.rS rSrg)ModulesFilesb    resources are the best)zmod.pyres.txtc                     SSK n[        R                  " U5      R                  S5      R	                  SS9nX R
                  S   :X  d   eg)z;
A module can have resources found adjacent to the module.
r   Nrh   r%   r&   )modr   r   r   r(   r^   )r   rj   r    s      r   test_module_resources"ModulesFiles.test_module_resourcesh   sC     	%..y9CCWCU9----r#   r<   N)r=   r>   r?   r@   r^   rk   rA   r<   r#   r   rd   rd   b   s    +D
.r#   rd   c                       \ rS rSrSrg)ModuleFilesDiskTestsr   r<   NrE   r<   r#   r   rn   rn   r   rF   r#   rn   c                       \ rS rSrSrg)ModuleFilesZipTestsv   r<   NrE   r<   r#   r   rq   rq   v   rF   r#   rq   c                       \ rS rSr\R
                  " S\R                    S35      r\\SS.\R                  \R                   S5      SS.S.r	S	 r
S
 rS rS rSrg)ImplicitContextFilesz   z
        import zZ as res
        val = res.files().joinpath('res.txt').read_text(encoding='utf-8')
        rg   )__init__.pyz	submod.pyrh   c_resources)rv   rh   )somepkg	frozenpkgc                 P    [         R                  " S5      R                  S:X  d   eg)G
Without any parameter, files() will infer the location as the caller.
rx   rg   N	importlibimport_modulevalr.   s    r   test_implicit_files_package0ImplicitContextFiles.test_implicit_files_package   s$     &&y1559QQQQr#   c                 P    [         R                  " S5      R                  S:X  d   eg)r{   zsomepkg.submodrg   Nr|   r.   s    r   test_implicit_files_submodule2ImplicitContextFiles.test_implicit_files_submodule   s%     &&'78<<@XXXXr#   c                    U R                   R                  [        R                  " 5       5      n[        R
                  " US5      n[        R
                  " [        R                  5      R                  nUR                  S5       HH  nUR                  UR                  U5      5      R                  S5      n[        R                  " XE5        MJ     U R                   R                  [        R                   " U5      5        g)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.
rw   z**/*.pyz.pycN)fixturesenter_contextr   temp_dirpathlibPathr   __file__parentglobr   relative_towith_suffix
py_compilecompiler   DirsOnSysPath)r   bin_siterw   sourcessource_pathc_paths         r   _compile_importlib'ImplicitContextFiles._compile_importlib   s     ==..y/A/A/CDll8];,,y11299"<<	2K ))+*A*A'*JKWWF {3	 3
 	##M$?$?$IJr#   c                 p    U R                  5         [        R                  " S5      R                  S:X  d   eg)zS
Caller detection works for compiled-only resources module.

python/cpython#123085
ry   rg   N)r   r}   r~   r   r.   s    r   +test_implicit_files_with_compiled_importlib@ImplicitContextFiles.test_implicit_files_with_compiled_importlib   s0     	!&&{377;SSSSr#   r<   N)r=   r>   r?   r@   textwrapdedentr   set_valreplacer^   r   r   r   r   rA   r<   r#   r   rt   rt   z   sx    oo""# $		G # /
 #??9+=+=}M/

DRYK$Tr#   rt   c                       \ rS rSrSrg)ImplicitContextFilesDiskTests   r<   NrE   r<   r#   r   r   r           	r#   r   c                       \ rS rSrSrg)ImplicitContextFilesZipTests   r<   NrE   r<   r#   r   r   r      r   r#   r   __main__)#
contextlibr}   r   r   r   unittestr   importlib_resourcesr   abcr   rf   r   compat.py39r   r   contextmanagerr   r   	DiskSetupTestCaserC   ZipSetuprH   rK   rU   rY   rd   rn   rq   rt   r   r   r=   mainr<   r#   r   <module>r      s_          '   1  / /8	J0A0A 		:t}}h.?.? 	)T^^X5F5F )0#Jx7H7H #% %. . 	:t~~|XEVEV 		*dmm\8CTCT 	8T 8Tv	 4h6G6G		3X5F5F	 zMMO r#   