From c2980eb80ffc9a7ab81d1424afeac77ec46a2fe2 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 26 Jan 2020 23:36:28 +0100 Subject: [PATCH] pytester: test for _makefile joining an absolute path Ref: https://github.com/pytest-dev/pytest/pull/6578#discussion_r371035867 --- testing/test_pytester.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 869e35db3..35a06e33a 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -710,3 +710,13 @@ def test_testdir_outcomes_with_multiple_errors(testdir): result.assert_outcomes(error=2) assert result.parseoutcomes() == {"error": 2} + + +def test_makefile_joins_absolute_path(testdir: Testdir) -> None: + absfile = testdir.tmpdir / "absfile" + if sys.platform == "win32": + with pytest.raises(OSError): + testdir.makepyfile(**{str(absfile): ""}) + else: + p1 = testdir.makepyfile(**{str(absfile): ""}) + assert str(p1) == (testdir.tmpdir / absfile) + ".py"