salt/tests/__init__.py
Pedro Algarvio c4fa5a641f Only set ONEDIR_TESTRUN if onedir is True
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2023-01-25 10:05:16 -07:00

14 lines
458 B
Python

import os
import pathlib
import sys
_repo_root = pathlib.Path(__file__).parent.parent
if os.environ.get("ONEDIR_TESTRUN", "0") == "1":
# In this particular case, we want to make sure that the repo root
# is not part if sys.path so that when we import salt, we import salt from
# the onedir and not the code checkout
if "" in sys.path:
sys.path.remove("")
if str(_repo_root) in sys.path:
sys.path.remove(str(_repo_root))