U
    i2e^                     @   s   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-bn52x7jx/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   sp   t | jd }t |L}| |jdt| |jddd}|	 }W 5 Q R X | 
d| W 5 Q R X dS )z
        Path should be readable.

        Test also implicitly verifies the returned object is a pathlib.Path
        instance.
        
utf-8.filerzutf-8)encodingzHello, UTF-8 world!
N)r   r   datar   
assertTruenameendswithrepropenreadassertEqual)r
   targetr   filetextr   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AssertionErrorr
   r   r   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)r    r   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   r0   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_manager:   s    z+PathZipTests.test_remove_in_context_managerN)r   r   r   r3   r   r   r   r   r1   9   s   r1   __main__)r)   ZunittestZimportlib_resourcesr    r   r   r   ZTestCaser   r#   r(   ZZipSetupr1   r   mainr   r   r   r   <module>   s   