a
    ijz
                     @   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 d    n1 s00    Y  d S )Nrb	resourcesfilesjoinpathopenselfpackagepathtarget r   a/home/ghrups/robot-bench/.venv/lib/python3.9/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 d    n1 s20    Y  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   sZ   t | jd }|d,}| }| |ttd W d    n1 sL0    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   sT   t | jd }|jdd$}| }| |d W d    n1 sF0    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<0    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 sB0    Y  |jddd}| }W d   n1 sx0    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   sH   t | jd }| t |d W d    n1 s:0    Y  d S )Ndoes-not-existr   r   r   r   r.   FileNotFoundErrorr
   r   r   r   r   r   "test_open_binary_FileNotFoundError9   s    z,OpenTests.test_open_binary_FileNotFoundErrorc                 C   sJ   t | jd }| t |jdd W d    n1 s<0    Y  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   D   s   r7   c                   @   s   e Zd ZdZdS )OpenDiskNamespaceTestsnamespacedata01Nr   r   r   MODULEr   r   r   r   r9   H   s   r9   c                   @   s   e Zd ZdS )OpenZipTestsNr8   r   r   r   r   r=   L   s   r=   c                   @   s   e Zd ZdZdS )OpenNamespaceZipTestsr:   Nr;   r   r   r   r   r>   P   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   .