def endpointForTesting(fireImmediately=False):
 @implementer(IStreamClientEndpoint)
 class ClientTestEndpoint(object, ):
  def connect(self, factory):
   result = Deferred()
   info.passedFactories.append(factory)
   @result.addCallback
   def createProtocol(ignored):
    protocol = factory.buildProtocol(None)
    info.constructedProtocols.append(protocol)
    transport = StringTransport()
    protocol.makeConnection(transport)
    return protocol
   info.connectQueue.append(result)
   if fireImmediately:
    result.callback(None)
   return result
 info = ConnectInformation()
 return (info, ClientTestEndpoint())

def endpointForTesting ( fireImmediately = False ) : @ implementer ( IStreamClientEndpoint ) class ClientTestEndpoint ( object , ) : def connect ( self , factory ) : result = Deferred ( ) info . passedFactories . append ( factory ) @ result . addCallback def createProtocol ( ignored ) : protocol = factory . buildProtocol ( None ) info . constructedProtocols . append ( protocol ) transport = StringTransport ( ) protocol . makeConnection ( transport ) return protocol info . connectQueue . append ( result ) if fireImmediately : result . callback ( None ) return result info = ConnectInformation ( ) return ( info , ClientTestEndpoint ( ) )
make a sample endpoint for testing .