Skip to content

Commit

Permalink
fix(BaseModel): don't suppress error if exe not found
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Aug 3, 2023
1 parent ca838b1 commit 1852f17
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 15 additions & 0 deletions autotest/test_modflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,21 @@ def test_mt_modelgrid(function_tmpdir):
assert np.array_equal(swt.modelgrid.idomain, ml.modelgrid.idomain)


@requires_exe("mp7")
def test_exe_selection():
# no selection defaults to mf2005
assert Path(Modflow().exe_name).name == "mf2005"
assert Path(Modflow(exe_name=None).exe_name).name == "mf2005"

# user-specified (just for testing - there is no legitimate reason
# to use mp7 with Modflow but Modpath7 derives from BaseModel too)
assert Path(Modflow(exe_name="mp7").exe_name).name == "mp7"

# BaseModel used to silently fall back to mf2005 if exe not found
with pytest.raises(FileNotFoundError):
ml = Modflow(exe_name="not_an_exe")


def test_free_format_flag(function_tmpdir):
Lx = 100.0
Ly = 100.0
Expand Down
5 changes: 1 addition & 4 deletions flopy/mbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,7 @@ def __init__(
self._namefile = self.__name + "." + self.namefile_ext
self._packagelist = []
self.heading = ""
try:
self.exe_name = resolve_exe(exe_name)
except:
self.exe_name = "mf2005"
self.exe_name = "mf2005" if exe_name is None else resolve_exe(exe_name)
self._verbose = verbose
self.external_path = None
self.external_extension = "ref"
Expand Down

0 comments on commit 1852f17

Please sign in to comment.