%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f����ddlmZddlmZmZddlmZddlmZeej�Gd�d��Z
Gd�dej�Zy	)
�)�implementer)�ethernet�raw)�
components)�unittestc��eZdZd�Zd�Zd�Zy)�
MyProtocolc�$�t|�|_y)N)�list�	expecting)�selfrs  �A/usr/lib/python3/dist-packages/twisted/pair/test/test_ethernet.py�__init__zMyProtocol.__init__s
���i����c��y)z!
        Not implemented
        N�)r
�num�protos   r�addProtozMyProtocol.addProtos�rc���|jsJd��|jjd�}t�}||||d�}|||fk(sJdj|||f���y)Nz(Got a packet when not expecting anymore.r��partial�dest�source�protocolzExpected {!r}, got {!r})r�pop�locals�format)	r
�datarrrr�expect�localVariables�paramss	         r�datagramReceivedzMyProtocol.datagramReceivedst���~�~�I�I�I�~����#�#�A�&�������� �	
���$���'�	
�)B�)I�)I��T�6�N�*
�	
�'rN)�__name__�
__module__�__qualname__rrr#rrrr	r	
s��)��

rr	c�B�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�
EthernetTestsc���tj�}tdddddd�fg�}|jd|�|j	dd��|j
rJd	|j
z��y)
N�foobarr�123456�987654�r�123456987654foobar�r�5Should not expect any more packets, but still want %r�r�EthernetProtocolr	rr#r�r
r�p1s   r�testPacketParsingzEthernetTests.testPacketParsing$s����)�)�+��
��#$� )�"+�$*�	��

�
��	���v�r�"�
���<�a��H��<�<�	
�C�b�l�l�R�	
��<rc	��tj�}tdddddd�fddd	d
dd�fg�}|jd|�|j	dd��|j	d
d��|j
rJd|j
z��y)Nr*rr+r,r-r�quux��012345�abcdefr.r/�012345abcdefquuxr0r1r3s   r�testMultiplePacketsz!EthernetTests.testMultiplePackets;s����)�)�+��
��#$� )�"+�$*�	���#$� )�"+�$*�	��
�
��,	���v�r�"�
���<�a��H�
���:�A��F��<�<�	
�C�b�l�l�R�	
��<rc��tj�}tdddddd�fg�}tdddddd�fg�}|jd|�|jd|�|j	dd��|j
r Jd	j
|j
���|j
r Jd	j
|j
���y)
Nr*rr+r,r-rr.r/z7Should not expect any more packets, but still want {!r})rr2r	rr#rr�r
rr4�p2s    r�testMultipleSameProtosz$EthernetTests.testMultipleSameProtos\s����)�)�+��
��#$� )�"+�$*�	��

�
����#$� )�"+�$*�	��

�
��	���v�r�"�
���v�r�"�
���<�a��H����	
�G�N�N��L�L�
�	
��
���	
�G�N�N��L�L�
�	
��rc��tj�}tg�}|jd|�|j	dd��|j	dd��y)Nir.rr/r;r8)rr2r	rr#r3s   r�testWrongProtoNotSeenz#EthernetTests.testWrongProtoNotSeen�sO���)�)�+��
��^��
���v�r�"�
���<�a��H�
���:�A��Frc	��tj�}tdddddd�fddd	d
dd�fg�}|jd|�tddd	d
dd�fdddddd�fg�}|jd|�|j	dd�
�|j	dd�
�|j	dd�
�|j	dd�
�|j
rJd|j
z��|j
rJd|j
z��y)Nr*rr+r,r-rr7r8r9r:ir.r/s012345abcdefquuxs123456987654foobarr;r0r1r>s    r�testDemuxingzEthernetTests.testDemuxing�sN���)�)�+��
��#$� )�"+�$*�	���#$� )�"+�$*�	��
�
��,	���v�r�"�
��#$� )�"+�$*�	���#$� )�"+�$*�	��
�
��,	���v�r�"�
���<�a��H�
���:�A��F�
���<�a��H�
���:�A��F��<�<�	
�C�b�l�l�R�	
���<�<�	
�C�b�l�l�R�	
��<rc��tj�}	|jdd�td��#tj
$rYywxYw)z2Adding a wrong level protocol raises an exception.�*�	silliness�2addProto must raise an exception for bad protocolsN)rr2r�AssertionErrorr�CannotAdapt�r
�es  r�testAddingBadProtos_WrongLevelz,EthernetTests.testAddingBadProtos_WrongLevel�sL���%�%�'��	W�
�J�J�r�;�'�!�!U�V�V���%�%�	��	�s�3�A	�A	c���tj�}	|jdtg��t	d��#t
$r}|jdk(rn�Yd}~yd}~wwxYw)z=Adding a protocol with a negative number raises an exception.���rH)z'Added protocol must be positive or zeroN�rr2rr	rI�	TypeError�argsrKs  r�testAddingBadProtos_TooSmallz*EthernetTests.testAddingBadProtos_TooSmall�s`���%�%�'��	W�
�J�J�r�:�b�>�*�!�!U�V�V��
�	��v�v�E�E�����	���<�	A �A�A c���tj�}	|jdtg��t	d��#t
$r}|jdk(rn�Yd}~yd}~wwxYw)�<Adding a protocol with a number >=2**16 raises an exception.irH�z"Added protocol must fit in 16 bitsNrPrKs  r�testAddingBadProtos_TooBigz(EthernetTests.testAddingBadProtos_TooBig�s`���%�%�'��	W�
�J�J�u�j��n�-�!�!U�V�V��
�	��v�v�@�@�����	�rTc���tj�}	|jdtg��t	d��#t
$r}|jdk(rn�Yd}~yd}~wwxYw)rVirHrWNrPrKs  r�testAddingBadProtos_TooBig2z)EthernetTests.testAddingBadProtos_TooBig2�s`���%�%�'��	W�
�J�J�y�*�R�.�1�!�!U�V�V��
�	��v�v�@�@�����	�rTN)r$r%r&r5r<r@rBrDrMrSrXrZrrrr(r(#s7��
�.
�B,
�\G�<
�|W�W�W�Wrr(N)
�zope.interfacer�twisted.pairrr�twisted.pythonr�
twisted.trialr�IRawPacketProtocolr	�TestCaser(rrr�<module>rasM��'�&�%�"�
�S�
#�
#�$�
�
�%�
�0\W�H�%�%�\Wr

Zerion Mini Shell 1.0