Skip to content

Commit

Permalink
refactor(modflowapi): move ModflowApi import into api_func (#1997)
Browse files Browse the repository at this point in the history
* refactor(modflowapi): move ModflowApi import into api_func

* add requires_pkg("modflowapi")
  • Loading branch information
langevin-usgs authored Aug 20, 2024
1 parent 644cf96 commit a832fdf
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 11 deletions.
5 changes: 4 additions & 1 deletion autotest/test_gwf_libmf6_evt01.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
import pytest
from framework import TestFramework
from modflowapi import ModflowApi
from modflow_devtools.markers import requires_pkg

cases = ["libgwf_evt01"]

Expand Down Expand Up @@ -150,6 +150,8 @@ def head2et_wellrate(h):


def api_func(exe, idx, model_ws=None):
from modflowapi import ModflowApi

name = cases[idx].upper()
if model_ws is None:
model_ws = "."
Expand Down Expand Up @@ -249,6 +251,7 @@ def api_func(exe, idx, model_ws=None):
return True, open(output_file_path).readlines()


@requires_pkg("modflowapi")
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_gwf_libmf6_ghb01.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import numpy as np
import pytest
from framework import TestFramework
from modflowapi import ModflowApi
from modflow_devtools.markers import requires_pkg

cases = ["libgwf_ghb01"]

Expand Down Expand Up @@ -180,6 +180,8 @@ def api_ghb_pak(hcof, rhs):


def api_func(exe, idx, model_ws=None):
from modflowapi import ModflowApi

name = cases[idx].upper()
if model_ws is None:
model_ws = "."
Expand Down Expand Up @@ -273,6 +275,7 @@ def api_func(exe, idx, model_ws=None):
return True, open(output_file_path).readlines()


@requires_pkg("modflowapi")
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_gwf_libmf6_ifmod01.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import flopy
import pytest
from framework import TestFramework
from modflowapi import ModflowApi
from modflow_devtools.markers import requires_pkg

cases = ["libgwf_ifmod01"]
name_left = "leftmodel"
Expand Down Expand Up @@ -207,6 +207,8 @@ def build_models(idx, test):


def api_func(exe, idx, model_ws=None):
from modflowapi import ModflowApi

if model_ws is None:
model_ws = "."
output_file_path = os.path.join(model_ws, "mfsim.stdout")
Expand Down Expand Up @@ -303,6 +305,7 @@ def check_interface_models(mf6):
), "AREA in interface model does not match"


@requires_pkg("modflowapi")
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_gwf_libmf6_ifmod02.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import numpy as np
import pytest
from framework import TestFramework
from modflowapi import ModflowApi
from modflow_devtools.markers import requires_pkg

cases = ["libgwf_ifmod02"]

Expand Down Expand Up @@ -303,6 +303,8 @@ def build_models(idx, test):


def api_func(exe, idx, model_ws=None):
from modflowapi import ModflowApi

if model_ws is None:
model_ws = "."

Expand Down Expand Up @@ -401,6 +403,7 @@ def check_interface_models(mf6):
)


@requires_pkg("modflowapi")
@pytest.mark.parametrize("idx, name", enumerate(cases))
@pytest.mark.developmode
def test_mf6model(idx, name, function_tmpdir, targets):
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_gwf_libmf6_ifmod03.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import numpy as np
import pytest
from framework import TestFramework
from modflowapi import ModflowApi
from modflow_devtools.markers import requires_pkg

cases = ["libgwf_ifmod03"]

Expand Down Expand Up @@ -220,6 +220,8 @@ def build_models(idx, test):


def api_func(exe, idx, model_ws=None):
from modflowapi import ModflowApi

if model_ws is None:
model_ws = "."

Expand Down Expand Up @@ -287,6 +289,7 @@ def check_interface_models(mf6):
assert abs(ymax - ymin) < 1e-6


@requires_pkg("modflowapi")
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_gwf_libmf6_rch01.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np
import pytest
from framework import TestFramework
from modflowapi import ModflowApi
from modflow_devtools.markers import requires_pkg

