Skip to content

Commit

Permalink
fix(tests): use keepable tmpdirs in pytest-cases POC
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Jan 18, 2023
1 parent 5cfeb20 commit deb90f4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions autotest/test_gwf_buy_lak02.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Data(NamedTuple):
Data(name="d", gwt_conc=0, lak_conc=35),
]
)
def case_generator(self, data, tmpdir):
def case_generator(self, data, function_tmpdir):
lx = 7.0
lz = 4.0
nlay = 4
Expand Down Expand Up @@ -69,7 +69,7 @@ def case_generator(self, data, tmpdir):
sim_name=data.name,
version="mf6",
exe_name="mf6",
sim_ws=str(tmpdir),
sim_ws=str(function_tmpdir),
)
# create tdis package
tdis = flopy.mf6.ModflowTdis(
Expand Down
10 changes: 5 additions & 5 deletions autotest/test_gwf_csub_sk01.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class Data(NamedTuple):
Data("c", None, True, 0, 15, True, 0.3),
]
)
def case_generator(self, tmpdir, data):
sim = self.get_model(data, tmpdir)
cmp = self.get_model(data, tmpdir / "mf6_regression")
def case_generator(self, function_tmpdir, data):
sim = self.get_model(data, function_tmpdir)
cmp = self.get_model(data, function_tmpdir / "mf6_regression")
return data, sim, cmp, self.eval_case

def get_model(self, data, tmpdir):
def get_model(self, data, function_tmpdir):
name = data.name
newton = data.newton
newtonoptions = None
Expand Down Expand Up @@ -168,7 +168,7 @@ def get_model(self, data, tmpdir):

# build MODFLOW 6 files
sim = flopy.mf6.MFSimulation(
sim_name=name, version="mf6", exe_name="mf6", sim_ws=str(tmpdir)
sim_name=name, version="mf6", exe_name="mf6", sim_ws=str(function_tmpdir)
)
# create tdis package
tdis = flopy.mf6.ModflowTdis(
Expand Down
6 changes: 3 additions & 3 deletions autotest/test_gwf_maw04.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ def well4(label):

class GwfMaw04Cases:
@parametrize(data=cases, ids=[c.name for c in cases])
def case_4(self, tmpdir, targets, data):
def case_4(self, function_tmpdir, targets, data):
name = data.name
ws = str(tmpdir)
ws = str(function_tmpdir)

# build MODFLOW 6 files
sim = flopy.mf6.MFSimulation(
Expand Down Expand Up @@ -225,7 +225,7 @@ def case_4(self, tmpdir, targets, data):
mc = None
else:
cmppth = "mf2005"
ws = os.path.join(str(tmpdir), cmppth)
ws = os.path.join(str(function_tmpdir), cmppth)
mc = flopy.modflow.Modflow(name, model_ws=ws, version=cmppth)
dis = flopy.modflow.ModflowDis(
mc,
Expand Down
14 changes: 7 additions & 7 deletions autotest/test_gwf_maw_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ class GwfMawCases:
]

@parametrize(data=cases1, ids=[c.name for c in cases1])
def case_1(self, tmpdir, targets, data):
def case_1(self, function_tmpdir, targets, data):
sim = flopy.mf6.MFSimulation(
sim_name=data.name,
version="mf6",
exe_name=targets["mf6"],
sim_ws=str(tmpdir),
sim_ws=str(function_tmpdir),
)

# create tdis package
Expand Down Expand Up @@ -329,9 +329,9 @@ def eval_1(self, config, data):
cases2 = [case2]

@parametrize(data=cases2, ids=[c.name for c in cases2])
def case_2(self, tmpdir, targets, data):
def case_2(self, function_tmpdir, targets, data):
name = data.name
ws = str(tmpdir)
ws = str(function_tmpdir)
sim = flopy.mf6.MFSimulation(
sim_name=name, version="mf6", exe_name=targets["mf6"], sim_ws=ws
)
Expand Down Expand Up @@ -598,7 +598,7 @@ def eval_2(self, config, data):
]

@parametrize(data=cases3, ids=[c.name for c in cases3])
def case_3(self, tmpdir, targets, data):
def case_3(self, function_tmpdir, targets, data):
top = 0.0
botm = [-1000.0]

Expand All @@ -607,7 +607,7 @@ def case_3(self, tmpdir, targets, data):
tdis_rc.append((data.perlen[i], data.nstp[i], data.tsmult[i]))

name = data.name
ws = str(tmpdir)
ws = str(function_tmpdir)
sim = flopy.mf6.MFSimulation(
sim_name=name, sim_ws=ws, exe_name=targets["mf6"]
)
Expand Down Expand Up @@ -810,7 +810,7 @@ def eval_3(self, config, data):
# ]

# @parametrize(data=cases4, ids=[c['name'] for c in cases4])
# def case_4(self, tmpdir, targets, data):
# def case_4(self, function_tmpdir, targets, data):
# pass

# def eval_4(self, sim, data):
Expand Down
4 changes: 2 additions & 2 deletions autotest/test_gwf_newton01.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def eval_head(sim):
"idx, name",
list(enumerate(ex)),
)
def test_mf6model(idx, name, tmpdir, targets):
ws = str(tmpdir)
def test_mf6model(idx, name, function_tmpdir, targets):
ws = str(function_tmpdir)
test = TestFramework()
test.build(build_model, idx, ws)
test.run(TestSimulation(name=name, exe_dict=targets, exfunc=eval_head), ws)
4 changes: 2 additions & 2 deletions autotest/test_gwf_obs01.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def eval_model(sim):
"idx, name",
list(enumerate(ex)),
)
def test_mf6model(idx, name, tmpdir, targets):
ws = str(tmpdir)
def test_mf6model(idx, name, function_tmpdir, targets):
ws = str(function_tmpdir)
test = TestFramework()
test.build(build_model, idx, ws)
test.run(
Expand Down

0 comments on commit deb90f4

Please sign in to comment.