Various helpers for tests for connection-oriented transports.

Function findFreePort Ask the platform to allocate a free port on the specified interface, then release the socket and return the address which was allocated.
Class ConnectableProtocol A protocol to be used with runProtocolsWithReactor.
Class EndpointCreator Create client and server endpoints that know how to connect to each other.
Function runProtocolsWithReactor Connect two protocols using endpoints and a new reactor instance.
Class Stop A client factory which stops a reactor when a connection attempt fails.
Class ClosingLaterProtocol ClosingLaterProtocol exchanges one byte with its peer and then disconnects itself. This is mostly a work-around for the fact that connectionMade is called before the SSL handshake has completed.
Class ConnectionTestsMixin This mixin defines test methods which should apply to most ITransport implementations.
Class LogObserverMixin Mixin for TestCase subclasses which want to observe log events.
Class BrokenContextFactory A context factory with a broken getContext method, for exercising the error handling for such a case.
Class StreamClientTestsMixin This mixin defines tests applicable to SOCK_STREAM client implementations.
Class _SingleProtocolFactory Factory to be used by runProtocolsWithReactor.
Function _getWriters Like IReactorFDSet.getWriters, but with support for IOCP reactor as well.
Class _AcceptOneClient This factory fires a Deferred with a protocol instance shortly after it is constructed (hopefully long enough afterwards so that it has been connected to a transport).
Class _SimplePullProducer A pull producer which writes one byte whenever it is resumed. For use by test_unregisterProducerAfterDisconnect.
def findFreePort(interface='127.0.0.1', family=socket.AF_INET, type=socket.SOCK_STREAM):

Ask the platform to allocate a free port on the specified interface, then release the socket and return the address which was allocated.

ParametersinterfaceThe local address to try to bind the port on. (type: str)
typeThe socket type which will use the resulting port.
ReturnsA two-tuple of address and port, like that returned by socket.getsockname.
def runProtocolsWithReactor(reactorBuilder, serverProtocol, clientProtocol, endpointCreator):

Connect two protocols using endpoints and a new reactor instance.

A new reactor will be created and run, with the client and server protocol instances connected to each other using the given endpoint creator. The protocols should run through some set of tests, then disconnect; when both have disconnected the reactor will be stopped and the function will return.

ParametersreactorBuilderA ReactorBuilder instance.
serverProtocolA ConnectableProtocol that will be the server.
clientProtocolA ConnectableProtocol that will be the client.
endpointCreatorAn instance of EndpointCreator.
ReturnsThe reactor run by this test.
def _getWriters(reactor):

Like IReactorFDSet.getWriters, but with support for IOCP reactor as well.

API Documentation for twisted, generated by pydoctor at 2020-03-25 17:34:30.