U
    ‚i2eo
  ã                   @   s¶   d dl Z d dl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ƒZG dd„ de
eje jƒZedkr²e  ¡  dS )é    Né   )Údata01)Úutilc                   @   s   e Zd Zdd„ ZdS )ÚCommonBinaryTestsc              	   C   s*   t  |¡ |¡}| d¡ W 5 Q R X d S )NÚrb©Ú	resourcesÚfilesÚjoinpathÚopen©ÚselfÚpackageÚpathÚtarget© r   úG/tmp/pip-unpacked-wheel-bn52x7jx/importlib_resources/tests/test_open.pyÚexecute	   s    zCommonBinaryTests.executeN©Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r      s   r   c                   @   s   e Zd Zdd„ ZdS )ÚCommonTextTestsc              	   C   s,   t  |¡ |¡}|jdd W 5 Q R X d S )Núutf-8©Úencodingr   r   r   r   r   r      s    zCommonTextTests.executeNr   r   r   r   r   r      s   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   s>   t  | j¡d }| d¡}| ¡ }|  |d¡ W 5 Q R X d S )Nzbinary.filer   s    ©r   r	   Údatar   ÚreadÚassertEqual©r   r   ÚfpÚresultr   r   r   Útest_open_binary   s    zOpenTests.test_open_binaryc              	   C   s@   t  | j¡d }|jdd}| ¡ }|  |d¡ W 5 Q R X d S )Nz
utf-8.filer   r   zHello, UTF-8 world!
r   r!   r   r   r   Útest_open_text_default_encoding   s    z)OpenTests.test_open_text_default_encodingc              	   C   sB   t  | j¡d }|jddd}| ¡ }W 5 Q R X |  |d¡ d S )Núutf-16.filezutf-16Ústrict©r   ÚerrorszHello, UTF-16 world!
r   r!   r   r   r   Útest_open_text_given_encoding#   s    z'OpenTests.test_open_text_given_encodingc              	   C   sj   t  | j¡d }|jddd}|  t|j¡ W 5 Q R X |jddd}| ¡ }W 5 Q R X |  |d¡ dS )zD
        Raises UnicodeError without the 'errors' argument.
        r&   r   r'   r(   Úignorez*H e l l o ,   U T F - 1 6   w o r l d ! 
 N)r   r	   r   r   ÚassertRaisesÚUnicodeErrorr   r    r!   r   r   r   Útest_open_text_with_errors)   s    þz$OpenTests.test_open_text_with_errorsc              	   C   s4   t  | j¡d }|  t¡ | d¡ W 5 Q R X d S )Núdoes-not-existr   ©r   r	   r   r,   ÚFileNotFoundErrorr   ©r   r   r   r   r   Ú"test_open_binary_FileNotFoundError9   s    z,OpenTests.test_open_binary_FileNotFoundErrorc              	   C   s6   t  | j¡d }|  t¡ |jdd W 5 Q R X d S )Nr/   r   r   r0   r2   r   r   r   Ú test_open_text_FileNotFoundError>   s    z*OpenTests.test_open_text_FileNotFoundErrorN)	r   r   r   r$   r%   r*   r.   r3   r4   r   r   r   r   r      s   r   c                   @   s   e Zd Zdd„ ZdS )ÚOpenDiskTestsc                 C   s
   t | _d S )N)r   r   )r   r   r   r   ÚsetUpE   s    zOpenDiskTests.setUpN©r   r   r   r6   r   r   r   r   r5   D   s   r5   c                   @   s   e Zd Zdd„ ZdS )ÚOpenDiskNamespaceTestsc                 C   s   ddl m} || _d S )Nr   )Únamespacedata01)Ú r9   r   )r   r9   r   r   r   r6   J   s    zOpenDiskNamespaceTests.setUpNr7   r   r   r   r   r8   I   s   r8   c                   @   s   e Zd ZdS )ÚOpenZipTestsN)r   r   r   r   r   r   r   r;   P   s   r;   Ú__main__)ZunittestZimportlib_resourcesr   r:   r   r   ZCommonTestsZTestCaser   r   r   r5   r8   ZZipSetupr;   r   Úmainr   r   r   r   Ú<module>   s   .