
    daf                        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
 ddl	mZ ddl	mZ d dlmZ d d	lmZ ej                   d
        Z G d d      Z G d deej&                        Z G d deej*                  ej&                        Z G d deej&                        Z G d d      Z G d deej&                        Z G d deej&                        Zedk(  r ej8                          yy)    N)	resources)Traversable   )data01)util)_path)	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    C/root/Python-3.12.4/Lib/test/test_importlib/resources/test_files.pysuppress_known_deprecationr      s@     		 	 	- i2DE	  s   A A	AAAc                   ^    e Zd Zd Zd Z ej                   eed      d      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!
)r   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"   runtime_checkablez4Only suitable when typing supports runtime_checkablec                 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               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(   unittest
skipUnlesshasattrtypingr.   r1    r"   r   r   r      sB    2
1
 X+,>C	C/r"   r   c                       e Zd Zd Zy)OpenDiskTestsc                     t         | _        y r+   )r   r   r-   s    r   setUpzOpenDiskTests.setUp4   s	    	r"   Nr2   r3   r4   r=   r9   r"   r   r;   r;   3   s    r"   r;   c                       e Zd Zy)OpenZipTestsN)r2   r3   r4   r9   r"   r   r@   r@   8   s    r"   r@   c                       e Zd Zd Zy)OpenNamespaceTestsc                     ddl m} || _        y )Nr   )namespacedata01) rD   r   )r   rD   s     r   r=   zOpenNamespaceTests.setUp=   s    %#	r"   Nr>   r9   r"   r   rB   rB   <   s    $r"   rB   c                       e Zd Zd Zy)SiteDirc                    t        j                         | _        | j                  | j                  j                         | j                  j                  t        j                               | _        | j                  j                  t        j                  | j                               | j                  j                  t        j                                y r+   )
contextlib	ExitStackfixtures
addCleanupcloseenter_contextr	   temp_dirsite_dirr
   DirsOnSysPathisolated_modulesr-   s    r   r=   zSiteDir.setUpD   s    ",,.++,33I4F4F4HI##M$?$?$NO##M$B$B$DEr"   Nr>   r9   r"   r   rG   rG   C   s    Fr"   rG   c                       e Zd Zd Zy)ModulesFilesTestsc                     ddd}t        j                  || j                         ddl}t	        j
                  |      j                  d      j                  d      }||d   k(  sJ y)	zK
        A module can have resources found adjacent to the module.
        rE   resources are the best)zmod.pyres.txtr   NrW   r$   r%   )r   buildrP   modr   r   r   r'   )r   specrY   r    s       r   test_module_resourcesz'ModulesFilesTests.test_module_resourcesM   sa    
 /
 	D$--(%..y9CCWCUi(((r"   N)r2   r3   r4   r[   r9   r"   r   rT   rT   L   s    )r"   rT   c                       e Zd Zd Zy)ImplicitContextFilesTestsc                     dt        j                  d      ddi}t        j                  || j                         t        j                  d      j                  dk(  sJ 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   )z__init__.pyrW   N)textwrapdedentr   rX   rP   	importlibimport_moduleval)r   rZ   s     r   test_implicit_filesz-ImplicitContextFilesTests.test_implicit_files]   s]    
 '  4

 	D$--(&&y1559QQQQr"   N)r2   r3   r4   re   r9   r"   r   r]   r]   \   s    Rr"   r]   __main__)r8   r`   r5   r   rb   rI   r   importlib.resources.abcr   rE   r   r   r   test.supportr	   r
   contextmanagerr   r   TestCaser;   ZipSetupr@   rB   rG   rT   r]   r2   mainr9   r"   r   <module>rm      s           /    " &  / /6J 1 1 
	:t}}h.?.? 	$X%6%6 $F F)!2!2 ) R):): R( zHMMO r"   