%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f	6����dZddlZddlmZddlmZddlmZddlmZGd�dej�Z
d	�Zeed
��ZGd�d
ej�Z
eed��ZGd�dej�Zy)z*
Test cases for L{twisted.names.rfc1982}.
�N)�datetime)�partial��SerialNumber)�unittestc��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�SerialNumberTestsz$
    Tests for L{SerialNumber}.
    c�N�|jtd�jd�y)zB
        L{SerialNumber.serialBits} has default value 32.
        �� N��assertEqualr�_serialBits��selfs �A/usr/lib/python3/dist-packages/twisted/names/test/test_rfc1982.py�test_serialBitsDefaultz(SerialNumberTests.test_serialBitsDefaults��	
����a��4�4�b�9�c�R�|jtdd��jd�y)z�
        L{SerialNumber.__init__} accepts a C{serialBits} argument whose value is
        assigned to L{SerialNumber.serialBits}.
        r���
serialBitsNr
rs r�test_serialBitsOverridez)SerialNumberTests.test_serialBitsOverrides!��
	
����a�A�6�B�B�A�Frc	�P�|jdttdd����y)ze
        L{SerialNumber.__repr__} returns a string containing number and
        serialBits.
        z'<SerialNumber number=123 serialBits=32>�{rrN)r�reprrrs r�	test_reprzSerialNumberTests.test_repr#s$��
	
���5���c�b�1�2�	
rc�L�|jttd��d�y)zg
        L{SerialNumber.__str__} returns a string representation of the current
        value.
        r�123N)r�strrrs r�test_strzSerialNumberTests.test_str-s��
	
����\�#�.�/��7rc�L�|jttd��d�y)zi
        L{SerialNumber.__int__} returns an integer representation of the current
        value.
        rN)r�intrrs r�test_intzSerialNumberTests.test_int4s��
	
����\�#�.�/��5rc���|jttd��ttd���|jttd��ttd���y)z|
        L{SerialNumber.__hash__} allows L{SerialNumber} instances to be hashed
        for use as dictionary keys.
        r�N)r�hashr�assertNotEqualrs r�	test_hashzSerialNumberTests.test_hash;sH��
	
����l�1�o�.��\�!�_�0E�F����D��a��1�4��Q��3H�Irc�z�tdd��}tdd��}|jt|j|�y)z�
        L{SerialNumber._convertOther} raises L{TypeError} if the other
        SerialNumber instance has a different C{serialBits} value.
        rrr�N)r�assertRaises�	TypeError�
_convertOther)r�s1�s2s   r�#test_convertOtherSerialBitsMismatchz5SerialNumberTests.test_convertOtherSerialBitsMismatchCs4��
�!��
*��
�!��
+�����)�R�%5�%5�r�:rc�L�|jtd�td��y)zK
        L{SerialNumber.__eq__} provides rich equality comparison.
        rN�rrrs r�test_eqzSerialNumberTests.test_eqMs��	
����a��,�q�/�:rc��|jtd�t�k(�|jtd�j	t��t
�y)zy
        == comparison of L{SerialNumber} with a non-L{SerialNumber} instance
        returns L{NotImplemented}.
        rN)�assertFalser�object�assertIs�__eq__�NotImplementedrs r�test_eqForeignTypez$SerialNumberTests.test_eqForeignTypeSs<��
	
����a��F�H�4�5��
�
�l�1�o�,�,�V�X�6��Grc��|jtd�td�k7�|jtd�td��y)zK
        L{SerialNumber.__ne__} provides rich equality comparison.
        rr&N)r6rr(rs r�test_nezSerialNumberTests.test_ne[s7��	
����a��L��O�;�<����L��O�\�!�_�=rc��|jtd�t�k7�|jtd�j	t��t
�y)zy
        != comparison of L{SerialNumber} with a non-L{SerialNumber} instance
        returns L{NotImplemented}.
        rN)�
assertTruerr7r8�__ne__r:rs r�test_neForeignTypez$SerialNumberTests.test_neForeignTypebs:��
	
����Q��6�8�3�4��
�
�l�1�o�,�,�V�X�6��Grc��|jtd�td�k�|jtd�td�k�y)zE
        L{SerialNumber.__le__} provides rich <= comparison.
        rr&N�r?rrs r�test_lezSerialNumberTests.test_lej�6��	
