o
    g                     @   s   d dl Z d dlmZm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ZG dd deeje jZedkrUe   dS dS )    N)import_module	resources   )data01)utilc                   @      e Zd Zdd ZdS )CommonBinaryTestsc                 C      t || d S N)r   read_binaryselfpackagepath r   S/Users/admin/.pyenv/versions/3.10.0/lib/python3.10/test/test_importlib/test_read.pyexecute	      zCommonBinaryTests.executeN__name__
__module____qualname__r   r   r   r   r   r          r   c                   @   r   )CommonTextTestsc                 C   r	   r
   )r   	read_textr   r   r   r   r      r   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      t | jd}| |d d S )Nbinary.file    )r   r   dataassertEqualr   resultr   r   r   test_read_binary      zReadTests.test_read_binaryc                 C   r   )Nz
utf-8.filezHello, UTF-8 world!
r   r   r   r    r!   r   r   r   test_read_text_default_encoding   r$   z)ReadTests.test_read_text_default_encodingc                 C   s"   t j| jddd}| |d d S )Nutf-16.filezutf-16)encodingzHello, UTF-16 world!
r%   r!   r   r   r   test_read_text_given_encoding   s   z'ReadTests.test_read_text_given_encodingc                 C   s6   |  ttj| jd tj| jddd}| |d d S )Nr'   ignore)errorsz*H e l l o ,   U T F - 1 6   w o r l d ! 
 )ZassertRaisesUnicodeErrorr   r   r   r    r!   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eZdS )ReadDiskTestsN)r   r   r   r   r   r   r   r   r   r.   +   s    r.   c                   @   s   e Zd Zdd Zdd ZdS )ReadZipTestsc                 C   s$   t d}t|d}| |d d S Nzziptestdata.subdirectoryr   r   )r   r   r   r    )r   Z	submoduler"   r   r   r   test_read_submodule_resource0   s   z)ReadZipTests.test_read_submodule_resourcec                 C   s   t dd}| |d d S r0   )r   r   r    r!   r   r   r   $test_read_submodule_resource_by_name5   s   z1ReadZipTests.test_read_submodule_resource_by_nameN)r   r   r   r1   r2   r   r   r   r   r/   /   s    r/   __main__)Zunittest	importlibr   r    r   r   ZCommonResourceTestsZTestCaser   r   r   r.   ZZipSetupr/   r   mainr   r   r   r   <module>   s    