diff --git a/selftests/unit/test_utils_service.py b/selftests/unit/test_utils_service.py index e4b7423ec36f9d98c9c2a4d4d2b106a593864e07..c252b10f74900180dfffc24cdeb8c03bab0db633 100644 --- a/selftests/unit/test_utils_service.py +++ b/selftests/unit/test_utils_service.py @@ -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, - stdout="sshd.service enabled\n" - "vsftpd.service disabled\n" - "systemd-sysctl.service static\n") - run_mock = mock.MagicMock(return_value=list_result_mock) + 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.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)