diff --git a/changelog/4680.bugfix.rst b/changelog/4680.bugfix.rst new file mode 100644 index 000000000..9126a70ea --- /dev/null +++ b/changelog/4680.bugfix.rst @@ -0,0 +1 @@ +Ensure the ``tmpdir`` and the ``tmp_path`` fixtures are the same folder. diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index 860c2d4af..267328414 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -167,7 +167,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 +176,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 diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index 6040d9444..3e6bde379 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -337,3 +337,7 @@ def attempt_symlink_to(path, to_path): Path(path).symlink_to(Path(to_path)) except OSError: pytest.skip("could not create symbolic link") + + +def test_tmpdir_equals_tmp_path(tmpdir, tmp_path): + assert Path(tmpdir) == tmp_path