o
    gz
                     @   s   d dl 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ree   dS dS )    N   )utilc                   @      e Zd Zdd ZdS )CommonBinaryTestsc                 C   s@   t ||}|d	 W d    d S 1 sw   Y  d S )Nrb	resourcesfilesjoinpathopenselfpackagepathtarget r   Z/var/www/visachat/venv/lib/python3.10/site-packages/importlib_resources/tests/test_open.pyexecute	   s   "zCommonBinaryTests.executeN__name__
__module____qualname__r   r   r   r   r   r          r   c                   @   r   )CommonTextTestsc                 C   sB   t ||}|jdd	 W d    d S 1 sw   Y  d S )Nutf-8encodingr   r   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	d
 Zdd ZdS )	OpenTestsc                 C   s\   t | jd }|d}| }| |ttd W d    d S 1 s'w   Y  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   sV   t | jd }|jdd}| }| |d W d    d S 1 s$w   Y  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   sV   t | jd }|jddd}| }W d    n1 sw   Y  | |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   s   t | jd }|jddd}| t|j W d   n1 s!w   Y  |jddd}| }W d   n1 s<w   Y  | |d dS )zD
        Raises UnicodeError without the 'errors' argument.
        r*   r   r+   r,   Nignorez*H e l l o ,   U T F - 1 6   w o r l d ! 
 )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   sJ   t | jd }| t |d W d    d S 1 sw   Y  d S )Ndoes-not-existr   r   r	   r   r0   FileNotFoundErrorr   r   r   r   r   r   "test_open_binary_FileNotFoundError9   s   "z,OpenTests.test_open_binary_FileNotFoundErrorc                 C   sL   t | jd }| t |jdd W d    d S 1 sw   Y  d S )Nr3   r   r   r4   r6   r   r   r    test_open_text_FileNotFoundError>   s   "z*OpenTests.test_open_text_FileNotFoundErrorN)	r   r   r   r'   r)   r.   r2   r7   r8   r   r   r   r   r      s    r   c                   @      e Zd ZdS )OpenDiskTestsNr   r   r   r   r   r   r   r:   D       r:   c                   @      e Zd ZdZdS )OpenDiskNamespaceTestsnamespacedata01Nr   r   r   MODULEr   r   r   r   r>   H       r>   c                   @   r9   )OpenZipTestsNr;   r   r   r   r   rC   L   r<   rC   c                   @   r=   )OpenNamespaceZipTestsr?   Nr@   r   r   r   r   rD   P   rB   rD   __main__)unittestimportlib_resourcesr    r   CommonTestsTestCaser   r   r   	DiskSetupr:   r>   ZipSetuprC   rD   r   mainr   r   r   r   <module>   s    .