U
    ?hņ  ć                   @   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   śc/var/www/html/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