Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_secrets.cpython-39.pyc

a

��g�@sfdZddlZddlZddlZGdd�dej�ZGdd�dej�ZGdd�dej�Zed	krbe�	�dS)
z�Test the secrets module.

As most of the functions in secrets are thin wrappers around functions
defined elsewhere, we don't need to test them exhaustively.
�Nc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Compare_Digest_Testsz%Test secrets.compare_digest function.c	CsNdD]D}|d}|d}|�t�||��|�t�|�d�|�d���qdS)N)�aZbcdZxyz123�d�utf-8)�
assertTrue�secrets�compare_digest�encode��self�sr�b�r�-/usr/local/lib/python3.9/test/test_secrets.py�
test_equals
zCompare_Digest_Tests.test_equalc	Csz|�t�dd��|�t�dd��dD]L}|dd}|dd}|�t�||��|�t�|�d	�|�d	���q(dS)
N�abcZabcdsabcsabcd)�xZmnZa1b2c3r�q�kr)ZassertFalserrr	r
rrr�test_unequalsz!Compare_Digest_Tests.test_unequalcCsRd}|�d�}t|t�sJ�t|t�s*J�|�ttj||�|�ttj||�dS)NZabcder)r	�
isinstance�str�bytes�assertRaises�	TypeErrorrr)rrr
rrr�test_bad_types$s
z#Compare_Digest_Tests.test_bad_typescCs,|�t�dd�t�|�t�dd�t�dS)NrZxyz)�assertIsInstancerr�bool)rrrr�	test_bool-szCompare_Digest_Tests.test_boolN)�__name__�
__module__�__qualname__�__doc__rrrrrrrrrs

	rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Random_Testsz*Test wrappers around SystemRandom methods.cCsVd}dD]H}td�D]:}t�|�}|�d|ko<d|kn|||f�qqdS)Nzrandbits(%d) returned %d)����r�)�rangerZrandbitsr)r�errmsgZnumbits�i�nrrr�
test_randbits6s

zRandom_Tests.test_randbitscCs.gd�}td�D]}|�t�|�|v�qdS)N)�r(���� �@�
)r)rr�choice)r�itemsr+rrr�test_choice>szRandom_Tests.test_choicecCsJtdd�D]}|�t�|�t|��q
|�ttjd�|�ttjd�dS)Nr(r4r���)r)ZassertInr�	randbelowr�
ValueError)rr+rrr�test_randbelowDszRandom_Tests.test_randbelowN)rr r!r"r-r7r;rrrrr#3sr#c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Token_TestszTest token functions.c
Cs�tjtjtjfD]�}|j|d��p|j}z
|�Wn tyR|�d|�Yn0z|d�Wn ty�|�d|�Yn0Wd�q1s�0Yqtj}|�	t
t�d��|�|�	t
t�d��d|�dS)N)�funcz$%s cannot be called with no argumentz%s cannot be called with Noner()r�token_bytes�	token_hex�
token_urlsafe�subTestrrZfailZDEFAULT_ENTROPY�assertEqual�len)rr=�name�sizerrr�test_token_defaultsOs �
4zToken_Tests.test_token_defaultsc	CsbdD]X}|j|d��8|�t�|�t�|�tt�|��|�Wd�q1sR0YqdS)N)r.r0�r�r,)rArrr>rrBrC)rr,rrr�test_token_bytesaszToken_Tests.test_token_bytesc	Cs|dD]r}|j|d��Rt�|�}|�|t�|�t|�d|�|�tdd�|D���Wd�q1sl0YqdS)N)r.r%��ZrHr(css|]}|tjvVqdS�N)�string�	hexdigits��.0�crrr�	<genexpr>o�z-Token_Tests.test_token_hex.<locals>.<genexpr>)	rArr?rrrBrCr�all�rr,rrrr�test_token_hexhs
zToken_Tests.test_token_hexc	s|tjtjd�dD]b}|j|d��Bt�|�}|�|t�|�t	�fdd�|D���Wd�q1sl0YqdS)Nz-_)r.���LrHc3s|]}|�vVqdSrLrrO�ZlegalrrrRxrSz1Token_Tests.test_token_urlsafe.<locals>.<genexpr>)
rM�
ascii_letters�digitsrArr@rrrrTrUrrZr�test_token_urlsafeqs
zToken_Tests.test_token_urlsafeN)rr r!r"rFrIrVr]rrrrr<Ls
	r<�__main__)
r"rZunittestrMZTestCaserr#r<r�mainrrrr�<module>s$/

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists