def test_execute_command_args_present_with_success(self, mock_logger_info,
):
with mock.patch('functest.utils.functest_utils.subprocess.Popen') \
as mock_subproc_open, \
mock.patch('six.moves.builtins.open',
mock.mock_open()) as mopen:
FunctestUtilsTesting.readline = 0
mock_obj = mock.Mock()
attrs = {'readline.side_effect': self.cmd_readline()}
mock_obj.configure_mock(**attrs)
mock_obj2 = mock.Mock()
attrs = {'stdout': mock_obj, 'wait.return_value': 0}
mock_obj2.configure_mock(**attrs)
mock_subproc_open.return_value = mock_obj2
resp = functest_utils.execute_command(self.cmd, info=True,
error_msg=self.error_msg,
verbose=True,
output_file=self.output_file)
self.assertEqual(resp, 0)
msg_exec = ("Executing command: '%s'" % self.cmd)
mock_logger_info.assert_called_once_with(msg_exec)
mopen.assert_called_once_with(self.output_file, "w")
评论列表
文章目录