o
    >Di                     @   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!	some_pathabc)filepathcontents)ioBytesIOr   create_package)self
bytes_data r   j/var/www/Datamplify/venv/lib/python3.10/site-packages/importlib_resources/tests/test_compatibilty_files.pypackage   s   
zCompatibilityFilesTests.packagec                 C      t | jS N	resourcesfilesr   r   r   r   r   r         zCompatibilityFilesTests.filesc                 C   s(   |  tdd | j D g d 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	   )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&   )
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_is0   s    z+CompatibilityFilesTests.test_orphan_path_isc                 C   s   |  | jjd d S )Ntestingpackager"   r   r   r   r   r   r   test_spec_path_name6   s   z+CompatibilityFilesTests.test_spec_path_namec                 C   s   |  | jd jd d S r&   r4   r   r   r   r   test_child_path_name9      z,CompatibilityFilesTests.test_child_path_namec                 C   s8   |  | jd d jd |  | jd d d jd d S Nr
   r   r   r4   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_open@   s   z+CompatibilityFilesTests.test_spec_path_openc                 C   s4   |  | jd  d |  | jd jddd d S )Nr
   r   r:   r;   r=   r>   r   r   r   r   test_child_path_openD   s   z,CompatibilityFilesTests.test_child_path_openc                 C   s   |  t | jd d   W d    n1 sw   Y  |  t | jd d d   W d    d S 1 s:w   Y  d S r8   )assertRaisesFileNotFoundErrorr   r?   r   r   r   r   test_orphan_path_openJ   s   "z-CompatibilityFilesTests.test_orphan_path_openc                 C   s<   |  t | jd W d    d S 1 sw   Y  d S )N0)rC   
ValueErrorr   openr   r   r   r   test_open_invalid_modeP   s   "z.CompatibilityFilesTests.test_open_invalid_modec                 C   s8   |  t t  W d    d S 1 sw   Y  d S r   )rC   rG   r   
OrphanPathr   r   r   r   test_orphan_path_invalidT   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_specX   s   
z&CompatibilityFilesTests.test_wrap_specN)__name__
__module____qualname__propertyr   r   r%   r)   r*   r/   r1   r2   r5   r6   r9   rA   rB   rE   rI   rK   rP   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   create_package_from_loaderr   r   r   r   r   ^   s   
z'CompatibilityFilesNoReaderTests.packagec                 C   r   r   r   r   r   r   r   r   b   r   z%CompatibilityFilesNoReaderTests.filesc                 C   s   |  | jd tj d S r&   )rL   r   r   rJ   r   r   r   r   test_spec_path_joinpathf   r7   z7CompatibilityFilesNoReaderTests.test_spec_path_joinpathN)rQ   rR   rS   rT   r   r   rW   r   r   r   r   rU   ]   s    

rU   )r   unittestimportlib_resourcesr   importlib_resources._adaptersr   r    r   TestCaser   rU   r   r   r   r   <module>   s    P