U
    kuf                     @   s   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 G dd dejej	ZG dd dZ
G d	d
 d
e
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   )data01)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   G/tmp/pip-unpacked-wheel-jirmq66v/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Path
assertTruenameendswithrepr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e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   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_manager6   s    z+PathZipTests.test_remove_in_context_managerN)r   r   r   r2   r   r   r   r   r0   5   s   r0   __main__)r(   r   ZunittestZimportlib_resourcesr    r   r   r   ZTestCaser   r"   r&   ZZipSetupr0   r   mainr   r   r   r   <module>   s   