diff --git a/test/common/test_config_helper.py b/test/common/test_config_helper.py index d5e7a4ff..afc487a3 100644 --- a/test/common/test_config_helper.py +++ b/test/common/test_config_helper.py @@ -21,10 +21,10 @@ class TestConfigHelper(unittest.TestCase): - @mock.patch('common.config_helper.YamlUtils.write_yaml_data') - @mock.patch('common.config_helper.DirectoryUtil.mkdir') - @mock.patch('common.config_helper.os.path.expanduser') - @mock.patch('common.config_helper.TimeUtils.timestamp_to_filename_time') + @mock.patch('src.common.config_helper.YamlUtils.write_yaml_data') + @mock.patch('src.common.config_helper.DirectoryUtil.mkdir') + @mock.patch('src.common.config_helper.os.path.expanduser') + @mock.patch('src.common.config_helper.TimeUtils.timestamp_to_filename_time') def test_save_old_configuration(self, mock_timestamp_to_filename_time, mock_expanduser, mock_mkdir, mock_write_yaml_data): # 模拟时间戳生成函数,返回一个特定的值 mock_timestamp_to_filename_time.return_value = '20240806_123456' @@ -93,7 +93,7 @@ def test_input_with_default(self, mock_input): self.assertEqual(result, 'custom_user') # 测试带有默认值的密码输入方法 - @mock.patch('common.config_helper.pwinput.pwinput') + @mock.patch('src.common.config_helper.pwinput.pwinput') def test_input_password_with_default(self, mock_pwinput): # 创建一个模拟的上下文对象 context = mock.MagicMock() @@ -120,7 +120,7 @@ def test_input_password_with_default(self, mock_pwinput): self.assertEqual(result, "custom_password") # 测试带有默认选项的选择输入方法 - @mock.patch('common.config_helper.input') + @mock.patch('src.common.config_helper.input') def test_input_choice_default(self, mock_input): # 创建一个模拟的上下文对象 context = mock.MagicMock() diff --git a/test/common/test_scene.py b/test/common/test_scene.py index ec8def50..01b1bc30 100644 --- a/test/common/test_scene.py +++ b/test/common/test_scene.py @@ -100,21 +100,21 @@ def test_wildcard_max_version(self): result = filter_by_version(scene, cluster, self.stdio) self.assertEqual(result, 0) - @patch('common.scene.get_observer_version') + @patch('src.common.scene.get_observer_version') def test_get_observer_version(self, mock_get_observer_version): mock_get_observer_version.return_value = "1.0.0" result = get_version_by_type(self.context, "observer") self.assertEqual(result, "1.0.0") mock_get_observer_version.assert_called_once_with(self.context) - @patch('common.scene.get_observer_version') + @patch('src.common.scene.get_observer_version') def test_get_other_version(self, mock_get_observer_version): mock_get_observer_version.return_value = "2.0.0" result = get_version_by_type(self.context, "other") self.assertEqual(result, "2.0.0") mock_get_observer_version.assert_called_once_with(self.context) - @patch('common.scene.get_observer_version') + @patch('src.common.scene.get_observer_version') def test_get_observer_version_fail(self, mock_get_observer_version): mock_get_observer_version.side_effect = Exception("Observer error") with self.assertRaises(Exception) as context: @@ -122,7 +122,7 @@ def test_get_observer_version_fail(self, mock_get_observer_version): self.assertIn("can't get observer version", str(context.exception)) self.context.stdio.warn.assert_called_once() - @patch('common.scene.get_obproxy_version') + @patch('src.common.scene.get_obproxy_version') def test_get_obproxy_version(self, mock_get_obproxy_version): mock_get_obproxy_version.return_value = "3.0.0" result = get_version_by_type(self.context, "obproxy") @@ -134,7 +134,7 @@ def test_unsupported_type(self): get_version_by_type(self.context, "unsupported") self.assertIn("No support to get the version", str(context.exception)) - @patch('common.scene.get_observer_version') + @patch('src.common.scene.get_observer_version') def test_general_exception_handling(self, mock_get_observer_version): mock_get_observer_version.side_effect = Exception("Unexpected error") with self.assertRaises(Exception) as context: