HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_secrets.cpython-37.pyc
B

��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	CsRxLdD]D}|d}|d}|�t�||��|�t�|�d�|�d���qWdS)N)�aZbcdZxyz123�dzutf-8)�
assertTrue�secrets�compare_digest�encode)�self�sr�b�r�-/usr/local/lib/python3.7/test/test_secrets.py�
test_equals

zCompare_Digest_Tests.test_equalc	Cs~|�t�dd��|�t�dd��xTdD]L}|dd}|dd}|�t�||��|�t�|�d	�|�d	���q*WdS)
N�abcZabcdsabcsabcd)�xZmnZa1b2c3r�q�kzutf-8)ZassertFalserrr)r	r
rrrrr
�test_unequals
z!Compare_Digest_Tests.test_unequalcCsRd}|�d�}t|t�st�t|t�s*t�|�ttj||�|�ttj||�dS)NZabcdezutf-8)	r�
isinstance�str�AssertionError�bytes�assertRaises�	TypeErrorrr)r	rrrrr
�test_bad_types$s
z#Compare_Digest_Tests.test_bad_typescCs,|�t�dd�t�|�t�dd�t�dS)NrZxyz)�assertIsInstancerr�bool)r	rrr
�	test_bool-szCompare_Digest_Tests.test_boolN)�__name__�
__module__�__qualname__�__doc__rrrrrrrr
rs

	rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Random_Testsz*Test wrappers around SystemRandom methods.cCs^d}xTdD]L}xFtd�D]:}t�|�}|�d|ko@d|kn|||f�qWq
WdS)Nzrandbits(%d) returned %d)����r�)�rangerZrandbitsr)r	�errmsgZnumbits�i�nrrr
�
test_randbits6s


zRandom_Tests.test_randbitscCs<dddddddg}x$td�D]}|�t�|�|k�qWdS)	N�r'���� �@�
)r(rr�choice)r	�itemsr*rrr
�test_choice>szRandom_Tests.test_choicecCsNx(tdd�D]}|�t�|�t|��qW|�ttjd�|�ttjd�dS)Nr'r3r���)r(ZassertInrZ	randbelowr�
ValueError)r	r*rrr
�test_randbelowDszRandom_Tests.test_randbelowN)rrr r!r,r6r9rrrr
r"3sr"c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Token_TestszTest token functions.c
Cs�x�tjtjtjfD]�}|j|d��j|j}y
|�Wn"tk
rV|�d|�YnXy|d�Wn"tk
r�|�d|�YnXWdQRXqWtj}|�	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)r	r;�name�sizerrr
�test_token_defaultsOs

"zToken_Tests.test_token_defaultsc
CsRxLdD]D}|j|d��.|�t�|�t�|�tt�|��|�WdQRXqWdS)N)r-r/�r)r+)r?rrr<rr@rA)r	r+rrr
�test_token_bytesas
zToken_Tests.test_token_bytesc
CslxfdD]^}|j|d��Ht�|�}|�|t�|�t|�d|�|�tdd�|D���WdQRXqWdS)N)r-r$��Z)r+r'css|]}|tjkVqdS)N)�stringZ	hexdigits)�.0�crrr
�	<genexpr>osz-Token_Tests.test_token_hex.<locals>.<genexpr>)	r?rr=rrr@rAr�all)r	r+r
rrr
�test_token_hexhs

zToken_Tests.test_token_hexc
sltjtjd�xVdD]N}|j|d��8t�|�}|�|t�|�t	�fdd�|D���WdQRXqWdS)Nz-_)r-���L)r+c3s|]}|�kVqdS)Nr)rJrK)�legalrr
rLxsz1Token_Tests.test_token_urlsafe.<locals>.<genexpr>)
rIZ
ascii_letters�digitsr?rr>rrrrM)r	r+r
r)rRr
�test_token_urlsafeqs

zToken_Tests.test_token_urlsafeN)rrr r!rDrFrNrTrrrr
r:Ls
	r:�__main__)
r!rZunittestrIZTestCaserr"r:r�mainrrrr
�<module>s$/