diff options
author | Fabio Zadrozny <fabiofz@gmail.com> | 2020-06-08 10:56:40 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-08 10:56:40 -0300 |
commit | 322190fd84e1b86d7b9a2d71f086445ca80c39b3 (patch) | |
tree | b48b5a82afdb07cd87f3a5492621e174abaed6a7 /src/_pytest/pathlib.py | |
parent | c17d50829f3173c85a9810520458a112971d551c (diff) | |
download | pytest-322190fd84e1b86d7b9a2d71f086445ca80c39b3.tar.gz |
Fix issue where working dir becomes wrong on subst drive on Windows. Fixes #5965 (#6523)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Diffstat (limited to 'src/_pytest/pathlib.py')
-rw-r--r-- | src/_pytest/pathlib.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index 6878965e0..69f490a1d 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -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)) |