File: //usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/test_socket.cpython-310.pyc
o
�b�$ � @ s� d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
mZ ddlm
Z
mZ ddlmZ dd lmZ G d
d� de
�ZG dd
� d
e
�ZG dd� de
�ZG dd� de
�Ze� �e�� � e� �e�� � e� �e�� � e� �e�� � dS )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 @ � e Zd ZdZegZdd� ZdS )�&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 C s | � � }| �t�t|�� dS )zf
The reactor instance returned by C{buildReactor} provides
L{IReactorSocket}.
N)�buildReactor�
assertTruer �verifyObjectr )�self�reactor� r �C/usr/lib/python3/dist-packages/twisted/internet/test/test_socket.py�
test_provider- s z4IReactorSocketVerificationTestsBuilder.test_providerN)�__name__�
__module__�__qualname__�__doc__r �requiredInterfacesr r r r r r s r c @ �. e Zd ZdZegZdd� Zdd� Zdd� ZdS ) �!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 C �r | � � }t�� }|�� }|�� | �tj|j|tjt� �}t �
� r-| �|jd t
j� dS | �|jd t
j� dS )z�
An implementation of L{IReactorSocket.adoptStreamPort} raises
L{socket.error} if passed an integer which is not associated with a
socket.
r N)r
�socket�fileno�close�assertRaises�error�adoptStreamPort�AF_INETr r
� isWindows�assertEqual�args�errno�WSAENOTSOCK�EBADF�r r �prober �excr r r �test_invalidDescriptorB � �z8AdoptStreamPortErrorsTestsBuilder.test_invalidDescriptorc C sR | � � }t�� }|�d� |�d� | �|j� d}| �t|j|� � |t
� � dS )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)r
r �bind�listen�
addCleanupr r r r"