Skip to content

Commit a8d0eb3

Browse files
mjrenomjreno
authored andcommitted
test examples simple compare
1 parent 123774c commit a8d0eb3

File tree

6 files changed

+26
-59
lines changed

6 files changed

+26
-59
lines changed

pixi.lock

Lines changed: 1 addition & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ dependencies = [
4848
"xarray[parallel,io]>=2025.10.1,<2026",
4949
"scipy>=1.16.2,<2",
5050
"sparse>=0.17.0,<0.18",
51-
"syrupy<5",
5251
"dask[array]>=2025.10.0,<2026",
5352
"pyproj>=3.7.2,<4",
5453
"netcdf4>=1.7.3,<2",

test/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from modflow_devtools.download import download_and_unzip
77
from modflow_devtools.misc import is_in_ci
88

9-
pytest_plugins = ["modflow_devtools.fixtures", "modflow_devtools.snapshots"]
9+
pytest_plugins = ["modflow_devtools.fixtures"]
1010

1111
PROJ_ROOT_PATH = Path(__file__).parents[1]
1212
DOCS_PATH = PROJ_ROOT_PATH / "docs"

test/test_examples.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,38 @@ def pytest_generate_tests(metafunc):
1919
metafunc.parametrize("example_script", scripts.values(), ids=scripts.keys())
2020

2121

22-
def check(example_script, snapshot):
23-
from pathlib import Path
24-
22+
def check_heads(compare_fpth, check_path):
2523
import numpy as np
2624
from flopy.utils import HeadFile
2725

28-
check_path = Path(f"{example_script.parent}/{example_script.stem}")
26+
if not compare_fpth.exists():
27+
return
28+
29+
hds_compare = np.load(compare_fpth)
30+
31+
# check *.hds files
2932
for f in check_path.rglob("*.hds"):
3033
hds = HeadFile(f, precision="double")
31-
# assert hds.get_data() == pytest.approx(snapshot)
32-
# assert snapshot == hds.get_data()
33-
test_dir = Path(f"{example_script.parent}/../../test")
34-
arr = np.load(test_dir / "__snapshots__" / "test_examples" / f"{example_script.stem}.npy")
35-
assert np.allclose(arr, hds.get_data())
34+
assert np.allclose(hds_compare, hds.get_data())
35+
36+
37+
def check(example_script):
38+
from pathlib import Path
39+
40+
test_name = "test_examples"
41+
check_path = Path(f"{example_script.parent}/{example_script.stem}")
42+
test_dir = Path(f"{example_script.parent}/../../test")
43+
44+
# checks; assume test output path parent has example name
45+
check_heads(
46+
test_dir / f"__compare__/{test_name}/{example_script.stem}.hds.npy",
47+
check_path,
48+
)
3649

3750

38-
@pytest.mark.snapshot
3951
@pytest.mark.slow
40-
def test_scripts(example_script, array_snapshot):
52+
def test_scripts(example_script):
4153
args = [sys.executable, example_script]
4254
stdout, stderr, retcode = run_cmd(*args, verbose=True)
4355
assert not retcode, stdout + stderr
44-
check(example_script, array_snapshot)
56+
check(example_script)

0 commit comments

Comments
 (0)