U
    ^»{jÁ  ã                   @   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r¤e ¡  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   úb/var/www/html/bwave/python/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   