#NEWLINE# @ mock . patch . object ( resource_tracker . LOG , 'warning' ) #NEWLINE# def test_get_host_metrics_exception( self , mock_LOG_warning ) : #NEWLINE# #INDENT# monitor = mock . MagicMock ( ) #NEWLINE# monitor . add_metrics_to_list . side_effect = Exception #NEWLINE# self . tracker . monitors = [ monitor ] #NEWLINE# metrics = self . tracker . _get_host_metrics ( self . context , self . node_name ) #NEWLINE# mock_LOG_warning . assert_called_once_with ( 'Cannot get the metrics from %(mon)s; error: %(exc)s' , mock . ANY ) #NEWLINE# self . assertEqual ( 0 , len ( metrics ) )