U
    ?h                     @   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e jZG dd deej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   )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   U/var/www/html/venv/lib/python3.8/site-packages/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   Z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dS )ReadDiskTestsN)r   r   r   r   r   r   r   r-   6   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 r/   r   r   r   r	   r   r   r    r!   r   r   r   $test_read_submodule_resource_by_name@   s    z1ReadZipTests.test_read_submodule_resource_by_nameN)r   r   r   r4   r6   r   r   r   r   r.   :   s   r.   c                   @   s   e Zd ZdZdS )ReadNamespaceTestsnamespacedata01N)r   r   r   MODULEr   r   r   r   r7   G   s   r7   c                   @   s    e Zd ZdZdd Zdd ZdS )ReadNamespaceZipTestsr8   c                 C   s6   t d}t|d }| |ttdd d S Nznamespacedata01.subdirectoryr         r1   r2   r   r   r   r4   N   s    z2ReadNamespaceZipTests.test_read_submodule_resourcec                 C   s.   t dd }| |ttdd d S r;   r5   r!   r   r   r   r6   S   s
    
z:ReadNamespaceZipTests.test_read_submodule_resource_by_nameN)r   r   r   r9   r4   r6   r   r   r   r   r:   K   s   r:   __main__)ZunittestZimportlib_resourcesr    r   	importlibr   ZCommonTestsZTestCaser   r   r   Z	DiskSetupr-   ZZipSetupr.   r7   r:   r   mainr   r   r   r   <module>   s   $