2022-12-22 08:31:23 +00:00
|
|
|
import os
|
|
|
|
import pathlib
|
|
|
|
import sys
|
|
|
|
|
2023-07-28 11:32:38 +01:00
|
|
|
_repo_root = pathlib.Path(__file__).resolve().parent.parent
|
2022-12-22 08:31:23 +00:00
|
|
|
|
2023-01-23 11:47:03 +00:00
|
|
|
if os.environ.get("ONEDIR_TESTRUN", "0") == "1":
|
2022-12-22 08:31:23 +00:00
|
|
|
# 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
|
2023-07-28 11:32:38 +01:00
|
|
|
for path in list(sys.path):
|
|
|
|
if path == "":
|
|
|
|
sys.path.remove(path)
|
|
|
|
elif pathlib.Path(path).resolve() == _repo_root:
|
2023-02-20 17:48:01 +00:00
|
|
|
sys.path.remove(path)
|