%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f�$����dZddlZddlZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
mZddlmZdd	lmZGd
�de
�ZGd�d
e
�ZGd�de
�ZGd�de
�Ze�j1ej3��e�j1ej3��e�j1ej3��e�j1ej3��y)aD
Tests for implementations of L{IReactorSocket}.

Generally only tests for failure cases are found here.  Success cases for
this interface are tested elsewhere.  For example, the success case for
I{AF_INET} is in L{twisted.internet.test.test_tcp}, since that case should
behave exactly the same as L{IReactorTCP.listenTCP}.
�N)�verify)�UnsupportedAddressFamily)�IReactorSocket)�DatagramProtocol�
ServerFactory)�ReactorBuilder�needsRunningReactor)�err)�platformc��eZdZdZegZd�Zy)�&IReactorSocketVerificationTestsBuilderaO
    Builder for testing L{IReactorSocket} implementations for required
    methods and method signatures.

    L{ReactorBuilder} already runs L{IReactorSocket.providedBy} to
    ensure that these tests will only be run on reactor classes that
    claim to implement L{IReactorSocket}.

    These tests ensure that reactors which claim to provide the
    L{IReactorSocket} interface actually have all the required methods
    and that those methods have the expected number of arguments.

    These tests will be skipped for reactors which do not claim to
    provide L{IReactorSocket}.
    c�v�|j�}|jtjt|��y)zf
        The reactor instance returned by C{buildReactor} provides
        L{IReactorSocket}.
        N)�buildReactor�
assertTruer�verifyObjectr)�self�reactors  �C/usr/lib/python3/dist-packages/twisted/internet/test/test_socket.py�
test_providerz4IReactorSocketVerificationTestsBuilder.test_provider-s+��
�#�#�%������+�+�N�G�D�E�N)�__name__�
__module__�__qualname__�__doc__r�requiredInterfacesr�rrr
r
s��� )�)��Frr
c�(�eZdZdZegZd�Zd�Zd�Zy)�!AdoptStreamPortErrorsTestsBuilderas
    Builder for testing L{IReactorSocket.adoptStreamPort} implementations.

    Generally only tests for failure cases are found here.  Success cases for
    this interface are tested elsewhere.  For example, the success case for
    I{AF_INET} is in L{twisted.internet.test.test_tcp}, since that case should
    behave exactly the same as L{IReactorTCP.listenTCP}.
    c���|j�}tj�}|j�}|j�|j	tj
|j|tjt��}tj�r.|j|jdtj�y|j|jdtj�y)z�
        An implementation of L{IReactorSocket.adoptStreamPort} raises
        L{socket.error} if passed an integer which is not associated with a
        socket.
        rN)r�socket�fileno�close�assertRaises�error�adoptStreamPort�AF_INETrr�	isWindows�assertEqual�args�errno�WSAENOTSOCK�EBADF�rr�prober!�excs     r�test_invalidDescriptorz8AdoptStreamPortErrorsTestsBuilder.test_invalidDescriptorBs����#�#�%���
�
��������
���
�����L�L��#�#���N�N��O�
���������S�X�X�a�[�%�*;�*;�<����S�X�X�a�[�%�+�+�6rc�<�|j�}tj�}|jd�|jd�|j	|j
�d}|j
t|j|j�|t��y)z�
        An implementation of L{IReactorSocket.adoptStreamPort} raises
        L{UnsupportedAddressFamily} if passed an address family it does not
        support.
        �z	127.0.0.1r��N)rr �bind�listen�
addCleanupr"r#rr%r!r�rr�port�	arbitrarys    r�test_invalidAddressFamilyz;AdoptStreamPortErrorsTestsBuilder.test_invalidAddressFamilyZsu���#�#�%���}�}����	�	�"�#����A������
�
�#��	����$��#�#��K�K�M���O�	
rc�������j��tj���j�j��j	d��jd��j
d��j�j��jt��}|j����fd�}�j|��jtd�t���fd���j!�y)a9
        When the L{IListeningPort} returned by
        L{IReactorSocket.adoptStreamPort} is stopped using
        C{stopListening}, the underlying socket is closed but not
        shutdown.  This allows another process which still has a
        reference to it to continue accepting connections over it.
        r2r3Fc�8���jtj�j�}t	j
