From c75bd0880729e36d58e61a3da8828c3b47edb030 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sun, 27 Jan 2019 14:08:43 +0100 Subject: [PATCH] ensure tmp_path is always a realpath --- changelog/4681.bugfix.rst | 1 + src/_pytest/tmpdir.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog/4681.bugfix.rst diff --git a/changelog/4681.bugfix.rst b/changelog/4681.bugfix.rst new file mode 100644 index 000000000..3ece27397 --- /dev/null +++ b/changelog/4681.bugfix.rst @@ -0,0 +1 @@ +Ensure ``tmp_path`` is always a real path. diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index 267328414..b8c755ac6 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -61,11 +61,11 @@ class TempPathFactory(object): """ return base temporary directory. """ if self._basetemp is None: if self._given_basetemp is not None: - basetemp = self._given_basetemp + basetemp = self._given_basetemp.resolve() ensure_reset_dir(basetemp) else: from_env = os.environ.get("PYTEST_DEBUG_TEMPROOT") - temproot = Path(from_env or tempfile.gettempdir()) + temproot = Path(from_env or tempfile.gettempdir()).resolve() user = get_user() or "unknown" # use a sub-directory in the temproot to speed-up # make_numbered_dir() call