%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/internet/test/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/internet/test/__pycache__/test_tcp.cpython-312.pyc |
� Ϫ�fͦ � � � d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z m Z mZmZm Z mZmZ ddlmZ ddlmZmZ ddlmZmZ ddlZddlmZmZ dd lmZmZmZm Z m!Z!m"Z" dd l#m$Z$m%Z% ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z; dd l<m=Z=m>Z>m?Z? ddl@mAZAmBZBmCZCmDZDmEZEmFZFmGZG ddlHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQ ddlRmSZSmTZTmUZU ddlVmWZWmXZX ddlYmZZZ ddl[m\Z\ ddl]m^Z^ ddl_m`Z` ddlambZbmcZcmdZdmeZe ddlfmgZgmhZhmiZi ddljmkZk ddllmmZm dZndZp ej ej� ej� � Zpepj� d� dZtdZuep�epj� � e`j� � rddlzm{Z{ e{j� Z}dZ~n dd lzmZ e�j Z}dZ~d"� Z�d#� Z� G d$� d%� Z� G d&� d'ei� Z� G d(� d)e>� Z� ee6� G d*� d+� � Z� ee6e�� G d,� d-ei� Z� G d.� d/ei� Z� G d0� d1eL� Z� G d2� d3e�� Z� ee:� G d4� d5� � Z� G d6� d7eSeKeO� Z� G d8� d9e�� Z� eeteu� G d:� d;e�� � Z� G d<� d=eS� Z� G d>� d?e�� Z� eeteu� G d@� dAe�� � Z�dB� Z� G dC� dDe� Z� ee�� ej� d�E� G dF� dG� � � Z� ee~dH� G dI� dJeh� � Z�dK� Z� ee~dH� G dL� dMeh� � Z� G dN� dOeM� Z� G dP� dQ� Z� G dR� dSe�� Z� G dT� dUe�� Z� G dV� dW� Z� G dX� dYeSe�e�e�� Z� G dZ� d[eSe�e�e�� Z� G d\� d]e>� Z�d^� Z�d_� Z�d`� Z� G da� dbeS� Z� G dc� dd� Z� G de� df� Z� G dg� dhe�e�eS� Z� G di� dje�e�eS� Z� e�� �jS e��jU � � e�� �jS e��jU � � e�� �jS e��jU � � e�� �jS e��jU � � e�� �jS e��jU � � e�� �jS e��jU � � e�� �jS e��jU � � e�� �jS e��jU � � e�� �jS e��jU � � G dk� dleJ� Z� G dm� dneJ� Z� G do� dpeJ� Z� G dq� dre�� Z� G ds� dteJ� Z� G du� dveJ� Z� G dw� dxeJ� Z� G dy� dze�� Z� G d{� d|e�� Z� G d}� d~e�� Z� G d� d�e�� Z� G d�� d�eJ� Z� G d�� d�eJ� Z� G d�� d�e�� Z� G d�� d�e�� Z� G d�� d�e�� Z� G d�� d�e�� Z� G d�� d�� Z� G d�� d�eSe�� Z� e�� �jS e��jU � � eeteu� G d�� d�ei� � Z� G d�� d�eh� Z� ee~dH� G d�� d�eh� � Z� G d�� d�eh� Z�y# eo$ r dZnY ��w xY w# ev$ rZwdZtdew� �ZuY dZw[w���dZw[www xY w# eo$ r d!� Z}Y ���w xY w)�zU Tests for implementations of L{IReactorTCP} and the TCP parts of L{IReactorSocket}. � N��wraps)�Callable�ClassVar�List�Mapping�Optional�Sequence�Type)�skipIf)� Interface�implementer)�verifyClass�verifyObject)�IPv4Address�IPv6Address)�Deferred�DeferredList�fail� gatherResults� maybeDeferred�succeed)�TCP4ClientEndpoint�TCP4ServerEndpoint) �ConnectBindError�ConnectionAborted�ConnectionClosed�ConnectionDone�ConnectionLost�ConnectionRefusedError�DNSLookupError� NoProtocol� UserError)� IConnector�IHalfCloseableProtocol�ILoggingContext� IPullProducer� IPushProducer� IReactorFDSet�IReactorSocket�IReactorTCP�IReactorTime�IResolverSimple� ITLSTransport)� ClientFactory�Protocol� ServerFactory)� Connection�Server�_BuffersLogs�_FileDescriptorReservation�_IFileDescriptorReservation�_NullFileDescriptorReservation�_resolveIPv6) �BrokenContextFactory�ConnectableProtocol�ConnectionTestsMixin�EndpointCreator�LogObserverMixin�Stop�StreamClientTestsMixin�findFreePort�runProtocolsWithReactor)�ReactorBuilder�needsRunningReactor�stopOnError)� MemoryReactor�StringTransport)�Logger)�log)�Failure)�platform)�ClientStartStopFactory�ClosingFactory�MyClientFactory�MyServerFactory)�SkipTest�SynchronousTestCase�TestCase)�SSL)�ClientContextFactoryTF)�::1r � zIPv6 not available. )�_win32ifaces)�_posixifacesc � � g S �N� rZ � �@/usr/lib/python3/dist-packages/twisted/internet/test/test_tcp.py�<lambda>r] � s � �B� r[ c �: � t � } | r| d S t d� �)al Find and return a configured link local IPv6 address including a scope identifier using the % separation syntax. If the system has no link local IPv6 addresses, raise L{SkipTest} instead. @raise SkipTest: if no link local address can be found or if the C{netifaces} module is not available. @return: a C{str} giving the address r z#Link local IPv6 address unavailable)�getLinkLocalIPv6AddressesrO )� addressess r\ �getLinkLocalIPv6Addressra � s% � � *�+�I����|�� �8� 9�9r[ c � � |\ }}d|v sd|v rt j ||� d d }n||f}| j |� y)a7 Connect a socket to the given destination. @param client: A C{socket.socket}. @param destination: A tuple of (host, port). The host is a C{str}, the port a C{int}. If the C{host} is an IPv6 IP, the address is resolved using C{getaddrinfo} and the first version found is used. �%�:r � N)�socket�getaddrinfo�connect)�client�destination�host�port�addresss r\ rh rh � sK � � �L�T�4� �d�{�c�T�k��$�$�T�4�0��3�A�6����,�� �N�N�7�r[ c �@ � e Zd ZdZd� Zd� Zd� Zd� Zd� Zd� Z d� Z d � Zy )� FakeSocketz� A fake for L{socket.socket} objects. @ivar data: A C{str} giving the data which will be returned from L{FakeSocket.recv}. @ivar sendBuffer: A C{list} of the objects passed to L{FakeSocket.send}. c � � || _ g | _ y rY )�data� sendBuffer��selfrq s r\ �__init__zFakeSocket.__init__� s � ��� ���r[ c � � || _ y rY )�blocking)rt rw s r\ �setblockingzFakeSocket.setblocking� s � � �� r[ c � � | j S rY )rq )rt �sizes r\ �recvzFakeSocket.recv� s � ��y�y�r[ c �N � | j j |� t |� S )z� I{Send} all of C{bytes} by accumulating it into C{self.sendBuffer}. @return: The length of C{bytes}, indicating all the data has been accepted. )rr �append�len�rt �bytess r\ �sendzFakeSocket.send� s � � �����u�%��5�z�r[ c � � y)z� Shutdown is not implemented. The method is provided since real sockets have it and some code expects it. No behavior of L{FakeSocket} is affected by a call to it. NrZ )rt �hows r\ �shutdownzFakeSocket.shutdown� � � r[ c � � y)z� Close is not implemented. The method is provided since real sockets have it and some code expects it. No behavior of L{FakeSocket} is affected by a call to it. NrZ �rt s r\ �closezFakeSocket.close� r� r[ c � � y)z� Setsockopt is not implemented. The method is provided since real sockets have it and some code expects it. No behavior of L{FakeSocket} is affected by a call to it. NrZ )rt �argss r\ � setsockoptzFakeSocket.setsockopt� r� r[ c � � y)z� Return a fake file descriptor. If actually used, this will have no connection to this L{FakeSocket} and will probably cause surprising results. � rZ r� s r\ �filenozFakeSocket.fileno� s � � r[ N)�__name__� __module__�__qualname__�__doc__ru rx r{ r� r� r� r� r� rZ r[ r\ ro ro � s/ � ���!������r[ ro c �"