�r.�j
|jdtj�y�j
|jdtj�y)Nr)r#r r$�acceptrr'r(r)r*�WSAEWOULDBLOCK�EAGAIN��ignoredr/�
portSocketrs  ��r�stoppedzFAdoptStreamPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.stopped�sg����#�#�F�L�L�*�2C�2C�D�C��!�!�#�� � ����!��e�.B�.B�C�� � ����!��e�l�l�;rz"Failed to accept on original port.c�,���j�fd��S)Nc�$���j�S�N��stop�rBrs �r�<lambda>zYAdoptStreamPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.<lambda>.<locals>.<lambda>��
���7�<�<�>�r��addCallback��drs��rrKzGAdoptStreamPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.<lambda>�����Q�]�]�+I�J�rN)rr r7r"r5r6�setblockingr%r!�familyr�
stopListeningrN�
addErrbackr
r	�run�rr9rDrPrCrs`  @@@r�test_stopOnlyClosesz5AdoptStreamPortErrorsTestsBuilder.test_stopOnlyClosesqs�����#�#�%���]�]�_�
����
�(�(�)����(�)����!�����u�%��&�&������!2�!2�M�O�
��
��� ��	<�	
�
�
�g��	���S�>�?���J�	
�	���
rN�	rrrrrrr0r;rXrrrrr6s!���)�)��7�0
�.(rrc��eZdZdZegZd�Zy)�'AdoptStreamConnectionErrorsTestsBuildera}
    Builder for testing L{IReactorSocket.adoptStreamConnection}
    implementations.

    Generally only tests for failure cases are found here.  Success cases for
    this interface are tested elsewhere.  For example, the success case for
    I{AF_INET} is in L{twisted.internet.test.test_tcp}, since that case should
    behave exactly the same as L{IReactorTCP.listenTCP}.
    c��|j�}tj�}|j|j�d}|j	t
|j|j�|t��y)z�
        An implementation of L{IReactorSocket.adoptStreamConnection} raises
        L{UnsupportedAddressFamily} if passed an address family it does not
        support.
        r4N)	rr r7r"r#r�adoptStreamConnectionr!r)rr�
connectionr:s    rr;zAAdoptStreamConnectionErrorsTestsBuilder.test_invalidAddressFamily�sb���#�#�%���]�]�_�
����
�(�(�)��	����$��)�)�������O�	
rN)rrrrrrr;rrrr[r[�s���)�)��
rr[c�(�eZdZdZegZd�Zd�Zd�Zy)�#AdoptDatagramPortErrorsTestsBuilderzR
    Builder for testing L{IReactorSocket.adoptDatagramPort} implementations.
    c���|j�}tj�}|j�}|j�|j	tj
|j|tjt��}tj�r.|j|jdtj�y|j|jdtj�y)z�
        An implementation of L{IReactorSocket.adoptDatagramPort} raises
        L{socket.error} if passed an integer which is not associated with a
        socket.
        rN)rr r!r"r#r$�adoptDatagramPortr&rrr'r(r)r*r+r,r-s     rr0z:AdoptDatagramPortErrorsTestsBuilder.test_invalidDescriptor�s����#�#�%���
�
��������
���
�����L�L��%�%���N�N���
���������S�X�X�a�[�%�*;�*;�<����S�X�X�a�[�%�+�+�6rc�4�|j�}tjtjtj�}|j	|j
�d}|j
t|j|j�|t��y)z�
        An implementation of L{IReactorSocket.adoptDatagramPort} raises
        L{UnsupportedAddressFamily} if passed an address family it does not
        support.
        r4N)rr r&�
SOCK_DGRAMr7r"r#rrbr!rr8s    rr;z=AdoptDatagramPortErrorsTestsBuilder.test_invalidAddressFamily�sm���#�#�%���}�}�V�^�^�V�->�->�?������
�
�#��	����$��%�%��K�K�M����	
rc�*������j��tjtjtj���j	�j
��j
d��jd��j�j��jt��}|j����fd�}�j|��jtd�t!���fd���j#�y)a7
        When the L{IListeningPort} returned by
        L{IReactorSocket.adoptDatagramPort} is stopped using
        C{stopListening}, the underlying socket is closed but not
        shutdown.  This allows another process which still has a
        reference to it to continue reading and writing to it.
        r2Fc�:���jtj�jd�}t	j
�r.�j
|jdtj�y�j
|jdtj�y)Nr3r)r#r r$�recvfromrr'r(r)r*r?r@rAs  ��rrDzHAdoptDatagramPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.stopped	si����#�#�F�L�L�*�2E�2E�q�I�C��!�!�#�� � ����!��e�.B�.B�C�� � ����!��e�l�l�;rz Failed to read on original port.c�,���j�fd��S)Nc�$���j�SrGrHrJs �rrKz[AdoptDatagramPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.<lambda>.<locals>.<lambda>rLrrMrOs��rrKzIAdoptDatagramPortErrorsTestsBuilder.test_stopOnlyCloses.<locals>.<lambda>rQrN)rr r&rdr7r"r5rRrbr!rSrrTrNrUr
r	rVrWs`  @@@rrXz7AdoptDatagramPortErrorsTestsBuilder.test_stopOnlyCloses�s�����#�#�%���]�]�6�>�>�6�3D�3D�E�
����
�(�(�)����(�)����u�%��(�(������!2�!2�4D�4F�
��
��� ��	<�	
�
�
�g��	���S�<�=���J�	
�	���
rNrYrrrr`r`�s!���)�)��7�0
�*&rr`)rr*r �zope.interfacer�twisted.internet.errorr�twisted.internet.interfacesr�twisted.internet.protocolrr�#twisted.internet.test.reactormixinsrr	�twisted.python.logr
�twisted.python.runtimerr
rr[r`�globals�update�makeTestCaseClassesrrr�<module>rts����
�
�!�;�6�E�S�"�+�F�^�F�8c��c�L 
�n� 
�FZ�.�Z�z�	���7�K�K�M�N��	���2�F�F�H�I��	���8�L�L�N�O��	���4�H�H�J�Kr

Zerion Mini Shell 1.0