a
    xd                     @   s   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 ddl
mZ ddlmZmZ ejd	d
 ZG dd dZG dd deejZG dd deejejZG dd deejZG dd dZG dd deejZG dd deejZedkre  dS )    N   )Traversable   )data01)util)_path)	os_helperimport_helperc                  c   sD   t jdd$} t jdtd | V  W d    n1 s60    Y  d S )NT)recorddefault)category)warningscatch_warningssimplefilterDeprecationWarning)ctx r   \/var/www/html/Ranjet/env/lib/python3.9/site-packages/importlib_resources/tests/test_files.pysuppress_known_deprecation   s    r   c                   @   s>   e Zd Zdd Zdd Zeeedddd Z	d	d
 Z
dS )
FilesTestsc                 C   s*   t | j}|d }|dks&J d S )N
utf-8.files   Hello, UTF-8 world!
)	resourcesfilesdatajoinpath
read_bytesselfr   actualr   r   r   test_read_bytes   s    zFilesTests.test_read_bytesc                 C   s.   t | j}|djdd}|dks*J d S )Nr   utf-8encodingzHello, UTF-8 world!
)r   r   r   r   	read_textr   r   r   r   test_read_text   s    zFilesTests.test_read_textruntime_checkablez4Only suitable when typing supports runtime_checkablec                 C   s   t t| jtsJ d S N)
isinstancer   r   r   r   r   r   r   r   test_traversable"   s    zFilesTests.test_traversablec                 C   s8   t   tj| jd W d   n1 s*0    Y  dS )zx
        Files used to take a 'package' parameter. Make sure anyone
        passing by name is still supported.
        )packageN)r   r   r   r   r(   r   r   r   test_old_parameter)   s    zFilesTests.test_old_parameterN)__name__
__module____qualname__r   r$   unittestZ
skipUnlesshasattrtypingr)   r+   r   r   r   r   r      s   
r   c                   @   s   e Zd Zdd ZdS )OpenDiskTestsc                 C   s
   t | _d S r&   )r   r   r(   r   r   r   setUp3   s    zOpenDiskTests.setUpNr,   r-   r.   r3   r   r   r   r   r2   2   s   r2   c                   @   s   e Zd ZdS )OpenZipTestsN)r,   r-   r.   r   r   r   r   r5   7   s   r5   c                   @   s   e Zd Zdd ZdS )OpenNamespaceTestsc                 C   s   ddl m} || _d S )Nr   )namespacedata01) r7   r   )r   r7   r   r   r   r3   <   s    zOpenNamespaceTests.setUpNr4   r   r   r   r   r6   ;   s   r6   c                   @   s   e Zd Zdd ZdS )SiteDirc                 C   sR   t  | _| | jj | jt | _| jt	
| j | jt	  d S r&   )
contextlib	ExitStackZfixturesZ
addCleanupcloseenter_contextr   temp_dirsite_dirr	   ZDirsOnSysPathZCleanImportr(   r   r   r   r3   C   s
    
zSiteDir.setUpNr4   r   r   r   r   r9   B   s   r9   c                   @   s   e Zd Zdd ZdS )ModulesFilesTestsc                 C   sL   ddd}t || j ddl}t|djdd}||d ksHJ dS )	zK
        A module can have resources found adjacent to the module.
        r8   resources are the best)zmod.pyres.txtr   NrB   r    r!   )r   buildr?   modr   r   r   r#   )r   specrD   r   r   r   r   test_module_resourcesL   s    z'ModulesFilesTests.test_module_resourcesN)r,   r-   r.   rF   r   r   r   r   r@   K   s   r@   c                   @   s   e Zd Zdd ZdS )ImplicitContextFilesTestsc                 C   s:   dt dddi}t|| j tdjdks6J dS )zW
        Without any parameter, files() will infer the location as the caller.
        Zsomepkgz
                    import importlib_resources as res
                    val = res.files().joinpath('res.txt').read_text(encoding='utf-8')
                    rA   )z__init__.pyrB   N)textwrapdedentr   rC   r?   	importlibimport_moduleval)r   rE   r   r   r   test_implicit_files\   s    z-ImplicitContextFilesTests.test_implicit_filesN)r,   r-   r.   rM   r   r   r   r   rG   [   s   rG   __main__)r1   rH   r/   r   rJ   r:   Zimportlib_resourcesr   abcr   r8   r   r   r   _compatr   r	   contextmanagerr   r   ZTestCaser2   ZZipSetupr5   r6   r9   r@   rG   r,   mainr   r   r   r   <module>   s,   
	
