def connectServerAndClient(test, clientFactory, serverFactory):
 addr = ('127.0.0.1',)
 clientBroker = clientFactory.buildProtocol(addr)
 serverBroker = serverFactory.buildProtocol(addr)
 clientTransport = StringIO()
 serverTransport = StringIO()
 clientBroker.makeConnection(protocol.FileWrapper(clientTransport))
 serverBroker.makeConnection(protocol.FileWrapper(serverTransport))
 pump = IOPump(clientBroker, serverBroker, clientTransport, serverTransport)
 def maybeDisconnect(broker):
  if (not broker.disconnected):
   broker.connectionLost(failure.Failure(main.CONNECTION_DONE))
 def disconnectClientFactory():
  clientFactory.clientConnectionLost(connector=None, reason=failure.Failure(main.CONNECTION_DONE))
 test.addCleanup(maybeDisconnect, clientBroker)
 test.addCleanup(maybeDisconnect, serverBroker)
 test.addCleanup(disconnectClientFactory)
 pump.pump()
 return (clientBroker, serverBroker, pump)

def connectServerAndClient ( test , clientFactory , serverFactory ) : addr = ( '127.0.0.1' , ) clientBroker = clientFactory . buildProtocol ( addr ) serverBroker = serverFactory . buildProtocol ( addr ) clientTransport = StringIO ( ) serverTransport = StringIO ( ) clientBroker . makeConnection ( protocol . FileWrapper ( clientTransport ) ) serverBroker . makeConnection ( protocol . FileWrapper ( serverTransport ) ) pump = IOPump ( clientBroker , serverBroker , clientTransport , serverTransport ) def maybeDisconnect ( broker ) : if ( not broker . disconnected ) : broker . connectionLost ( failure . Failure ( main . CONNECTION_DONE ) ) def disconnectClientFactory ( ) : clientFactory . clientConnectionLost ( connector = None , reason = failure . Failure ( main . CONNECTION_DONE ) ) test . addCleanup ( maybeDisconnect , clientBroker ) test . addCleanup ( maybeDisconnect , serverBroker ) test . addCleanup ( disconnectClientFactory ) pump . pump ( ) return ( clientBroker , serverBroker , pump )
create a server and a client and connect the two with an l{iopump} .