U
    ?h                     @   s   d dl Z d dlZd dlZd dlZddlmZ G dd dejejZG dd dZ	G dd	 d	e	ej
ejZG d
d de	ejZG dd de	ejejZedkre  dS )    N   )utilc                   @   s   e Zd Zdd ZdS )CommonTestsc              	   C   s&   t t || W 5 Q R X d S )N)	resourcesas_filefilesjoinpath)selfpackagepath r   U/var/www/html/venv/lib/python3.8/site-packages/importlib_resources/tests/test_path.pyexecute
   s    zCommonTests.executeN)__name__
__module____qualname__r   r   r   r   r   r   	   s   r   c                   @   s   e Zd Zdd ZdS )	PathTestsc              	   C   sd   t | jd }t |@}| |tj | |j	dt
| | d|jdd W 5 Q R X dS )zF
        Path should be readable and a pathlib.Path instance.
        
utf-8.filezHello, UTF-8 world!
zutf-8)encodingN)r   r   datar   ZassertIsInstancepathlibPathZ
assertTruenameendswithreprZassertEqual	read_textr	   targetr   r   r   r   test_reading   s
    zPathTests.test_readingN)r   r   r   r   r   r   r   r   r      s   r   c                   @   s   e Zd Zdd ZdS )PathDiskTestsc              	   C   s:   t | jd }t |}dt|ks,tW 5 Q R X dS )z
        Guarantee the internal implementation detail that
        file-system-backed resources do not get the tempdir
        treatment.
        r   r   N)r   r   r   r   strAssertionErrorr   r   r   r   test_natural_path   s    zPathDiskTests.test_natural_pathN)r   r   r   r"   r   r   r   r   r      s   r   c                   @   s   e Zd Zdd ZdS )PathMemoryTestsc                 C   sB   t d}| |j tj|tdd| _d | jj_	d| jj_
d S )Ns   Hello, UTF-8 world!
zpackage exists only in memory)filer   F)ioBytesIOZ
addCleanupcloser   Zcreate_packageFileNotFoundErrorr   __spec__originhas_location)r	   r$   r   r   r   setUp(   s    
 
zPathMemoryTests.setUpN)r   r   r   r,   r   r   r   r   r#   '   s   r#   c                   @   s   e Zd Zdd ZdS )PathZipTestsc              	   C   s2   t | jd }t |}|  W 5 Q R X dS )z
        It is not an error if the file that was temporarily stashed on the
        file system is removed inside the `with` stanza.
        r   N)r   r   r   r   unlinkr   r   r   r   test_remove_in_context_manager3   s    z+PathZipTests.test_remove_in_context_managerN)r   r   r   r/   r   r   r   r   r-   2   s   r-   __main__)r%   r   ZunittestZimportlib_resourcesr    r   r   ZTestCaser   Z	DiskSetupr   r#   ZZipSetupr-   r   mainr   r   r   r   <module>   s   