From ca847e8c90bd5215c9c5caece55d1c948b9a4d8a Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 26 Jan 2020 23:36:28 +0100 Subject: [PATCH] pytester: _makefile: use `abs=True` when joining paths Passing in an absolute path should use that, but not join it with the tmpdir. --- src/_pytest/pytester.py | 2 +- testing/test_pytester.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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"