forked from pypest/pyemu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
81 lines (72 loc) · 2.28 KB
/
conftest.py
File metadata and controls
81 lines (72 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from pathlib import Path
import pytest
import shutil
import platform
# from pst_from_tests import setup_freyberg_mf6
pytest_plugins = ["modflow_devtools.fixtures"]
collect_ignore = [
# "emulator_tests.py",
# "en_tests.py",
# "full_meal_deal_tests_2.py",
# "get_pestpp_tests.py",
# "la_tests.py",
# "mat_tests.py",
# "mc_tests_ignore.py",
# "metrics_tests.py",
# "plot_tests.py",
# "pst_from_tests.py",
# "pst_tests.py",
# "pst_tests_2.py",
# "transformer_tests.py",
# "utils_tests.py"
# "verf_test.py",
]
def get_project_root_path():
"""
Get the root path of the project.
"""
return Path(__file__).parent.parent
def get_exe_path(exe_name, forgive=True):
"""
Get the absolute path to an executable in the project.
"""
if platform.system() == "Windows":
exe_name = f"{exe_name}.exe"
if shutil.which(exe_name) is not None:
print(f"Found {exe_name} in system PATH")
return exe_name
# else look in local project bin/<platform>
root_path = get_project_root_path()
exe_path = root_path / "bin"
if not (exe_path / exe_name).exists():
if "linux" in platform.system().lower():
exe_path = Path(exe_path, "linux")
elif "darwin" in platform.system().lower():
exe_path = Path(exe_path, "mac")
else:
exe_path = Path(exe_path, "win")
if not (exe_path / exe_name).exists():
if forgive:
print(f"Executable {exe_name} not found in {exe_path}, returning None")
else:
raise FileNotFoundError(f"Executable {exe_name} not found in system PATH or fallback path:"
f" {exe_path}")
return None
return (exe_path / exe_name).as_posix()
def full_exe_ref_dict():
"""
Get a dictionary of executable references for the project.
"""
d = {}
for exe_name in [
"mfnwt", "mt3dusgs", "mfusg_gsi", "mf6",
"pestpp-ies", "pestpp-sen", "pestpp-opt", "pestpp-glm",
"pestpp-mou", "pestpp-da", "pestpp-sqp", "pestpp-swp"
]:
exe_path = get_exe_path(exe_name)
d[exe_name] = exe_path
return d
@pytest.fixture(autouse=True)
def _ch2testdir(monkeypatch):
testdir = Path(__file__).parent
monkeypatch.chdir(testdir)