#NEWLINE# @ mock . patch ( 'sys.stdout' ) #NEWLINE# @ mock . patch ( 'subprocess.Popen' ) #NEWLINE# @ mock . patch ( 'subprocess.PIPE' ) #NEWLINE# def test_execute_process( self , mock_PIPE , mock_Popen , mock_stdout ) : #NEWLINE# #INDENT# args = [ mock . sentinel . fake_arg ] #NEWLINE# mock_p = mock . MagicMock ( ) #NEWLINE# mock_out = mock . MagicMock ( ) #NEWLINE# mock_err = mock . MagicMock ( ) #NEWLINE# mock_Popen . return_value = mock_p #NEWLINE# mock_p . communicate . return_value = ( mock_out , mock_err ) #NEWLINE# response = self . _base . execute_process ( args , shell = True , decode_output = True ) #NEWLINE# mock_Popen . assert_called_once_with ( args , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = True ) #NEWLINE# mock_p . communicate . assert_called_once_with ( ) #NEWLINE# if ( sys . version_info < ( 3 , 0 ) ) : #NEWLINE# #INDENT# mock_out . decode . assert_called_once_with ( mock_stdout . encoding ) #NEWLINE# mock_err . decode . assert_called_once_with ( mock_stdout . encoding ) #NEWLINE# self . assertEqual ( ( mock_out . decode . return_value , mock_err . decode . return_value , mock_p . returncode ) , response ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertEqual ( ( mock_out , mock_err , mock_p . returncode ) , response )