From 2de8317e7035b7e3d828d20e58255f3c1b9adf8a Mon Sep 17 00:00:00 2001 From: Megan Wilhite Date: Tue, 20 Jun 2023 08:40:21 -0600 Subject: [PATCH] Run onedir pytest fixture only on module tests --- tests/pytests/functional/conftest.py | 16 ---------------- tests/pytests/functional/modules/conftest.py | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/pytests/functional/conftest.py b/tests/pytests/functional/conftest.py index b2e6607dd19..2fb2246b633 100644 --- a/tests/pytests/functional/conftest.py +++ b/tests/pytests/functional/conftest.py @@ -1,5 +1,4 @@ import logging -import os import shutil import pytest @@ -8,21 +7,6 @@ from saltfactories.utils.functional import Loaders log = logging.getLogger(__name__) -@pytest.fixture(scope="package", autouse=True) -def onedir_env(): - """ - Functional tests cannot currently test the - onedir artifact. This will need to be removed - when we do add onedir support for functional tests. - """ - if os.environ.get("ONEDIR_TESTRUN", "0") == "1": - try: - os.environ["ONEDIR_TESTRUN"] = "0" - yield - finally: - os.environ["ONEDIR_TESTRUN"] = "1" - - @pytest.fixture(scope="package") def minion_id(): return "func-tests-minion-opts" diff --git a/tests/pytests/functional/modules/conftest.py b/tests/pytests/functional/modules/conftest.py index 19cd807cae9..5b940163efd 100644 --- a/tests/pytests/functional/modules/conftest.py +++ b/tests/pytests/functional/modules/conftest.py @@ -1,6 +1,25 @@ +import os + import pytest +@pytest.fixture(scope="package", autouse=True) +def onedir_env(): + """ + Functional tests cannot currently test the + onedir artifact. This will need to be removed + when we do add onedir support for functional tests. + This is specifically needed for testing the new + package grain when calling from the grains module. + """ + if os.environ.get("ONEDIR_TESTRUN", "0") == "1": + try: + os.environ["ONEDIR_TESTRUN"] = "0" + yield + finally: + os.environ["ONEDIR_TESTRUN"] = "1" + + @pytest.fixture(scope="module") def modules(loaders): return loaders.modules