����Q��<��?�:�;�����Q��<��?�:�;rc�2�|jtd��y)zs
        <= comparison of L{SerialNumber} with a non-L{SerialNumber} instance
        raises L{TypeError}.
        c�.�td�t�kS�Nr�rr7�rr�<lambda>z6SerialNumberTests.test_leForeignType.<locals>.<lambda>v���\�!�_���-H�rN�r,r-rs r�test_leForeignTypez$SerialNumberTests.test_leForeignTypeq���
	
���)�%H�Irc��|jtd�td�k\�|jtd�td�k\�y)zE
        L{SerialNumber.__ge__} provides rich >= comparison.
        rr&NrCrs r�test_gezSerialNumberTests.test_gexrErc�2�|jtd��y)zs
        >= comparison of L{SerialNumber} with a non-L{SerialNumber} instance
        raises L{TypeError}.
        c�.�td�t�k\SrHrIrJrrrKz6SerialNumberTests.test_geForeignType.<locals>.<lambda>�rLrNrMrs r�test_geForeignTypez$SerialNumberTests.test_geForeignTyperOrc�P�|jtd�td�k�y)zD
        L{SerialNumber.__lt__} provides rich < comparison.
        rr&NrCrs r�test_ltzSerialNumberTests.test_lt����	
����Q��,�q�/�9�:rc�2�|jtd��y)zr
        < comparison of L{SerialNumber} with a non-L{SerialNumber} instance
        raises L{TypeError}.
        c�.�td�t�kSrHrIrJrrrKz6SerialNumberTests.test_ltForeignType.<locals>.<lambda>����\�!�_�v�x�-G�rNrMrs r�test_ltForeignTypez$SerialNumberTests.test_ltForeignType����
	
���)�%G�Hrc�P�|jtd�td�kD�y)zD
        L{SerialNumber.__gt__} provides rich > comparison.
        r&rNrCrs r�test_gtzSerialNumberTests.test_gt�rWrc�2�|jtd��y)zt
        > comparison of L{SerialNumber} with a non-L{SerialNumber} instance
          raises L{TypeError}.
        c�.�td�t�kDS)Nr&rIrJrrrKz6SerialNumberTests.test_gtForeignType.<locals>.<lambda>�rZrNrMrs r�test_gtForeignTypez$SerialNumberTests.test_gtForeignType�r\rc�d�|jtd�td�ztd��y)zX
        L{SerialNumber.__add__} allows L{SerialNumber} instances to be summed.
        rr&Nr3rs r�test_addzSerialNumberTests.test_add�s%��	
����a��<��?�:�L��O�Lrc�2�|jtd��y)zn
        Addition of L{SerialNumber} with a non-L{SerialNumber} instance raises
        L{TypeError}.
        c�.�td�t�zSrHrIrJrrrKz7SerialNumberTests.test_addForeignType.<locals>.<lambda>�rZrNrMrs r�test_addForeignTypez%SerialNumberTests.test_addForeignType�r\rc�b��td�j�|jt�fd��y)zp
        L{SerialNumber} cannot be added with other SerialNumber values larger
        than C{_maxAdd}.
        rc�8��td�t�dz�zSrHr)�maxAdds�rrKz:SerialNumberTests.test_addOutOfRangeHigh.<locals>.<lambda>�s���\�!�_�|�F�Q�J�7O�%O�rN)r�_maxAddr,�ArithmeticError)rris @r�test_addOutOfRangeHighz(SerialNumberTests.test_addOutOfRangeHigh�s(���
�a��(�(������O�	
rc���td�}|j|jzdz
}|dz}|jt|�t|�kD�|jt|�td��y)z�
        L{SerialNumber.__add__} returns a wrapped value when s1 plus the s2
        would result in a value greater than the C{maxVal}.
        rrN)r�	_halfRingr?r)r�s�maxVal�maxValPlus1s    r�test_maxValzSerialNumberTests.test_maxVal�sa��

