diff options
author | Brett Holman <bholman.devel@gmail.com> | 2021-12-08 14:27:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-08 15:27:37 -0600 |
commit | 65c2cfd7f21758746444c8c79444994a4638d563 (patch) | |
tree | 3b4c91b0ba35dbd8f043f779a9ea6b41f4665a16 /tests/unittests/test_render_cloudcfg.py | |
parent | b21afb0a8ab64543715dffff490253db8ecefb9f (diff) | |
download | vyos-cloud-init-65c2cfd7f21758746444c8c79444994a4638d563.tar.gz vyos-cloud-init-65c2cfd7f21758746444c8c79444994a4638d563.zip |
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.
Diffstat (limited to 'tests/unittests/test_render_cloudcfg.py')
-rw-r--r-- | tests/unittests/test_render_cloudcfg.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/unittests/test_render_cloudcfg.py b/tests/unittests/test_render_cloudcfg.py index 00d50e66..b2222747 100644 --- a/tests/unittests/test_render_cloudcfg.py +++ b/tests/unittests/test_render_cloudcfg.py @@ -1,12 +1,12 @@ """Tests for tools/render-cloudcfg""" -import os import sys import pytest from cloudinit import subp from cloudinit import util +from tests.unittests.helpers import cloud_init_project_dir # TODO(Look to align with tools.render-cloudcfg or cloudinit.distos.OSFAMILIES) DISTRO_VARIANTS = ["amazon", "arch", "centos", "debian", "eurolinux", "fedora", @@ -17,8 +17,8 @@ DISTRO_VARIANTS = ["amazon", "arch", "centos", "debian", "eurolinux", "fedora", @pytest.mark.allow_subp_for(sys.executable) class TestRenderCloudCfg: - cmd = [sys.executable, os.path.realpath('tools/render-cloudcfg')] - tmpl_path = os.path.realpath('config/cloud.cfg.tmpl') + cmd = [sys.executable, cloud_init_project_dir('tools/render-cloudcfg')] + tmpl_path = cloud_init_project_dir('config/cloud.cfg.tmpl') @pytest.mark.parametrize('variant', (DISTRO_VARIANTS)) def test_variant_sets_distro_in_cloud_cfg(self, variant, tmpdir): |