a
    3j                     @   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re   dS )    N)import_module	resources   )data01)utilc                   @   s   e Zd Zdd ZdS )CommonBinaryTestsc                 C   s   t || d S N)r   read_binaryselfpackagepath r   Y/www/server/python_manager/versions/3.9.10/lib/python3.9/test/test_importlib/test_read.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 || d S r   )r   	read_textr
   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	S )
	ReadTestsc                 C   s   t | jd}| |d d S )Nbinary.file    )r   r	   dataassertEqualr   resultr   r   r   test_read_binary   s    zReadTests.test_read_binaryc                 C   s   t | jd}| |d d S )Nz
utf-8.filezHello, UTF-8 world!
r   r   r   r   r   r   r   r   test_read_text_default_encoding   s    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_resource1   s
    z)ReadZipTests.test_read_submodule_resourcec                 C   s   t dd}| |d d S r*   )r   r	   r   r   r   r   r   $test_read_submodule_resource_by_name7   s    z1ReadZipTests.test_read_submodule_resource_by_nameN)r   r   r   r+   r,   r   r   r   r   r)   0   s   r)   __main__)Zunittest	importlibr   r    r   r   ZCommonResourceTestsZTestCaser   r   r   r(   ZZipSetupr)   r   mainr   r   r   r   <module>   s   