U
    kuf(                     @   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G dd dee j	ZG dd deeje j	Zedkre   dS )    N   )data01)util)import_modulec                   @   s   e Zd Zdd ZdS )CommonBinaryTestsc                 C   s   t ||  d S )N)	resourcesfilesjoinpath
read_bytesselfpackagepath r   G/tmp/pip-unpacked-wheel-jirmq66v/importlib_resources/tests/test_read.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 d S )Nutf-8encoding)r   r   r	   	read_textr   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	S )
	ReadTestsc                 C   s.   t | jd }| |ttd d S )Nbinary.file   )r   r   datar	   r
   assertEqualbytesranger   resultr   r   r   test_read_bytes   s    zReadTests.test_read_bytesc                 C   s*   t | jdjdd}| |d d S )Nz
utf-8.filer   r   zHello, UTF-8 world!
r   r   r   r	   r   r   r"   r   r   r   test_read_text_default_encoding   s    z)ReadTests.test_read_text_default_encodingc                 C   s*   t | jdjdd}| |d d S )Nutf-16.filezutf-16r   zHello, UTF-16 world!
r%   r"   r   r   r   test_read_text_given_encoding    s    z'ReadTests.test_read_text_given_encodingc                 C   s@   t | jd }| jt|jdd |jddd}| |d dS )zD
        Raises UnicodeError without the 'errors' argument.
        r'   r   r   ignore)r   errorsz*H e l l o ,   U T F - 1 6   w o r l d ! 
 N)r   r   r   assertRaisesUnicodeErrorr   r   )r   targetr#   r   r   r   test_read_text_with_errors(   s    z$ReadTests.test_read_text_with_errorsN)r   r   r   r$   r&   r(   r.   r   r   r   r   r      s   r   c                   @   s   e Zd ZeZdS )ReadDiskTestsN)r   r   r   r   r   r   r   r   r   r/   7   s   r/   c                   @   s   e Zd Zdd Zdd ZdS )ReadZipTestsc                 C   s6   t d}t|d }| |ttdd d S Nzdata01.subdirectoryr   r      r   r   r   r	   r
   r   r    r!   r   	submoduler#   r   r   r   test_read_submodule_resource<   s    z)ReadZipTests.test_read_submodule_resourcec                 C   s.   t dd }| |ttdd d S r1   r   r   r	   r
   r   r    r!   r"   r   r   r   $test_read_submodule_resource_by_nameA   s    z1ReadZipTests.test_read_submodule_resource_by_nameN)r   r   r   r6   r8   r   r   r   r   r0   ;   s   r0   c                   @   s   e Zd Zdd ZdS )ReadNamespaceTestsc                 C   s   ddl m} || _d S )Nr   )namespacedata01) r:   r   )r   r:   r   r   r   setUpI   s    zReadNamespaceTests.setUpN)r   r   r   r<   r   r   r   r   r9   H   s   r9   c                   @   s    e Zd ZdZdd Zdd ZdS )ReadNamespaceZipTestsr:   c                 C   s6   t d}t|d }| |ttdd d S Nznamespacedata01.subdirectoryr         r3   r4   r   r   r   r6   R   s    z2ReadNamespaceZipTests.test_read_submodule_resourcec                 C   s.   t dd }| |ttdd d S r>   r7   r"   r   r   r   r8   W   s
    
z:ReadNamespaceZipTests.test_read_submodule_resource_by_nameN)r   r   r   Z
ZIP_MODULEr6   r8   r   r   r   r   r=   O   s   r=   __main__)ZunittestZimportlib_resourcesr   r;   r   r   	importlibr   ZCommonTestsZTestCaser   r   r   r/   ZZipSetupr0   r9   r=   r   mainr   r   r   r   <module>   s   $