��O�����q�{�{�*�Q�.���q�j������[�1�L��4H�H�I�����k�2�L��O�Drc�`�|jtd�tjd��y)z�
        L{SerialNumber.fromRFC4034DateString} accepts a datetime string argument
        of the form 'YYYYMMDDhhmmss' and returns an L{SerialNumber} instance
        whose value is the unix timestamp corresponding to that UTC date.
        ���N�20120101000000N)rr�fromRFC4034DateStringrs r�test_fromRFC4034DateStringz,SerialNumberTests.test_fromRFC4034DateString�s)��	
�����$��.�.�/?�@�	
rc�V�|jdtd�j��y)z�
        L{DateSerialNumber.toRFC4034DateString} interprets the current value as
        a unix timestamp and returns a date string representation of that date.
        rurtN�rr�toRFC4034DateStringrs r�test_toRFC4034DateStringz*SerialNumberTests.test_toRFC4034DateString�s%��
	
����l�:�6�J�J�L�	
rc�V�|jtd�j�d�y)zq
        L{SerialNumber.toRFC4034DateString} stores 32bit timestamps relative to
        the UNIX epoch.
        r�19700101000000Nryrs r�test_unixEpochz SerialNumberTests.test_unixEpoch�s"��
	
����a��<�<�>�@P�Qrc�V�|jtd�j�d�y)zI
        L{SerialNumber} wraps unix timestamps in the year 2106.
        ����21060207062815Nryrs r�test_Y2106Problemz#SerialNumberTests.test_Y2106Problem�s#��	
����b�)�=�=�?�AQ�Rrc
����tjtdddddd�j���|j	�td�j�|jt�fd��y	)
zy
        L{SerialNumber} raises ArithmeticError when used to add dates more than
        68 years in the future.
        i�r����rc�8��td�t�dz�zS)Nrrr)�
maxAddTimes�rrKz5SerialNumberTests.test_Y2038Problem.<locals>.<lambda>�s���\�!�_�|�J�QR�N�7S�%S�rN)	�calendar�timegmr�utctimetuplerrrjr,rk)rr�s @r�test_Y2038Problemz#SerialNumberTests.test_Y2038Problem�s_���
�_�_�X�d�A�r�1�b�!�%D�%Q�%Q�%S�T�
�������O�#�#�	
�
	
����S�	
rN) �__name__�
__module__�__qualname__�__doc__rrrr!r$r)r1r4r;r=rArDrNrQrTrVr[r^rarcrfrlrrrwr{r~r�r�rJrrr	r	s����:�G�
�8�6�J�;�;�H�>�H�<�J�<�J�;�I�;�I�M�I�
�	E�	
�
�R�S�
rr	c���|j||k(�|j||k�|j||k�|j||kD�|j||k\�y)a�
    A custom assertion for L{SerialNumber} values that cannot be meaningfully
    compared.

    "Note that there are some pairs of values s1 and s2 for which s1 is not
    equal to s2, but for which s1 is neither greater than, nor less than, s2.
    An attempt to use these ordering operators on such pairs of values produces
    an undefined result."

    @see: U{https://tools.ietf.org/html/rfc1982#section-3.2}

    @param testCase: The L{unittest.TestCase} on which to call assertion
        methods.
    @type testCase: L{unittest.TestCase}

    @param s1: The first value to compare.
    @type s1: L{SerialNumber}

    @param s2: The second value to compare.
    @type s2: L{SerialNumber}
    N)r6)�testCaser/r0s   r�assertUndefinedComparisonr��s^��,
����r��"�����r��"�����b��!�����b��!�����r��"rr&rc�(�eZdZdZd�Zd�Zd�Zd�Zy)�SerialNumber2BitTestsaF
    Tests for correct answers to example calculations in RFC1982 5.1.

    The simplest meaningful serial number space has SERIAL_BITS == 2.  In this
    space, the integers that make up the serial number space are 0, 1, 2, and 3.
    That is, 3 == 2^SERIAL_BITS - 1.

    https://tools.ietf.org/html/rfc1982#section-5.1
    c�R�|jtdd��jd�y)z�
        In this space, the largest integer that it is meaningful to add to a
        sequence number is 2^(SERIAL_BITS - 1) - 1, or 1.
        rr&rrN�rrrjrs r�test_maxaddz!SerialNumber2BitTests.test_maxadds!��
	
����a�A�6�>�>��Brc��|jtd�td�ztd��|jtd�td�ztd��|jtd�td�ztd��|jtd�td�ztd��y)zN
        Then, as defined 0+1 == 1, 1+1 == 2, 2+1 == 3, and 3+1 == 0.
        rrr&r�N)r�
serialNumber2rs rrczSerialNumber2BitTests.test_add&s���	
����q�)�M�!�,<�<�m�A�>N�O�����q�)�M�!�,<�<�m�A�>N�O�����q�)�M�!�,<�<�m�A�>N�O�����q�)�M�!�,<�<�m�A�>N�Orc�4�|jtd�td�kD�|jtd�td�kD�|jtd�td�kD�|jtd�td�kD�y)z:
        Further, 1 > 0, 2 > 1, 3 > 2, and 0 > 3.
        rrr&r�N)r?r�rs rr^zSerialNumber2BitTests.test_gt/sp��	
���
�a�(�=��+;�;�<����
�a�(�=��+;�;�<����
�a�(�=��+;�;�<����
�a�(�=��+;�;�<rc��t|td�td��t|td�td��t|td�td��t|td�td��y)zU
        It is undefined whether 2 > 0 or 0 > 2, and whether 1 > 3 or 3 > 1.
        r&rrr�N)r�r�rs r�test_undefinedz$SerialNumber2BitTests.test_undefined8s\��	"�$�
�a�(8�-��:J�K�!�$�
�a�(8�-��:J�K�!�$�
�a�(8�-��:J�K�!�$�
�a�(8�-��:J�KrN)r�r�r�r�r�rcr^r�rJrrr�r�s���C�P�=�Lrr�rc�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�SerialNumber8BitTestsa.
    Tests for correct answers to example calculations in RFC1982 5.2.

    Consider the case where SERIAL_BITS == 8.  In this space the integers that
    make up the serial number space are 0, 1, 2, ... 254, 255.  255 ==
    2^SERIAL_BITS - 1.

    https://tools.ietf.org/html/rfc1982#section-5.2
    c�R�|jtdd��jd�y)z�
        In this space, the largest integer that it is meaningful to add to a
        sequence number is 2^(SERIAL_BITS - 1) - 1, or 127.
        rrr�Nr�rs rr�z!SerialNumber8BitTests.test_maxaddPs!��
	
����a�A�6�>�>��Drc�$�|jtd�td�ztd��|jtd�td�ztd��|jtd�td�ztd��y)z|
        Addition is as expected in this space, for example: 255+1 == 0,
        100+100 == 200, and 200+100 == 44.
        �rr�d���,N)r�
serialNumber8rs rrczSerialNumber8BitTests.test_addWsr��
	
����s�+�m�A�.>�>�
�a�@P�Q�����s�+�m�C�.@�@�-�PS�BT�U�����s�+�m�C�.@�@�-�PR�BS�Trc��|jtd�td�kD�|jtd�td�kD�|jtd�td�kD�|jtd�td�kD�|jtd�td�kD�|jtd�td�kD�|jtd�td�kD�|jtd�td�kD�|jtd�td�kD�y)z�
        Comparison is more interesting, 1 > 0, 44 > 0, 100 > 0, 100 > 44,
        200 > 100, 255 > 200, 0 > 255, 100 > 255, 0 > 200, and 44 > 200.
        rrr�r�r�r�N�r?r�rs rr^zSerialNumber8BitTests.test_gt`s���
	
���
�a�(�=��+;�;�<����
�b�)�M�!�,<�<�=����
�c�*�]�1�-=�=�>����
�c�*�]�2�->�>�?����
�c�*�]�3�-?�?�@����
�c�*�]�3�-?�?�@����
�c�*�]�3�-?�?�@����
�a�(�=��+=�=�>����
�b�)�M�#�,>�>�?rc���|jtd�td�ztd�kD�|jtd�td�ztd�ztd�k�y)a�
        Note that 100+100 > 100, but that (100+100)+100 < 100.  Incrementing a
        serial number can cause it to become "smaller".  Of course, incrementing
        by a smaller number will allow many more increments to be made before
        this occurs.  However this is always something to be aware of, it can
        cause surprising errors, or be useful as it is the only defined way to
        actually cause a serial number to decrease.
        r�Nr�rs r�test_surprisingAdditionz-SerialNumber8BitTests.test_surprisingAdditionos_��	
���
�c�*�]�3�-?�?�-�PS�BT�T�U�����#���s�!3�3�m�C�6H�H��C� �
!�	
rc��t|td�td��t|td�td��t|td�td��t|td�td��y	)
z�
        The pairs of values 0 and 128, 1 and 129, 2 and 130, etc, to 127 and 255
        are not equal, but in each pair, neither number is defined as being
        greater than, or less than, the other.
        r�r�r&�r�r�N)r�r�rs rr�z$SerialNumber8BitTests.test_undefined~s\��	"�$�
�a�(8�-��:L�M�!�$�
�a�(8�-��:L�M�!�$�
�a�(8�-��:L�M�!�$�
�c�(:�M�#�<N�OrN)	r�r�r�r�r�rcr^r�r�rJrrr�r�Es$���E�U�
@�

�	Prr�)r�r�r�	functoolsr�twisted.names._rfc1982r�
twisted.trialr�TestCaser	r�r�r�r�r�rJrr�<module>r�s|���
���/�"�`
��)�)�`
�F#�:���3�
�+L�H�-�-�+L�\���3�
�BP�H�-�-�BPr

Zerion Mini Shell 1.0