#NEWLINE# def test_send_error( _socket , conn ) : #NEWLINE# #INDENT# conn . connect ( ) #NEWLINE# assert ( conn . state is ConnectionStates . CONNECTED ) #NEWLINE# req = MetadataRequest [ 0 ] ( [ ] ) #NEWLINE# try : #NEWLINE# #INDENT# _socket . send . side_effect = ConnectionError #NEWLINE# #UNINDENT# except NameError : #NEWLINE# #INDENT# _socket . send . side_effect = socket . error #NEWLINE# #UNINDENT# f = conn . send ( req ) #NEWLINE# assert ( f . failed ( ) is True ) #NEWLINE# assert isinstance ( f . exception , Errors . ConnectionError ) #NEWLINE# assert ( req . close . call_count == 1 ) #NEWLINE# assert ( conn . state is ConnectionStates . DISCONNECTED )