o
    g                     @   s   d dl Z d dlmZ d dl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rke   dS dS )    N)import_module   )utilc                   @      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   Z/var/www/visachat/venv/lib/python3.10/site-packages/importlib_resources/tests/test_read.pyexecute
   s   zCommonBinaryTests.executeN__name__
__module____qualname__r   r   r   r   r   r   	       r   c                   @   r   )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      r   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   *   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      
z)ReadTests.test_read_text_default_encodingc                 C   r&   )Nutf-16.filezutf-16r   zHello, UTF-16 world!
r'   r#   r   r   r   test_read_text_given_encoding    r)   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+   r1   r   r   r   r   r      s
    r   c                   @   s   e Zd ZdS )ReadDiskTestsN)r   r   r   r   r   r   r   r2   7   s    r2   c                   @   s   e Zd Zdd Zdd ZdS )ReadZipTestsc                 C   6   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<      z)ReadZipTests.test_read_submodule_resourcec                 C   .   t dd }| |ttdd d S r5   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   r:   r>   r   r   r   r   r3   ;   s    r3   c                   @   s   e Zd ZdZdS )ReadNamespaceTestsnamespacedata01N)r   r   r   MODULEr   r   r   r   r?   H   s    r?   c                   @   s    e Zd ZdZdd Zdd ZdS )ReadNamespaceZipTestsr@   c                 C   r4   Nznamespacedata01.subdirectoryr         r7   r8   r   r   r   r:   O   r;   z2ReadNamespaceZipTests.test_read_submodule_resourcec                 C   r<   rC   r=   r#   r   r   r   r>   T   s
   z:ReadNamespaceZipTests.test_read_submodule_resource_by_nameN)r   r   r   rA   r:   r>   r   r   r   r   rB   L   s    rB   __main__)unittest	importlibr   importlib_resourcesr    r   CommonTestsTestCaser   r   r   	DiskSetupr2   ZipSetupr3   r?   rB   r   mainr   r   r   r   <module>   s    $