Fix issue where working dir becomes wrong on subst drive on Windows. Fixes #5965 (#6523)

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
Fabio Zadrozny
2020-06-08 10:56:40 -03:00
committed by GitHub
parent c17d50829f
commit 322190fd84
10 changed files with 160 additions and 120 deletions

View File

@@ -18,6 +18,7 @@ from typing import Set
from typing import TypeVar
from typing import Union
from _pytest.outcomes import skip
from _pytest.warning_types import PytestWarning
if sys.version_info[:2] >= (3, 6):
@@ -397,3 +398,11 @@ def fnmatch_ex(pattern: str, path) -> bool:
def parts(s: str) -> Set[str]:
parts = s.split(sep)
return {sep.join(parts[: i + 1]) or sep for i in range(len(parts))}
def symlink_or_skip(src, dst, **kwargs):
"""Makes a symlink or skips the test in case symlinks are not supported."""
try:
os.symlink(str(src), str(dst), **kwargs)
except OSError as e:
skip("symlinks not supported: {}".format(e))