Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(test000_setup): fallback for when os.path.relpath throws #45

Merged
merged 1 commit into from
Apr 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test(test000_setup): fallback for when os.path.relpath throws
Happens on Windows only. It is only used for logging, so no functional change.
  • Loading branch information
visr committed Apr 2, 2019
commit 0c4802a212404f8549c1124c4cd638c63fd4ff52
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