%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/test/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/test/__pycache__/test_randbytes.cpython-312.pyc |
� Ϫ�f� � � � d Z ddlmZ ddlmZ ddlmZmZ ddlmZ ddl m Z G d� de� Z G d � d � Z G d� dee j � Z G d � dee j � Z G d� dee j � Zy)z- Test cases for L{twisted.python.randbytes}. � )�annotations)�Callable)�NoReturn�Protocol)� randbytes)�unittestc � � e Zd Zdd�Zdd�Zy)�_SupportsAssertionsc � � y �N� ��self�a�bs �=/usr/lib/python3/dist-packages/twisted/test/test_randbytes.py�assertEqualz_SupportsAssertions.assertEqual � � �� c � � y r r r s r �assertNotEqualz"_SupportsAssertions.assertNotEqual r r N)r �objectr r �returnr )�__name__� __module__�__qualname__r r r r r r r s � ��r r c � � e Zd ZdZdd�Zy)�SecureRandomTestCaseBasez1 Base class for secureRandom test cases. c �� � t dd� D ]Z } ||� }| j t |� |� ||� }| j t |� |� | j ||� �\ y)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)�ranger �lenr )r �source�nbytes�s�s2s r �_checkzSecureRandomTestCaseBase._check sc � � �B��m� '�F��v��A����S��V�V�,����B����S��W�f�-�����A�&� 'r N)r r r$ zCallable[[int], bytes]r �None)r r r �__doc__r( r r r r r s � ��'r r c � � e Zd ZdZdd�Zy)�SecureRandomTestsz4 Test secureRandom under normal conditions. c �B � | j t j � y)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 s r �test_normalzSecureRandomTests.test_normal4 s � � ���I�*�*�+r N�r r) )r r r r* r0 r r r r, r, / s � ��,r r, c �0 � e Zd ZdZdd�Zdd�Zdd�Zdd�Zy) �ConditionalSecureRandomTestsz< Test random sources one by one, then remove it to. c �6 � t j � | _ y)zJ Create a L{randbytes.RandomFactory} to use in the tests. N)r � RandomFactory�factoryr/ s r �setUpz"ConditionalSecureRandomTests.setUpC s � � !�.�.�0��r c �* � t j � �)zL A factory raising an error when a source is not available. )r �SourceNotAvailable)r r% s r �errorFactoryz)ConditionalSecureRandomTests.errorFactoryI s � � �*�*�,�,r c �N � | j | j j � y)zy L{RandomFactory._osUrandom} should work as a random source whenever L{os.urandom} is available. N)r( r6 � _osUrandomr/ s r �test_osUrandomz+ConditionalSecureRandomTests.test_osUrandomO s � � ���D�L�L�+�+�,r c � � � � j � j _ � j t j � j j d� d� fd�}� j t dt |� }� j t |� d� y)zt Remove all secure sources and assert it raises a failure. Then try the fallback parameter. � c �>