@@ -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