Current File : //usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/test_socket.cpython-312.pyc |
�
Ϫ�f�$ � �� � d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
mZ ddlm
Z
mZ ddlmZ dd lmZ G d
� de
� Z G d� d
e
� Z G d� de
� Z G d� de
� Z e� j1 ej3 � � e� j1 ej3 � � e� j1 ej3 � � e� j1 ej3 � � 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 � � e Zd ZdZegZd� 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 � }| j t j t |� � 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 � r r r
r
s � �� )�)��Fr r
c �( � e Zd ZdZegZd� 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 � }t j � }|j � }|j � | j t j
|j |t j t � � }t j � r.| j |j d t j � y| j |j d t j � y)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! �excs r �test_invalidDescriptorz8AdoptStreamPortErrorsTestsBuilder.test_invalidDescriptorB s� � � �#�#�%���
�
��������
���
�����L�L��#�#���N�N��O�
�� �������S�X�X�a�[�%�*;�*;�<����S�X�X�a�[�%�+�+�6r c �< � | j � }t j � }|j d� |j d� | 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)r r �bind�listen�
addCleanupr"