From 65c2cfd7f21758746444c8c79444994a4638d563 Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Wed, 8 Dec 2021 14:27:37 -0700 Subject: factor out function for getting top level directory of cloudinit (#1136) Add a test helper to get top level directory Many tests need to get the location of files & dirs within the cloud-init project directory. Tests implement this in various different ways, and often those ways depend on the current working directory of the pytest invocation. Create helper functions (and tests) that gets the path of the top directory or any sub directory under the top directory. This function does not depend on the environment. --- tests/unittests/test_ds_identify.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/unittests/test_ds_identify.py') diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py index 62c3e403..eb8992d9 100644 --- a/tests/unittests/test_ds_identify.py +++ b/tests/unittests/test_ds_identify.py @@ -9,8 +9,12 @@ from cloudinit import safeyaml from cloudinit import subp from cloudinit import util from tests.unittests.helpers import ( - CiTestCase, dir2dict, populate_dir, populate_dir_with_ts) - + CiTestCase, + dir2dict, + populate_dir, + populate_dir_with_ts, + cloud_init_project_dir, +) from cloudinit.sources import DataSourceIBMCloud as ds_ibm from cloudinit.sources import DataSourceSmartOS as ds_smartos from cloudinit.sources import DataSourceOracle as ds_oracle @@ -92,7 +96,7 @@ CallReturn = namedtuple('CallReturn', class DsIdentifyBase(CiTestCase): - dsid_path = os.path.realpath('tools/ds-identify') + dsid_path = cloud_init_project_dir('tools/ds-identify') allowed_subp = ['sh'] def call(self, rootd=None, mocks=None, func="main", args=None, files=None, -- cgit v1.2.3