module documentation

Tests for implementations of IReactorTCP and the TCP parts of IReactorSocket.

Class AbortConnectionMixin Unit tests for ITransport.abortConnection.
Class AbortConnectionTests TCP-specific AbortConnectionMixin tests.
Class AbortingClient Call abortConnection() after writing some data.
Class AbortingThenLosingClient Call abortConnection() and then loseConnection().
Class AbortingTwiceClient Call abortConnection() twice, after writing some data.
Class AbortServerWritingProtocol Protocol that writes data upon connection.
Class AdoptStreamConnectionTestsBuilder Test server transports built using adoptStreamConnection.
Class AssertPeerClosedOnEMFILETests Tests for assertPeerClosedOnEMFILE.
Class BaseAbortingClient Base class for abort-testing clients.
Class BuffersLogsTests Tests for _BuffersLogs.
Class ConnectToTCPListenerMixin Provides connectToListener for TCP transports.
Class DataReceivedRaisingClient Call abortConnection(), and then throw exception, from dataReceived.
Class EventualNoReadServer Like NoReadServer, except we Wait until some bytes have been delivered before stopping reading. This means TLS handshake has finished, where applicable.
Class ExhaustsFileDescriptorsTests Tests for _ExhaustsFileDescriptors.
Class FakeProtocol An IProtocol that returns a value from its dataReceived method.
Class FakeResolver A resolver implementation based on a dict mapping names to addresses.
Class FakeSocket A fake for socket.socket objects.
Class FakeSocketTests Test that the FakeSocket can be used by the doRead method of Connection
Class FileDescriptorReservationTests Tests for _FileDescriptorReservation.
Class ListenTCPMixin Mixin which uses IReactorTCP.listenTCP to hand out listening TCP ports.
Class NoReadServer Stop reading immediately on connection.
Class NullFileDescriptorReservationTests Tests for _NullFileDescriptorReservation.
Class ProducerAbortingClient Call abortConnection from doWrite, via resumeProducing.
Class ProducerAbortingClientLater Call abortConnection from doWrite, via resumeProducing.
Class ReadAbortServerProtocol Server that should never receive any data, except 'X's which are written by the other side of the connection before abortConnection, and so might possibly arrive.
Class ResumeThrowsClient Call abortConnection() and throw exception from resumeProducing().
Class ServerAbortsThenLoses Call abortConnection() followed by loseConnection().
Class ServerAbortsTwice Call abortConnection() twice.
Class SimpleUtilityTests Simple, direct tests for helpers within twisted.internet.tcp.
Class SocketTCPMixin Mixin which uses IReactorSocket.adoptStreamPort to hand out listening TCP ports.
Class StopStartReadingProtocol Protocol that pauses and resumes the transport a few times
Class StreamingProducerClient Call abortConnection() when the other side has stopped reading.
Class StreamingProducerClientLater Call abortConnection() from dataReceived, after bytes have been exchanged.
Class StreamTransportTestsMixin Mixin defining tests which apply to any port/connection based transport.
Class TCP4ClientTestsBuilder Builder configured with IPv4 parameters for tests related to IReactorTCP.connectTCP.
Class TCP4ConnectorTestsBuilder Undocumented
Class TCP6ClientTestsBuilder Builder configured with IPv6 parameters for tests related to IReactorTCP.connectTCP.
Class TCP6ConnectorTestsBuilder Undocumented
Class TCP6Creator Create IPv6 TCP endpoints for ReactorBuilder.runProtocolsWithReactor-based tests.
Class TCPClientTestsBase Base class for builders defining tests related to IReactorTCP.connectTCP. Classes which uses this in must provide all of the documented instance variables in order to specify how the test works. These are documented as instance variables rather than declared as methods due to some peculiar inheritance ordering concerns, but they are effectively abstract methods.
Class TCPConnectionTests Whitebox tests for twisted.internet.tcp.Connection.
Class TCPConnectionTestsBuilder Builder defining tests relating to twisted.internet.tcp.Connection.
Class TCPConnectorTestsBuilder Tests for the IConnector provider returned by IReactorTCP.connectTCP.
Class TCPCreator Create IPv4 TCP endpoints for runProtocolsWithReactor-based tests.
Class TCPFDPortTestsBuilder Undocumented
Class TCPPortTestsBuilder Undocumented
Class TCPPortTestsMixin Tests for IReactorTCP.listenTCP
Class TCPServerTests Whitebox tests for twisted.internet.tcp.Server.
Class TCPTransportServerAddressTestMixin Test mixing for TCP server address building and log prefix.
Class TCPTransportTestsBuilder Test standard ITCPTransports built with listenTCP and connectTCP.
Class WriteSequenceTestsMixin Test for twisted.internet.abstract.FileDescriptor.writeSequence.
Class WritingButNotAbortingClient Write data, but don't abort.
Function assertNotReading Use the given test to assert that the given transport is not actively reading in the given reactor.
Function assertPeerClosedOnEMFILE Assert that an IListeningPort immediately closes an accepted peer socket when the number of open file descriptors exceeds the soft resource limit.
Function assertReading Use the given test to assert that the given transport is actively reading in the given reactor.
Function connect Connect a socket to the given destination.
Function createTestSocket Create a socket for the duration of the given test.
Function getLinkLocalIPv6Address 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 SkipTest instead.
Function oneTransportTest Decorate a ReactorBuilder test function which tests one reactor and one connected transport. Run that test method in the context of connectionMade, and immediately drop the connection (and end the test) when that completes.
Constant SKIP_EMFILE Undocumented
Variable s Undocumented
Interface _IExhaustsFileDescriptors A way to trigger EMFILE.
Class _ExhaustsFileDescriptors A class that triggers EMFILE by creating as many file descriptors as necessary.
Class _FakeFDSetReactor An in-memory implementation of IReactorFDSet, which records the current sets of active IReadDescriptor and IWriteDescriptors.
def assertNotReading(testCase, reactor, transport): (source)

