提交 4de5de55 编写于 作者: C Cleber Rosa

Python 3 port: adjust mock import on test_utils_process.py

Mock is slightly lighter than MagicMock, which is only necessary
when mocking "magic" methods.  So, let's revert to the lighter
Mock class.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 876ff434
......@@ -87,9 +87,9 @@ class TestSysVInit(unittest.TestCase):
class TestSpecificServiceManager(unittest.TestCase):
def setUp(self):
self.run_mock = mock.MagicMock()
self.run_mock = mock.Mock()
self.init_name = "init"
get_name_of_init_mock = mock.MagicMock(return_value="init")
get_name_of_init_mock = mock.Mock(return_value="init")
@mock.patch.object(service, "get_name_of_init", get_name_of_init_mock)
def patch_service_command_generator():
......@@ -139,7 +139,7 @@ class TestServiceManager(unittest.TestCase):
class TestSystemdServiceManager(TestServiceManager):
def setUp(self):
self.run_mock = mock.MagicMock()
self.run_mock = mock.Mock()
self.init_name = "systemd"
self.service_manager = super(TestSystemdServiceManager,
self).get_service_manager_from_init_and_run(self.init_name,
......@@ -152,11 +152,11 @@ class TestSystemdServiceManager(TestServiceManager):
self.assertEqual(self.run_mock.call_args[0][0], cmd)
def test_list(self):
list_result_mock = mock.MagicMock(exit_status=0,
list_result_mock = mock.Mock(exit_status=0,
stdout="sshd.service enabled\n"
"vsftpd.service disabled\n"
"systemd-sysctl.service static\n")
run_mock = mock.MagicMock(return_value=list_result_mock)
run_mock = mock.Mock(return_value=list_result_mock)
service_manager = super(TestSystemdServiceManager,
self).get_service_manager_from_init_and_run(self.init_name,
run_mock)
......@@ -169,9 +169,9 @@ class TestSystemdServiceManager(TestServiceManager):
def test_set_default_runlevel(self):
runlevel = service.convert_sysv_runlevel(3)
mktemp_mock = mock.MagicMock(return_value="temp_filename")
symlink_mock = mock.MagicMock()
rename_mock = mock.MagicMock()
mktemp_mock = mock.Mock(return_value="temp_filename")
symlink_mock = mock.Mock()
rename_mock = mock.Mock()
@mock.patch.object(service, "mktemp", mktemp_mock)
@mock.patch("os.symlink", symlink_mock)
......@@ -200,14 +200,14 @@ class TestSystemdServiceManager(TestServiceManager):
class TestSysVInitServiceManager(TestServiceManager):
def setUp(self):
self.run_mock = mock.MagicMock()
self.run_mock = mock.Mock()
self.init_name = "init"
self.service_manager = super(TestSysVInitServiceManager,
self).get_service_manager_from_init_and_run(self.init_name,
self.run_mock)
def test_list(self):
list_result_mock = mock.MagicMock(
list_result_mock = mock.Mock(
exit_status=0,
stdout="sshd 0:off 1:off 2:off 3:off 4:off 5:off 6:off\n"
"vsftpd 0:off 1:off 2:off 3:off 4:off 5:on 6:off\n"
......@@ -215,7 +215,7 @@ class TestSysVInitServiceManager(TestServiceManager):
" amanda: off\n"
" chargen-dgram: on\n")
run_mock = mock.MagicMock(return_value=list_result_mock)
run_mock = mock.Mock(return_value=list_result_mock)
service_manager = super(TestSysVInitServiceManager,
self).get_service_manager_from_init_and_run(self.init_name,
run_mock)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册