Server IP : 209.38.156.173 / Your IP : 216.73.216.122 [ Web Server : Apache/2.4.52 (Ubuntu) System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.1.2-1ubuntu2.22 Disable Function : NONE Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/twisted/test/__pycache__/ |
Upload File : |
o �b� � @ sj d Z ddlmZ ddlmZ G dd� d�ZG dd� deej�ZG dd � d eej�Z G d d� deej�Z dS ) z- Test cases for L{twisted.python.randbytes}. � )� randbytes)�unittestc @ � e Zd ZdZdd� ZdS )�SecureRandomTestCaseBasez1 Base class for secureRandom test cases. c C sP t dd�D ] }||�}| �t|�|� ||�}| �t|�|� | �||� qdS )a| The given random bytes source should return the number of bytes requested each time it is called and should probably not return the same bytes on two consecutive calls (although this is a perfectly legitimate occurrence and rejecting it may generate a spurious failure -- maybe we'll get lucky and the heat death with come first). � � N)�range�assertEqual�len�assertNotEqual)�self�source�nbytes�s�s2� r �=/usr/lib/python3/dist-packages/twisted/test/test_randbytes.py�_check s �zSecureRandomTestCaseBase._checkN)�__name__� __module__�__qualname__�__doc__r r r r r r � r c @ r )�SecureRandomTestsz4 Test secureRandom under normal conditions. c C � | � tj� dS )z� L{randbytes.secureRandom} should return a string of the requested length and make some effort to make its result otherwise unpredictable. N)r r �secureRandom�r r r r �test_normal( s zSecureRandomTests.test_normalN)r r r r r r r r r r # r r c @ s0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd S )�ConditionalSecureRandomTestsz< Test random sources one by one, then remove it to. c C s t �� | _dS )zJ Create a L{randbytes.RandomFactory} to use in the tests. N)r � RandomFactory�factoryr r r r �setUp7 s z"ConditionalSecureRandomTests.setUpc C s t �� �)zL A factory raising an error when a source is not available. )r �SourceNotAvailable)r r r r r �errorFactory= s z)ConditionalSecureRandomTests.errorFactoryc C s | � | jj� dS )zy L{RandomFactory._osUrandom} should work as a random source whenever L{os.urandom} is available. N)r r � _osUrandomr r r r �test_osUrandomC s z+ConditionalSecureRandomTests.test_osUrandomc sN � j � j_� �tj� jjd� � fdd�}� �tdt |�}� � t|�d� dS )zt Remove all secure sources and assert it raises a failure. Then try the fallback parameter. � c s � j jddd�S )Nr&