#NEWLINE# def test_connection_wait_for_connection( self ) : #NEWLINE# #INDENT# connection = Connection ( '127.0.0.1' , 'guest' , 'guest' , timeout = 5 , lazy = True ) #NEWLINE# connection . set_state ( connection . OPENING ) #NEWLINE# io = IO ( connection . parameters , [ ] ) #NEWLINE# io . socket = MagicMock ( name = 'socket' , spec = socket . socket ) #NEWLINE# connection . _io = io #NEWLINE# self . assertFalse ( connection . is_open ) #NEWLINE# def func( conn ) : #NEWLINE# #INDENT# conn . set_state ( conn . OPEN ) #NEWLINE# #UNINDENT# threading . Timer ( function = func , interval = 1 , args = ( connection , ) ) . start ( ) #NEWLINE# connection . _wait_for_connection_to_open ( ) #NEWLINE# self . assertTrue ( self . is_open )