Skip to content

Commit

Permalink
ci: convert addition autotests to use FlopyTestSetup testing class
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhughes-usgs committed Nov 1, 2021
1 parent 06c91bd commit b50b977
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions autotest/t501_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

def test_mf6():
base_dir = base_test_dir(__file__, rel_path="temp", verbose=True)
test_setup = FlopyTestSetup(verbose=True, test_dirs=baseDir)
test_setup = FlopyTestSetup(verbose=True, test_dirs=base_dir)

sim = flopy.mf6.MFSimulation(sim_ws=baseDir)
sim = flopy.mf6.MFSimulation(sim_ws=base_dir)
assert isinstance(sim, flopy.mf6.MFSimulation)

tdis = flopy.mf6.modflow.mftdis.ModflowTdis(sim)
Expand Down Expand Up @@ -97,7 +97,7 @@ def test_mf6():
sim.write_simulation()

# Verify files were written
assert os.path.isfile(os.path.join(baseDir, "mfsim.nam"))
assert os.path.isfile(os.path.join(base_dir, "mfsim.nam"))
exts_model = [
"nam",
"dis",
Expand All @@ -124,10 +124,10 @@ def test_mf6():
]
exts_sim = ["gwfgwf", "ims", "tdis"]
for ext in exts_model:
fname = os.path.join(baseDir, f"model.{ext}")
fname = os.path.join(base_dir, f"model.{ext}")
assert os.path.isfile(fname), f"{fname} not found"
for ext in exts_sim:
fname = os.path.join(baseDir, f"sim.{ext}")
fname = os.path.join(base_dir, f"sim.{ext}")
assert os.path.isfile(fname), f"{fname} not found"

return
Expand Down
4 changes: 2 additions & 2 deletions autotest/t502_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def test_create_and_run_model():

test_setup = FlopyTestSetup(verbose=True, test_dirs=baseDir)
test_setup = FlopyTestSetup(verbose=True, test_dirs=base_dir)

# names
sim_name = "testsim"
Expand All @@ -22,7 +22,7 @@ def test_create_and_run_model():
# set up simulation
tdis_name = f"{sim_name}.tdis"
sim = MFSimulation(
sim_name=sim_name, version="mf6", exe_name=exe_name, sim_ws=baseDir
sim_name=sim_name, version="mf6", exe_name=exe_name, sim_ws=base_dir
)
tdis_rc = [(6.0, 2, 1.0), (6.0, 3, 1.0)]
tdis = mftdis.ModflowTdis(
Expand Down
16 changes: 8 additions & 8 deletions autotest/t503_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
print(f" {exdir}")


def copy_folder(baseDir, src):
def copy_folder(base_dir, src):
subDir = src.partition("{0}mf6examples{0}".format(os.path.sep))[2]
if os.path.basename(subDir) in os.path.basename(baseDir):
dst = baseDir
if os.path.basename(subDir) in os.path.basename(base_dir):
dst = base_dir
else:
dst = os.path.join(baseDir, subDir)
dst = os.path.join(base_dir, subDir)

# clean the destination directory if it exists
if os.path.isdir(dst):
Expand All @@ -58,9 +58,9 @@ def copy_folder(baseDir, src):
return dst


def simulation_subdirs(baseDir):
def simulation_subdirs(base_dir):
exsubdirs = []
for dirName, subdirList, fileList in os.walk(baseDir):
for dirName, subdirList, fileList in os.walk(base_dir):
for file_name in fileList:
if file_name.lower() == "mfsim.nam":
print(f"Found directory: {dirName}")
Expand All @@ -78,7 +78,7 @@ def runmodel(exdir):

simulations = simulation_subdirs(exdir)
for src in simulations:
ws = copy_folder(baseDir, src)
ws = copy_folder(base_dir, src)
test_setup.add_test_dir(ws)
f = os.path.basename(os.path.normpath(ws))
print("\n\n")
Expand Down Expand Up @@ -129,7 +129,7 @@ def runmodel(exdir):
)
assert success, f"comparision for {ws} failed"

test_setup.add_test_dir(baseDir)
test_setup.add_test_dir(base_dir)


# for running tests with pytest
Expand Down

0 comments on commit b50b977

Please sign in to comment.