U
    ?hy
                     @   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re   dS )    N   )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   U/var/www/html/venv/lib/python3.8/site-packages/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_FileNotFoundError8   s    z,OpenTests.test_open_binary_FileNotFoundErrorc              	   C   s6   t | jd }| t |jdd W 5 Q R X d S )Nr1   r   r   r2   r4   r   r   r    test_open_text_FileNotFoundError=   s    z*OpenTests.test_open_text_FileNotFoundErrorN)	r   r   r   r%   r'   r,   r0   r5   r6   r   r   r   r   r      s   r   c                   @   s   e Zd ZdS )OpenDiskTestsNr   r   r   r   r   r   r   r7   C   s   r7   c                   @   s   e Zd ZdZdS )OpenDiskNamespaceTestsnamespacedata01Nr   r   r   MODULEr   r   r   r   r9   G   s   r9   c                   @   s   e Zd ZdS )OpenZipTestsNr8   r   r   r   r   r=   K   s   r=   c                   @   s   e Zd ZdZdS )OpenNamespaceZipTestsr:   Nr;   r   r   r   r   r>   O   s   r>   __main__)ZunittestZimportlib_resourcesr    r   ZCommonTestsZTestCaser   r   r   Z	DiskSetupr7   r9   ZZipSetupr=   r>   r   mainr   r   r   r   <module>   s   .