From deb90f4f946d8b51f732566efbedf73809ea622c Mon Sep 17 00:00:00 2001 From: w-bonelli Date: Wed, 18 Jan 2023 12:04:07 -0500 Subject: [PATCH] fix(tests): use keepable tmpdirs in pytest-cases POC --- autotest/test_gwf_buy_lak02.py | 4 ++-- autotest/test_gwf_csub_sk01.py | 10 +++++----- autotest/test_gwf_maw04.py | 6 +++--- autotest/test_gwf_maw_cases.py | 14 +++++++------- autotest/test_gwf_newton01.py | 4 ++-- autotest/test_gwf_obs01.py | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/autotest/test_gwf_buy_lak02.py b/autotest/test_gwf_buy_lak02.py index 26118e3aeed..514f3348da5 100644 --- a/autotest/test_gwf_buy_lak02.py +++ b/autotest/test_gwf_buy_lak02.py @@ -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 @@ -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( diff --git a/autotest/test_gwf_csub_sk01.py b/autotest/test_gwf_csub_sk01.py index 62231c0fcc8..c53ec9fc470 100644 --- a/autotest/test_gwf_csub_sk01.py +++ b/autotest/test_gwf_csub_sk01.py @@ -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 @@ -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( diff --git a/autotest/test_gwf_maw04.py b/autotest/test_gwf_maw04.py index cd7f71c7ad0..e77656f0c68 100644 --- a/autotest/test_gwf_maw04.py +++ b/autotest/test_gwf_maw04.py @@ -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( @@ -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, diff --git a/autotest/test_gwf_maw_cases.py b/autotest/test_gwf_maw_cases.py index 2c52f79077d..4469bcee2cc 100644 --- a/autotest/test_gwf_maw_cases.py +++ b/autotest/test_gwf_maw_cases.py @@ -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 @@ -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 ) @@ -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] @@ -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"] ) @@ -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): diff --git a/autotest/test_gwf_newton01.py b/autotest/test_gwf_newton01.py index 86339c395da..60c83c8f768 100644 --- a/autotest/test_gwf_newton01.py +++ b/autotest/test_gwf_newton01.py @@ -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) diff --git a/autotest/test_gwf_obs01.py b/autotest/test_gwf_obs01.py index fc41a26f281..bcee2743b56 100644 --- a/autotest/test_gwf_obs01.py +++ b/autotest/test_gwf_obs01.py @@ -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(