#NEWLINE# def test_allocate( self ) : #NEWLINE# #INDENT# port = util . allocate_port ( ) #NEWLINE# p2 = tcp . Port ( d , protocol . Factory ( ) ) #NEWLINE# p2 . startListening ( ) #NEWLINE# port2 = p2 . getHost ( ) . port #NEWLINE# d = p2 . stopListening ( ) #NEWLINE# def _stopped( res ) : #NEWLINE# #INDENT# self . failUnlessEqual ( port , port2 ) #NEWLINE# return res #NEWLINE# #UNINDENT# d . addBoth ( _stopped ) #NEWLINE# return d