o
    Þý°j™  ã                   @   sv   d Z ddlZddlZddlmZ ddlmZ G dd„ deƒZddd„Z	i fd	d
„Z
edkr9dd„ Zejdd� dS dS )zgSelf tests

These tests should perform quickly and can ideally be used every time an
application runs.
é    N)Úimport_module)ÚStringIOc                   @   s   e Zd Zdd„ ZdS )ÚSelfTestErrorc                 C   s   t  | ||¡ || _|| _d S ©N)Ú	ExceptionÚ__init__ÚmessageÚresult)Úselfr   r	   © r   ú�/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/Cryptodome/SelfTest/__init__.pyr   &   s   
zSelfTestError.__init__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   %   s    r   c           	      K   sÊ   |du ri }t  ¡ }| du r|du rt|d�}| |¡ n|du r+| | j|d�¡ ntdƒ‚|du r9tƒ |d< n||d< t jdd|i|¤Ž}| |¡}| ¡ sc|du r^t	j
 |d  ¡ ¡ td|ƒ‚|S )a>  Execute self-tests.

    This raises SelfTestError if any test is unsuccessful.

    You may optionally pass in a sub-module of SelfTest if you only want to
    perform some of the tests.  For example, the following would test only the
    hash modules:

        Cryptodome.SelfTest.run(Cryptodome.SelfTest.Hash)

    N©Úconfigz5'module' and 'tests' arguments are mutually exclusiveÚstreamÚ	verbosityzSelf-test failedr   )ÚunittestÚ	TestSuiteÚ	get_testsÚaddTestsÚ
ValueErrorr   ÚTextTestRunnerÚrunÚwasSuccessfulÚsysÚstderrÚwriteÚgetvaluer   )	Úmoduler   r   Útestsr   ÚkwargsÚsuiteÚrunnerr	   r   r   r   r   ,   s(   


r   c                 C   s6   g }g d¢}|D ]}t d| ƒ}||j| d�7 }q|S )N)	ÚCipherÚHashÚProtocolÚ	PublicKeyÚRandomÚUtilÚ	SignatureÚIOÚMathzCryptodome.SelfTest.r   )r   r   )r   r!   Úmodule_namesÚnamer    r   r   r   r   R   s   r   Ú__main__c                   C   s   t  tƒ ¡S r   )r   r   r   r   r   r   r   r#   b   s   r#   )ÚdefaultTest)Nr   NNN)Ú__doc__r   r   Ú	importlibr   ÚCryptodome.Util.py3compatr   r   r   r   r   r   r#   Úmainr   r   r   r   Ú<module>   s   
&ý