cases = ["libgwf_rch01"]

Expand Down Expand Up @@ -147,6 +147,8 @@ def build_models(idx, test):


def api_func(exe, idx, model_ws=None):
from modflowapi import ModflowApi

name = cases[idx].upper()
if model_ws is None:
model_ws = "."
Expand Down Expand Up @@ -229,6 +231,7 @@ def api_func(exe, idx, model_ws=None):
return True, open(output_file_path).readlines()


@requires_pkg("modflowapi")
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_gwf_libmf6_rch02.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np
import pytest
from framework import TestFramework
from modflowapi import ModflowApi
from modflow_devtools.markers import requires_pkg

cases = ["libgwf_rch02"]

Expand Down Expand Up @@ -180,6 +180,8 @@ def run_perturbation(mf6, max_iter, recharge, tag, rch):


def api_func(exe, idx, model_ws=None):
from modflowapi import ModflowApi

print("\nBMI implementation test:")

name = cases[idx].upper()
Expand Down Expand Up @@ -304,6 +306,7 @@ def api_func(exe, idx, model_ws=None):
return True, open(output_file_path).readlines()


@requires_pkg("modflowapi")
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_gwf_libmf6_riv01.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
import pytest
from framework import TestFramework
from modflowapi import ModflowApi
from modflow_devtools.markers import requires_pkg

cases = ["libgwf_riv01"]

Expand Down Expand Up @@ -153,6 +153,8 @@ def build_models(idx, test):


def api_func(exe, idx, model_ws=None):
from modflowapi import ModflowApi

name = cases[idx].upper()
if model_ws is None:
model_ws = "."
Expand Down Expand Up @@ -246,6 +248,7 @@ def api_func(exe, idx, model_ws=None):
return True, open(output_file_path).readlines()


@requires_pkg("modflowapi")
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_gwf_libmf6_riv02.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
import pytest
from framework import TestFramework
from modflowapi import ModflowApi
from modflow_devtools.markers import requires_pkg

cases = ["libgwf_riv02"]

Expand Down Expand Up @@ -167,6 +167,8 @@ def api_riv_pak(stage, h, hcof, rhs):


def api_func(exe, idx, model_ws=None):
from modflowapi import ModflowApi

name = cases[idx].upper()
if model_ws is None:
model_ws = "."
Expand Down Expand Up @@ -271,6 +273,7 @@ def api_func(exe, idx, model_ws=None):
return True, open(output_file_path).readlines()


@requires_pkg("modflowapi")
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_gwf_libmf6_sto01.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np
import pytest
from framework import TestFramework
from modflowapi import ModflowApi
from modflow_devtools.markers import requires_pkg

cases = ["libgwf_sto01"]

Expand Down Expand Up @@ -150,6 +150,8 @@ def build_models(idx, test):


def api_func(exe, idx, model_ws=None):
from modflowapi import ModflowApi

name = cases[idx].upper()
if model_ws is None:
model_ws = "."
Expand Down Expand Up @@ -205,6 +207,7 @@ def api_func(exe, idx, model_ws=None):
return True, open(output_file_path).readlines()


@requires_pkg("modflowapi")
@pytest.mark.slow
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
Expand Down
5 changes: 4 additions & 1 deletion autotest/test_prt_libmf6_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest
from framework import TestFramework
from modflowapi import ModflowApi
from modflow_devtools.markers import requires_pkg
from test_prt_budget import (
HorizontalCase,
build_mp7_sim,
Expand Down Expand Up @@ -44,6 +44,8 @@ def build_models(idx, test):


def api_func(exe, idx, model_ws=None):
from modflowapi import ModflowApi

name = cases[idx].upper()
if model_ws is None:
model_ws = Path(".")
Expand Down Expand Up @@ -97,6 +99,7 @@ def api_func(exe, idx, model_ws=None):
return True, open(output_file_path).readlines()


@requires_pkg("modflowapi")
@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down

0 comments on commit a832fdf

Please sign in to comment.