%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f�����dZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZee
�Gd	�d
��Zee
e�ee�Gd�de��Zeee�y
)z$
Utilities for Twisted.names tests.
�)�	randrange)�implementer)�verifyClass)�IPv4Address)�succeed)�IReactorUDP�
IUDPTransport)�Clockc�<�eZdZdZd�Zd�Zd�Zd
d�Zd�Zd�Z	d	�Z
y)�MemoryDatagramTransporta�
    This L{IUDPTransport} implementation enforces the usual connection rules
    and captures sent traffic in a list for later inspection.

    @ivar _host: The host address to which this transport is bound.
    @ivar _protocol: The protocol connected to this transport.
    @ivar _sentPackets: A C{list} of two-tuples of the datagrams passed to
        C{write} and the addresses to which they are destined.

    @ivar _connectedTo: L{None} if this transport is unconnected, otherwise an
        address to which all traffic is supposedly sent.

    @ivar _maxPacketSize: An C{int} giving the maximum length of a datagram
        which will be successfully handled by C{write}.
    c�J�||_||_g|_d|_||_y�N)�_host�	_protocol�_sentPackets�_connectedTo�_maxPacketSize)�self�host�protocol�
maxPacketSizes    �>/usr/lib/python3/dist-packages/twisted/names/test/test_util.py�__init__z MemoryDatagramTransport.__init__&s(����
�!������ ���+���c�.�tdg|j���S)z_
        Return the address which this transport is pretending to be bound
        to.
        �UDP)rr�rs r�getHostzMemoryDatagramTransport.getHost-s��
�5�.�4�:�:�.�.rc�D�|j�td��||f|_y)z>
        Connect this transport to the given address.
        NzAlready connected)r�
ValueError)rr�ports   r�connectzMemoryDatagramTransport.connect4s(�����(��0�1�1�!�4�L��rNc��|�|j}|�td��t|�|jkDrtd��|jj||f�y)z*
        Send the given datagram.
        NzNeed an addresszPacket too big)rr �lenrr�append)r�datagram�addrs   r�writezMemoryDatagramTransport.write<s\���<��$�$�D��<��.�/�/��x�=�4�.�.�.��-�.�.���� � �(�D�!1�2rc�L�|jj�td�S)z+
        Shut down this transport.
        N)r�stopProtocolrrs r�
stopListeningz%MemoryDatagramTransport.stopListeningHs��	
���#�#�%��t�}�rc��y�zC
        Dummy implementation to satisfy L{IUDPTransport}.
        N�)r�enableds  r�setBroadcastAllowedz+MemoryDatagramTransport.setBroadcastAllowedO���	
rc��yr-r.rs r�getBroadcastAllowedz+MemoryDatagramTransport.getBroadcastAllowedUr1rr)�__name__�
__module__�__qualname__�__doc__rrr"r(r+r0r3r.rrrrs*��� ,�/�)�
3��
�
rrc��eZdZdZd�Zdd�Zy)�
MemoryReactoraO
    An L{IReactorTime} and L{IReactorUDP} provider.

    Time is controlled deterministically via the base class, L{Clock}.  UDP is
    handled in-memory by connecting protocols to instances of
    L{MemoryDatagramTransport}.

    @ivar udpPorts: A C{dict} mapping port numbers to instances of
        L{MemoryDatagramTransport}.
    c�<�tj|�i|_yr)r
r�udpPortsrs rrzMemoryReactor.__init__ls��
���t����
rc���|dk(r	tdd�}||jvrn�||jvrtd��t||f||�}||j|<|j	|�|S)zR
        Pretend to bind a UDP port and connect the given protocol to it.
        r�izAddress in use)rr;r r�makeConnection)rr!r�	interfacer�	transports      r�	listenUDPzMemoryReactor.listenUDPps}���1�9�� ��E�*���t�}�}�,����4�=�=� ��-�.�.�+�Y��,=�x��W�	�'��
�
�d�����	�*��rN)�i )r4r5r6r7rrAr.rrr9r9_s��	��rr9N)r7�randomr�zope.interfacer�zope.interface.verifyr�twisted.internet.addressr�twisted.internet.deferr�twisted.internet.interfacesrr	�twisted.internet.taskr
rr9r.rr�<module>rJs}���
�&�-�0�*�B�'�
�]��D
�D
��D
�N�M�2�3�
�[���E����B�K��'r

Zerion Mini Shell 1.0