#NEWLINE# def _runTest( self , clientProto , serverProto , clientIsServer = False ) : #NEWLINE# #INDENT# '\n        Helper method to run TLS tests.\n\n        @param clientProto: protocol instance attached to the client\n            connection.\n        @param serverProto: protocol instance attached to the server\n            connection.\n        @param clientIsServer: flag indicated if client should initiate\n            startTLS instead of server.\n\n        @return: a L{defer.Deferred} that will fire when both connections are\n            lost.\n        ' #NEWLINE# self . clientProto = clientProto #NEWLINE# cf = self . clientFactory = protocol . ClientFactory ( ) #NEWLINE# cf . protocol = ( lambda : clientProto ) #NEWLINE# if port : #NEWLINE# #INDENT# cf . server = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cf . client = True #NEWLINE# #UNINDENT# self . serverProto = serverProto #NEWLINE# sf = self . serverFactory = protocol . ServerFactory ( ) #NEWLINE# sf . protocol = ( lambda : serverProto ) #NEWLINE# if clientIsServer : #NEWLINE# #INDENT# sf . client = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sf . server = True #NEWLINE# #UNINDENT# port = reactor . listenTCP ( 0 , sf , interface = '127.0.0.1' ) #NEWLINE# self . addCleanup ( port . stopListening ) #NEWLINE# reactor . connectTCP ( '127.0.0.1' , port . getHost ( ) . port , cf ) #NEWLINE# return defer . gatherResults ( [ clientProto . deferred , serverProto . deferred ] )