#NEWLINE# def buildReactor( self ) : #NEWLINE# #INDENT# '\n        Create and return a reactor using C{self.reactorFactory}.\n        ' #NEWLINE# try : #NEWLINE# #INDENT# from twisted.internet.cfreactor import CFReactor #NEWLINE# from twisted.internet import reactor as globalReactor #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( isinstance ( globalReactor , CFReactor ) and ( self . reactorFactory is CFReactor ) ) : #NEWLINE# #INDENT# raise SkipTest ( "CFReactor uses APIs which manipulate global state, so it's not safe to run its own reactor-builder tests under itself" ) #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# reactor = self . reactorFactory ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# log . err ( None , 'Failed to install reactor' ) #NEWLINE# self . flushLoggedErrors ( ) #NEWLINE# raise SkipTest ( Failure ( ) . getErrorMessage ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( x . requiredInterfaces is not None ) : #NEWLINE# #INDENT# missing = filter ( ( lambda required : ( not required . providedBy ( reactor ) ) ) , self . requiredInterfaces ) #NEWLINE# if missing : #NEWLINE# #INDENT# self . unbuildReactor ( reactor ) #NEWLINE# raise SkipTest ( ( '%r does not provide %s' % ( reactor , ',' . join ( [ repr ( x ) for x in missing ] ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . addCleanup ( self . unbuildReactor , reactor ) #NEWLINE# return reactor