Retain tmp paths for setup and teardown errors - #14999
Conversation
|
I found a regression in the setup-skip path: removing Minimal reproduction, run with import pytest
@pytest.fixture
def resource(tmp_path):
(tmp_path / "input.txt").write_text("fixture data", encoding="utf-8")
yield tmp_path
assert (tmp_path / "input.txt").read_text(encoding="utf-8") == "fixture data"
@pytest.fixture
def unavailable(resource):
pytest.skip("optional service unavailable")
def test_optional_service(unavailable):
passThe base commit Disclosure: Codex assisted with identifying and reproducing this case. |
|
Thanks for the repro. I reproduced the setup-skip teardown case and pushed |
Fixes #14998.
tmp_path_retention_policy = "failed"currently removes a temporary directory before setup or teardown outcomes are known. This loses debugging evidence for fixture setup errors and teardown errors.This change defers the retention decision until the teardown report is available. Setup skips keep the existing cleanup behavior from #10502, while setup errors, call failures, and teardown errors retain their directories.
Tests:
uv run --frozen pytest testing/test_tmpdir.py -q(49 passed, 11 skipped)uvx --from ruff ruff check src/_pytest/tmpdir.py testing/test_tmpdir.pyuvx --from ruff ruff format --check src/_pytest/tmpdir.py testing/test_tmpdir.pytesting/acceptance_test.py::TestInvocationVariants::test_pydocdue to Windows/Python 3.14 UTF-8 decoding.git diff --check