#NEWLINE# @ mock . patch ( 'cloudbaseinit.plugins.common.userdatautils._get_command' ) #NEWLINE# def test_execute_user_data_script_fails( self , mock_get_command , _ ) : #NEWLINE# #INDENT# mock_get_command . return_value . side_effect = ValueError #NEWLINE# with testutils . LogSnatcher ( 'cloudbaseinit.plugins.common.userdatautils' ) as snatcher : #NEWLINE# #INDENT# retval = userdatautils . execute_user_data_script ( mock . sentinel . user_data ) #NEWLINE# #UNINDENT# expected_logging = [ "An error occurred during user_data execution: ''" , 'User_data script ended with return code: 0' ] #NEWLINE# self . assertEqual ( 0 , mock_get_command ) #NEWLINE# self . assertEqual ( expected_logging , snatcher . output )