o
    }¨Êhð  ã                   @   s²   d dl Z d dlZddlmZ ddlmZ ddlmZ G dd„ deje j	ƒ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e j	ƒZedkrWe  ¡  dS dS )é    Né   )Údata01)Úutilé   )ÚFileNotFoundErrorc                   @   ó   e Zd Zdd„ ZdS )ÚCommonBinaryTestsc                 C   ó2   t  ||¡�	 W d   ƒ d S 1 sw   Y  d S ©N)Ú	resourcesÚopen_binary©ÚselfÚpackageÚpath© r   úU/var/www/html/env/lib/python3.10/site-packages/importlib_resources/tests/test_open.pyÚexecute
   ó   "ÿzCommonBinaryTests.executeN©Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   	   ó    r   c                   @   r   )ÚCommonTextTestsc                 C   r	   r
   )r   Ú	open_textr   r   r   r   r      r   zCommonTextTests.executeNr   r   r   r   r   r      r   r   c                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )Ú	OpenTestsc                 C   óH   t  | jd¡�}| ¡ }|  |d¡ W d   ƒ d S 1 sw   Y  d S )Nú
utf-8.files   Hello, UTF-8 world!
)r   r   ÚdataÚreadÚassertEqual©r   ÚfpÚresultr   r   r   Útest_open_binary   ó   "þzOpenTests.test_open_binaryc                 C   r   )Nr   zHello, UTF-8 world!
©r   r   r   r    r!   r"   r   r   r   Útest_open_text_default_encoding   r&   z)OpenTests.test_open_text_default_encodingc                 C   sJ   t  | jddd¡�}| ¡ }W d   ƒ n1 sw   Y  |  |d¡ d S )Núutf-16.filezutf-16ÚstrictzHello, UTF-16 world!
r'   r"   r   r   r   Útest_open_text_given_encoding    s   
ÿ
þz'OpenTests.test_open_text_given_encodingc                 C   sŠ   t  | jddd¡�}|  t|j¡ W d   ƒ n1 sw   Y  t  | jddd¡�}| ¡ }W d   ƒ n1 s8w   Y  |  |d¡ d S )Nr)   zutf-8r*   Úignorez*H e l l o ,   U T F - 1 6   w o r l d ! 
 )r   r   r   ÚassertRaisesÚUnicodeErrorr    r!   r"   r   r   r   Útest_open_text_with_errors&   s    
ÿþ
ÿ
þþz$OpenTests.test_open_text_with_errorsc                 C   ó   |   ttj| jd¡ d S ©Nzdoes-not-exist)r-   r   r   r   r   ©r   r   r   r   Ú"test_open_binary_FileNotFoundError4   ó   
þz,OpenTests.test_open_binary_FileNotFoundErrorc                 C   r0   r1   )r-   r   r   r   r   r2   r   r   r   Ú test_open_text_FileNotFoundError9   r4   z*OpenTests.test_open_text_FileNotFoundErrorN)	r   r   r   r%   r(   r+   r/   r3   r5   r   r   r   r   r      s    r   c                   @   r   )ÚOpenDiskTestsc                 C   s
   t | _d S r
   )r   r   r2   r   r   r   ÚsetUp@   s   
zOpenDiskTests.setUpN)r   r   r   r7   r   r   r   r   r6   ?   r   r6   c                   @   s   e Zd ZdS )ÚOpenZipTestsN)r   r   r   r   r   r   r   r8   D   s    r8   Ú__main__)ÚunittestÚimportlib_resourcesr   Ú r   r   Ú_compatr   ÚCommonTestsÚTestCaser   r   r   r6   ÚZipSetupr8   r   Úmainr   r   r   r   Ú<module>   s    *ÿ