From e8d775e7f23c68d41065361ede833d0e7a3fa08e Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Wed, 18 Aug 2021 05:37:08 +0000 Subject: [PATCH 1/2] Simple refactor test code --- src/sonic-host-services/tests/hostcfgd/hostcfgd_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic-host-services/tests/hostcfgd/hostcfgd_test.py b/src/sonic-host-services/tests/hostcfgd/hostcfgd_test.py index 9bd82a76afc7..6abc4a5465c2 100644 --- a/src/sonic-host-services/tests/hostcfgd/hostcfgd_test.py +++ b/src/sonic-host-services/tests/hostcfgd/hostcfgd_test.py @@ -1,6 +1,6 @@ import os import sys -import swsscommon +from swsscommon import swsscommon from parameterized import parameterized from sonic_py_common.general import load_module_from_source @@ -12,7 +12,7 @@ from pyfakefs.fake_filesystem_unittest import patchfs -swsscommon.swsscommon.ConfigDBConnector = MockConfigDb +swsscommon.ConfigDBConnector = MockConfigDb test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) modules_path = os.path.dirname(test_path) scripts_path = os.path.join(modules_path, "scripts") From 7f0194f451ce3ac650dce1ffdbcaa34f8e017506 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Thu, 26 Aug 2021 03:27:12 +0000 Subject: [PATCH 2/2] Fix name conflicting --- src/sonic-host-services/tests/hostcfgd/hostcfgd_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sonic-host-services/tests/hostcfgd/hostcfgd_test.py b/src/sonic-host-services/tests/hostcfgd/hostcfgd_test.py index 6abc4a5465c2..15dd66f29e7e 100644 --- a/src/sonic-host-services/tests/hostcfgd/hostcfgd_test.py +++ b/src/sonic-host-services/tests/hostcfgd/hostcfgd_test.py @@ -1,5 +1,6 @@ import os import sys +import swsscommon as swsscommon_package from swsscommon import swsscommon from parameterized import parameterized @@ -93,7 +94,7 @@ def test_hostcfgd(self, test_name, test_data, fs): Returns: None """ - fs.add_real_paths(swsscommon.__path__) # add real path of swsscommon for database_config.json + fs.add_real_paths(swsscommon_package.__path__) # add real path of swsscommon for database_config.json fs.create_dir(hostcfgd.FeatureHandler.SYSTEMD_SYSTEM_DIR) MockConfigDb.set_config_db(test_data["config_db"]) with mock.patch("hostcfgd.subprocess") as mocked_subprocess: