U
    kuf
                     @   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G dd de
eje jZedkre   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-jirmq66v/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   sF   t | jd }|d"}| }| |ttd W 5 Q R X d S )Nzbinary.filer      )r   r	   datar   readassertEqualbytesrange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   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 )Nr2   r   r   r3   r5   r   r   r    test_open_text_FileNotFoundError>   s    z*OpenTests.test_open_text_FileNotFoundErrorN)	r   r   r   r&   r(   r-   r1   r6   r7   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   r9   r   r   r   r   r8   D   s   r8   c                   @   s   e Zd Zdd ZdS )OpenDiskNamespaceTestsc                 C   s   ddl m} || _d S )Nr   )namespacedata01) r<   r   )r   r<   r   r   r   r9   J   s    zOpenDiskNamespaceTests.setUpNr:   r   r   r   r   r;   I   s   r;   c                   @   s   e Zd ZdS )OpenZipTestsN)r   r   r   r   r   r   r   r>   P   s   r>   c                   @   s   e Zd ZdZdS )OpenNamespaceZipTestsr<   N)r   r   r   Z
ZIP_MODULEr   r   r   r   r?   T   s   r?   __main__)ZunittestZimportlib_resourcesr   r=   r   r   ZCommonTestsZTestCaser   r   r   r8   r;   ZZipSetupr>   r?   r   mainr   r   r   r   <module>   s   .