diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 8e7fa5e09bb..fbc7327440b 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -614,7 +614,7 @@ def to_text(s): ret = None for basename, value in items: - p = self.tmpdir.join(basename).new(ext=ext) + p = self.tmpdir.join(basename, abs=True).new(ext=ext) p.dirpath().ensure_dir() source = Source(value) source = "\n".join(to_text(line) for line in source.lines) diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 869e35db3e1..5aed9ed7010 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -710,3 +710,9 @@ def test_error2(bad_fixture): result.assert_outcomes(error=2) assert result.parseoutcomes() == {"error": 2} + + +def test_makefile_abs(testdir): + path = str(testdir.tmpdir / "absfile") + p1 = testdir.makepyfile(**{path: "..."}) + assert str(p1) == path + ".py"