From a6ff8d0c2399a11a0127aac14f59f650b1eb9639 Mon Sep 17 00:00:00 2001 From: Megan Wilhite Date: Thu, 20 Jul 2023 13:15:28 -0600 Subject: [PATCH] Move _pkg.txt into salt directory --- pkg/tests/integration/test_salt_grains.py | 2 +- _pkg.txt => salt/_pkg.txt | 0 salt/utils/package.py | 2 +- tests/pytests/functional/modules/conftest.py | 4 +++- tests/pytests/unit/conftest.py | 4 +++- tools/pkg/build.py | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) rename _pkg.txt => salt/_pkg.txt (100%) diff --git a/pkg/tests/integration/test_salt_grains.py b/pkg/tests/integration/test_salt_grains.py index d6f23e40455..6a8e484d6d6 100644 --- a/pkg/tests/integration/test_salt_grains.py +++ b/pkg/tests/integration/test_salt_grains.py @@ -46,5 +46,5 @@ def test_grains_package_onedir(salt_cli, salt_minion): Test that the package grain returns onedir """ ret = salt_cli.run("grains.get", "package", minion_tgt=salt_minion.id) - assert "onedir" == ret.data + assert ret.data == "onedir" assert ret.data, ret diff --git a/_pkg.txt b/salt/_pkg.txt similarity index 100% rename from _pkg.txt rename to salt/_pkg.txt diff --git a/salt/utils/package.py b/salt/utils/package.py index 3bbe8abfbfc..a3c752e8c06 100644 --- a/salt/utils/package.py +++ b/salt/utils/package.py @@ -18,7 +18,7 @@ def pkg_type(): """ Utility to find out how Salt was installed. """ - pkg_file = pathlib.Path(__file__).parent.parent.parent / "_pkg.txt" + pkg_file = pathlib.Path(__file__).parent.parent / "_pkg.txt" if pkg_file.is_file(): with salt.utils.files.fopen(pkg_file) as _fp: content = _fp.read() diff --git a/tests/pytests/functional/modules/conftest.py b/tests/pytests/functional/modules/conftest.py index 5b940163efd..49d3c71da9d 100644 --- a/tests/pytests/functional/modules/conftest.py +++ b/tests/pytests/functional/modules/conftest.py @@ -4,7 +4,7 @@ import pytest @pytest.fixture(scope="package", autouse=True) -def onedir_env(): +def _onedir_env(): """ Functional tests cannot currently test the onedir artifact. This will need to be removed @@ -18,6 +18,8 @@ def onedir_env(): yield finally: os.environ["ONEDIR_TESTRUN"] = "1" + else: + yield @pytest.fixture(scope="module") diff --git a/tests/pytests/unit/conftest.py b/tests/pytests/unit/conftest.py index 24d6e7ea1a5..9c883571c42 100644 --- a/tests/pytests/unit/conftest.py +++ b/tests/pytests/unit/conftest.py @@ -6,7 +6,7 @@ import salt.config @pytest.fixture(scope="package", autouse=True) -def onedir_env(): +def _onedir_env(): """ Unit tests cannot currently test the onedir artifact. This will need to be removed @@ -18,6 +18,8 @@ def onedir_env(): yield finally: os.environ["ONEDIR_TESTRUN"] = "1" + else: + yield @pytest.fixture diff --git a/tools/pkg/build.py b/tools/pkg/build.py index 6aa67eeb126..1400a19a7b3 100644 --- a/tools/pkg/build.py +++ b/tools/pkg/build.py @@ -749,7 +749,7 @@ def salt_onedir( shutil.copyfile(src, dst) # Add package type file for package grain - with open(pathlib.Path(site_packages) / "_pkg.txt", "w") as fp: + with open(pathlib.Path(site_packages) / "salt" / "_pkg.txt", "w") as fp: fp.write("onedir")