#NEWLINE# @ mock . patch . object ( serialconsolehandler , 'SerialConsoleHandler' ) #NEWLINE# @ mock . patch . object ( serialconsoleops . SerialConsoleOps , 'stop_console_handler_unsync' ) #NEWLINE# def _test_start_console_handler( self , mock_stop_handler , mock_console_handler , raise_exception = False ) : #NEWLINE# #INDENT# mock_handler = mock_console_handler . return_value #NEWLINE# if raise_exception : #NEWLINE# #INDENT# mock_handler . start . side_effect = Exception #NEWLINE# #UNINDENT# self . _serialops . start_console_handler ( mock . sentinel . instance_name ) #NEWLINE# mock_stop_handler . assert_called_once_with ( mock . sentinel . instance_name ) #NEWLINE# mock_console_handler . assert_called_once_with ( mock . sentinel . instance_name ) #NEWLINE# if raise_exception : #NEWLINE# #INDENT# mock_handler . stop . assert_called_once_with ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# console_handler = serialconsoleops . _console_handlers . get ( mock . sentinel . instance_name ) #NEWLINE# self . assertEqual ( mock_handler , self )