%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/twisted/test/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/twisted/test/__pycache__/test_randbytes.cpython-312.pyc

�

Ϫ�f����dZddlmZddlmZddlmZmZddlmZddl	m
Z
Gd�de�ZGd	�d
�ZGd�dee
j�ZGd
�dee
j�ZGd�dee
j�Zy)z-
Test cases for L{twisted.python.randbytes}.
�)�annotations)�Callable)�NoReturn�Protocol)�	randbytes)�unittestc��eZdZdd�Zdd�Zy)�_SupportsAssertionsc��y�N���self�a�bs   �=/usr/lib/python3/dist-packages/twisted/test/test_randbytes.py�assertEqualz_SupportsAssertions.assertEqual����c��yrr
rs   r�assertNotEqualz"_SupportsAssertions.assertNotEqualrrN)r�objectrr�returnr)�__name__�
__module__�__qualname__rrr
rrr
r
s���rr
c��eZdZdZdd�Zy)�SecureRandomTestCaseBasez1
    Base class for secureRandom test cases.
    c���tdd�D]Z}||�}|jt|�|�||�}|jt|�|�|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._checksc���B��m�	'�F��v��A����S��V�V�,����B����S��W�f�-�����A�&�
	'rN)rr
r$zCallable[[int], bytes]r�None)rrr�__doc__r(r
rrrrs���'rrc��eZdZdZdd�Zy)�SecureRandomTestsz4
    Test secureRandom under normal conditions.
    c�B�|jtj�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�rs r�test_normalzSecureRandomTests.test_normal4s��
	
���I�*�*�+rN�rr))rrrr*r0r
rrr,r,/s���,rr,c�0�eZdZdZdd�Zdd�Zdd�Zdd�Zy)	�ConditionalSecureRandomTestsz<
    Test random sources one by one, then remove it to.
    c�6�tj�|_y)zJ
        Create a L{randbytes.RandomFactory} to use in the tests.
        N)r�
RandomFactory�factoryr/s r�setUpz"ConditionalSecureRandomTests.setUpCs��!�.�.�0��rc�*�tj��)zL
        A factory raising an error when a source is not available.
        )r�SourceNotAvailable)rr%s  r�errorFactoryz)ConditionalSecureRandomTests.errorFactoryIs���*�*�,�,rc�N�|j|jj�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_osUrandomOs��
	
���D�L�L�+�+�,rc� ���j�j_�jtj
�jjd�d�fd�}�jtdt|�}�jt|�d�y)zt
        Remove all secure sources and assert it raises a failure. Then try the
        fallback parameter.
        �c�>���jjdd��S)Nr?T)�fallback)r6r.r/s�r�wrapperzBConditionalSecureRandomTests.test_withoutAnything.<locals>.wrapper`s����<�<�,�,�R�$�,�?�?rzPurandom unavailable - proceeding with non-cryptographically secure random sourceN)r�bytes)r:r6r<�assertRaisesr�SecureRandomNotAvailabler.�assertWarns�RuntimeWarning�__file__rr#)rrBr&s`  r�test_withoutAnythingz1ConditionalSecureRandomTests.test_withoutAnythingVsy���
#'�"3�"3���������.�.����0I�0I�2�	
�	@�
����
I���
��	
����Q���$rNr1)r%rrr)rrrr*r7r:r=rIr
rrr3r3<s���1�-�-�%rr3c� �eZdZdZdd�Zdd�Zy)�RandomBaseTestsz%
    'Normal' random test cases.
    c�B�|jtj�y)z"
        Test basic case.
        N)r(r�insecureRandomr/s rr0zRandomBaseTests.test_normalrs��	
���I�,�,�-rc�p�tj�}d|_|j|j�y)zG
        Test C{insecureRandom} without C{random.getrandbits}.
        N)rr5�getrandbitsr(rM)rr6s  r�test_withoutGetrandbitsz'RandomBaseTests.test_withoutGetrandbitsxs,���)�)�+��"������G�*�*�+rNr1)rrrr*r0rPr
rrrKrKms���.�,rrKN)r*�
__future__r�typingrrr�twisted.pythonr�
twisted.trialrr
r�TestCaser,�SynchronousTestCaser3rKr
rr�<module>rWsq���#��%�$�"��(��'�'�,
,�0�(�2C�2C�
,�.%��h�:�:�.%�b,�.��0L�0L�,r

Zerion Mini Shell 1.0