Merge pull request #4681 from RonnyPfannschmidt/fix-4680-tmppath-is-tmpdir

Fix 4680 - `tmp_path` and `tmpdir` now share the same temporary directory
This commit is contained in:
Bruno Oliveira
2019-01-29 19:00:56 -02:00
committed by GitHub
5 changed files with 11 additions and 4 deletions

View File

@@ -63,9 +63,10 @@ class TempPathFactory(object):
if self._given_basetemp is not None:
basetemp = self._given_basetemp
ensure_reset_dir(basetemp)
basetemp = basetemp.resolve()
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
@@ -167,7 +168,7 @@ def _mk_tmp(request, factory):
@pytest.fixture
def tmpdir(request, tmpdir_factory):
def tmpdir(tmp_path):
"""Return a temporary directory path object
which is unique to each test function invocation,
created as a sub directory of the base temporary
@@ -176,7 +177,7 @@ def tmpdir(request, tmpdir_factory):
.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
"""
return _mk_tmp(request, tmpdir_factory)
return py.path.local(tmp_path)
@pytest.fixture