Use the given test to assert that the given transport is not actively reading in the given reactor.

Parameters
testCase:TestCasea test case to perform the assertion upon.
reactorA reactor, possibly one providing IReactorFDSet, or an IOCP reactor.
transportAn ITCPTransport
Note
Maintainers; for more information on why this is a function rather than a method on a test case, see this document on how we structure test tools
def assertPeerClosedOnEMFILE(testCase, exhauster, reactor, runReactor, listen, connect): (source)

Assert that an IListeningPort immediately closes an accepted peer socket when the number of open file descriptors exceeds the soft resource limit.

Parameters
testCase:trial.unittest.SynchronousTestCaseThe test case under which to run this assertion.
exhauster:_ExhaustsFileDescriptorsThe file descriptor exhauster.
reactorThe reactor under test.
runReactorA callable that will synchronously run the provided reactor.
listen:A callable that accepts two arguments: the provided reactor; and a ServerFactory. It must return an IListeningPort provider.A callback to bind to a port.
connect:A callable that accepts three arguments: the provided reactor; the address returned by IListeningPort.getHost; and a ClientFactory. Its return value is ignored.A callback to connect a client to the listening port.
def assertReading(testCase, reactor, transport): (source)

Use the given test to assert that the given transport is actively reading in the given reactor.

Parameters
testCase:TestCasea test case to perform the assertion upon.
reactorA reactor, possibly one providing IReactorFDSet, or an IOCP reactor.
transportAn ITCPTransport
Note
Maintainers; for more information on why this is a function rather than a method on a test case, see this document on how we structure test tools
def connect(client, destination): (source)

Connect a socket to the given destination.

Parameters
clientA socket.socket.
destinationA tuple of (host, port). The host is a str, the port a int. If the host is an IPv6 IP, the address is resolved using getaddrinfo and the first version found is used.
def createTestSocket(test, addressFamily, socketType): (source)

Create a socket for the duration of the given test.

Parameters
testthe test to add cleanup to.
addressFamilyan AF_* constant
socketTypea SOCK_* constant.
Returns
a socket object.
def getLinkLocalIPv6Address(): (source)

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 SkipTest instead.

Returns
a str giving the address
Raises
SkipTestif no link local address can be found or if the netifaces module is not available.
def oneTransportTest(testMethod): (source)

Decorate a ReactorBuilder test function which tests one reactor and one connected transport. Run that test method in the context of connectionMade, and immediately drop the connection (and end the test) when that completes.

Parameters
testMethod:3-argument functionA unit test method on a ReactorBuilder test suite; taking two additional parameters; a reactor as built by the ReactorBuilder, and an ITCPTransport provider.
Returns
1-argument functiona no-argument test method.
SKIP_EMFILE: bool = (source)

Undocumented

Value
True

Undocumented