Skip to content

Commit

Permalink
test(test000_setup): fallback for when os.path.relpath throws
Browse files Browse the repository at this point in the history
Happens on Windows only. It is only used for logging, so no functional change.
  • Loading branch information
visr committed Apr 2, 2019
1 parent 40dd799 commit 0c4802a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions autotest/test000_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
mfexe_pth = 'temp/mfexes'


def relpath_fallback(pth):
try:
# throws ValueError on Windows if pth is on a different drive
return os.path.relpath(pth)
except ValueError:
return os.path.abspath(pth)


def create_dir(pth):
# remove pth directory if it exists
if os.path.exists(pth):
Expand Down Expand Up @@ -173,7 +181,7 @@ def test_build_modflow6():
pymake.main(srcdir, target, fc=fc, cc=cc, include_subdirs=True,
fflags=fflags)

msg = '{} does not exist.'.format(os.path.relpath(target))
msg = '{} does not exist.'.format(relpath_fallback(target))
assert os.path.isfile(target), msg


Expand All @@ -197,7 +205,7 @@ def test_build_mf5to6():
pymake.main(srcdir, target, fc=fc, cc=cc, include_subdirs=True,
extrafiles=extrafiles)

msg = '{} does not exist.'.format(os.path.relpath(target))
msg = '{} does not exist.'.format(relpath_fallback(target))
assert os.path.isfile(target), msg


Expand All @@ -219,7 +227,7 @@ def test_build_zonebudget():

pymake.main(srcdir, target, fc=fc, cc=cc, extrafiles=extrafiles)

msg = '{} does not exist.'.format(os.path.relpath(target))
msg = '{} does not exist.'.format(relpath_fallback(target))
assert os.path.isfile(target), msg


Expand Down

0 comments on commit 0c4802a

Please sign in to comment.