def start_tls_server(test, port, context_factory):
 server_endpoint = SSL4ServerEndpoint(reactor, port, context_factory, interface='127.0.0.1')
 server_factory = WaitForDisconnectsFactory.forProtocol(SendingProtocol)
 test.addCleanup((lambda : server_factory.wait_for_disconnects()))
 d = server_endpoint.listen(server_factory)
 d.addCallback((lambda port: test.addCleanup(port.stopListening)))
 return d

def start_tls_server ( test , port , context_factory ) : server_endpoint = SSL4ServerEndpoint ( reactor , port , context_factory , interface = '127.0.0.1' ) server_factory = WaitForDisconnectsFactory . forProtocol ( SendingProtocol ) test . addCleanup ( ( lambda : server_factory . wait_for_disconnects ( ) ) ) d = server_endpoint . listen ( server_factory ) d . addCallback ( ( lambda port : test . addCleanup ( port . stopListening ) ) ) return d
start a tls server on the given port .