U
    \g%iò  ã                   @   s\   d dl Z d dlZd dlZd dlmZmZ ddlmZ G dd„ dej	ƒZ
G dd„ dej	ƒZdS )	é    N)ÚCompatibilityFilesÚ	wrap_specé   )Úutilc                   @   sœ   e Zd Zedd„ ƒZedd„ ƒZdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#S )$ÚCompatibilityFilesTestsc                 C   s   t  d¡}tj|dddS )Nó   Hello, world!Z	some_path)ÚaÚbÚc)ÚfileÚpathÚcontents)ÚioÚBytesIOr   Zcreate_package)ÚselfÚ
bytes_data© r   úp/var/www/html/api-medvista/venv/lib/python3.8/site-packages/importlib_resources/tests/test_compatibilty_files.pyÚpackage   s    
ýzCompatibilityFilesTests.packagec                 C   s   t  | j¡S ©N©Ú	resourcesÚfilesr   ©r   r   r   r   r      s    zCompatibilityFilesTests.filesc                 C   s*   |   tdd„ | j ¡ D ƒƒdddg¡ d S )Nc                 s   s   | ]}|j V  qd S r   )Úname)Ú.0r   r   r   r   Ú	<genexpr>   s     z>CompatibilityFilesTests.test_spec_path_iter.<locals>.<genexpr>r   r	   r
   )ÚassertEqualÚsortedr   Úiterdirr   r   r   r   Útest_spec_path_iter   s    þz+CompatibilityFilesTests.test_spec_path_iterc                 C   s   |   t| jd  ¡ ƒg ¡ d S ©Nr   ©r   Úlistr   r   r   r   r   r   Útest_child_path_iter"   s    z,CompatibilityFilesTests.test_child_path_iterc                 C   sD   |   t| jd d  ¡ ƒg ¡ |   t| jd d d  ¡ ƒg ¡ d S r!   r"   r   r   r   r   Útest_orphan_path_iter%   s    z-CompatibilityFilesTests.test_orphan_path_iterc                 C   s$   |   | j ¡ ¡ |   | j ¡ ¡ d S r   ©ÚassertFalser   Úis_fileÚis_dirr   r   r   r   Útest_spec_path_is)   s    z)CompatibilityFilesTests.test_spec_path_isc                 C   s,   |   | jd  ¡ ¡ |  | jd  ¡ ¡ d S r!   )Z
assertTruer   r(   r'   r)   r   r   r   r   Útest_child_path_is-   s    z*CompatibilityFilesTests.test_child_path_isc                 C   sl   |   | jd d  ¡ ¡ |   | jd d  ¡ ¡ |   | jd d d  ¡ ¡ |   | jd d d  ¡ ¡ d S r!   r&   r   r   r   r   Útest_orphan_path_is1   s    z+CompatibilityFilesTests.test_orphan_path_isc                 C   s   |   | jjd¡ d S )NZtestingpackage©r   r   r   r   r   r   r   Útest_spec_path_name7   s    z+CompatibilityFilesTests.test_spec_path_namec                 C   s   |   | jd jd¡ d S r!   r-   r   r   r   r   Útest_child_path_name:   s    z,CompatibilityFilesTests.test_child_path_namec                 C   s8   |   | jd d jd¡ |   | jd d d jd¡ d S ©Nr   r	   r
   r-   r   r   r   r   Útest_orphan_path_name=   s    z-CompatibilityFilesTests.test_orphan_path_namec                 C   s,   |   | j ¡ d¡ |   | jjddd¡ d S )Nr   úutf-8©ÚencodingúHello, world!©r   r   Ú
read_bytesÚ	read_textr   r   r   r   Útest_spec_path_openA   s    z+CompatibilityFilesTests.test_spec_path_openc                 C   s4   |   | jd  ¡ d¡ |   | jd jddd¡ d S )Nr   r   r2   r3   r5   r6   r   r   r   r   Útest_child_path_openE   s
     ÿz,CompatibilityFilesTests.test_child_path_openc              	   C   sX   |   t¡ | jd d  ¡  W 5 Q R X |   t¡ | jd d d  ¡  W 5 Q R X d S r0   )ÚassertRaisesÚFileNotFoundErrorr   r7   r   r   r   r   Útest_orphan_path_openK   s    z-CompatibilityFilesTests.test_orphan_path_openc              	   C   s&   |   t¡ | j d¡ W 5 Q R X d S )NÚ0)r;   Ú
ValueErrorr   Úopenr   r   r   r   Útest_open_invalid_modeQ   s    z.CompatibilityFilesTests.test_open_invalid_modec              	   C   s"   |   t¡ t ¡  W 5 Q R X d S r   )r;   r?   r   Ú
OrphanPathr   r   r   r   Útest_orphan_path_invalidU   s    z0CompatibilityFilesTests.test_orphan_path_invalidc                 C   s"   t | jƒ}|  |j d ¡t¡ d S r   )r   r   ÚassertIsInstanceÚloaderÚget_resource_readerr   )r   Úspecr   r   r   Útest_wrap_specY   s    
z&CompatibilityFilesTests.test_wrap_specN)Ú__name__Ú
__module__Ú__qualname__Úpropertyr   r   r    r$   r%   r*   r+   r,   r.   r/   r1   r9   r:   r=   rA   rC   rH   r   r   r   r   r      s&   

r   c                   @   s,   e Zd Zedd„ ƒZedd„ ƒZdd„ ZdS )ÚCompatibilityFilesNoReaderTestsc                 C   s
   t  d ¡S r   )r   Zcreate_package_from_loaderr   r   r   r   r   _   s    z'CompatibilityFilesNoReaderTests.packagec                 C   s   t  | j¡S r   r   r   r   r   r   r   c   s    z%CompatibilityFilesNoReaderTests.filesc                 C   s   |   | jd tj¡ d S r!   )rD   r   r   rB   r   r   r   r   Útest_spec_path_joinpathg   s    z7CompatibilityFilesNoReaderTests.test_spec_path_joinpathN)rI   rJ   rK   rL   r   r   rN   r   r   r   r   rM   ^   s
   

rM   )r   ZunittestZimportlib_resourcesr   Zimportlib_resources._adaptersr   r   Ú r   ZTestCaser   rM   r   r   r   r   Ú<module>   s   P