Commit af57f15c by Brian Turek Committed by Bryce Drennan

Fix pytest fixtures on Win10 (#1326)

Catch and deal with failed symlinking on Windows
parent bd5fcf9b
......@@ -87,7 +87,15 @@ def mock_download(self, url, dest):
if dest.exists():
os.unlink(str(dest))
if PY2 and WINDOWS:
# Python2 does not support os.symlink on Windows whereas Python3 does. os.symlink requires either administrative
# privileges or developer mode on Win10, throwing an OSError is neither is active.
if WINDOWS:
if PY2:
shutil.copyfile(str(fixture), str(dest))
else:
try:
os.symlink(str(fixture), str(dest))
except OSError:
shutil.copyfile(str(fixture), str(dest))
else:
os.symlink(str(fixture), str(dest))
......
......@@ -52,7 +52,15 @@ def mock_download(self, url, dest):
if dest.exists():
shutil.rmtree(str(dest))
if PY2 and WINDOWS:
# Python2 does not support os.symlink on Windows whereas Python3 does. os.symlink requires either administrative
# privileges or developer mode on Win10, throwing an OSError is neither is active.
if WINDOWS:
if PY2:
shutil.copyfile(str(fixture), str(dest))
else:
try:
os.symlink(str(fixture), str(dest))
except OSError:
shutil.copyfile(str(fixture), str(dest))
else:
os.symlink(str(fixture), str(dest))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment