Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion autotest/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pathlib import Path
import pytest
import shutil
import platform
# from pst_from_tests import setup_freyberg_mf6

pytest_plugins = ["modflow_devtools.fixtures"]
Expand All @@ -22,7 +24,53 @@
# "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 shutil.which(exe_name) is not None:
return exe_name
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


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"
]:
d[exe_name] = get_exe_path(exe_name)
return d


@pytest.fixture(autouse=True)
def _ch2testdir(monkeypatch):
testdir = Path(__file__).parent
monkeypatch.chdir(testdir)
monkeypatch.chdir(testdir)
6 changes: 3 additions & 3 deletions autotest/emulator_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import pandas as pd
import platform
import pyemu
from pst_from_tests import setup_tmp, bin_path, _get_port
from pst_from_tests import setup_tmp, _get_port, exepath_dict
from pyemu.emulators import DSI, LPFA, GPR

ies_exe_path = os.path.join(bin_path, "pestpp-ies")
mou_exe_path = os.path.join(bin_path, "pestpp-mou")
ies_exe_path = exepath_dict["pestpp-ies"]
mou_exe_path = exepath_dict["pestpp-mou"]

def dsi_freyberg(tmp_d,transforms=None,tag=""):

Expand Down
Loading
Loading