diff --git a/tests/functional2/pyproject.toml b/tests/functional2/pyproject.toml index d807b996e..2c8a2122c 100644 --- a/tests/functional2/pyproject.toml +++ b/tests/functional2/pyproject.toml @@ -5,6 +5,12 @@ requires-python = ">=3.11" [tool.pytest.ini_options] addopts = "-p no:xonsh" + +# Keep the temporary files of the last 3 test runs (default value) +tmp_path_retention_count = 3 +# Keep temporary files of all tests, regardless if they failed or not +tmp_path_retention_policy = "all" + log_cli = true log_cli_level = "INFO" # how the logs are being printed, default is `"%(filename)s %(lineno)d %(levelname)s %(message)s"` diff --git a/tests/functional2/testlib/fixtures/nix.py b/tests/functional2/testlib/fixtures/nix.py index c893c76e2..63ce1d176 100644 --- a/tests/functional2/testlib/fixtures/nix.py +++ b/tests/functional2/testlib/fixtures/nix.py @@ -6,7 +6,7 @@ import subprocess from functools import partialmethod from pathlib import Path from typing import Any, AnyStr -from collections.abc import Callable +from collections.abc import Callable, Generator import pytest @@ -239,5 +239,9 @@ class Nix: @pytest.fixture -def nix(tmp_path: Path) -> Nix: - return Nix(tmp_path) +def nix(tmp_path: Path) -> Generator[Nix, Any, None]: + yield Nix(tmp_path) + # when things are done using the nix store, the permissions for the store are read only + # after the test was executed, we set the permissions to rwx (write being the important part) + # for pytest to be able to delete the files during cleanup + Command(argv=["chmod", "-R", "+w", str(tmp_path.absolute())], env=os.environ.copy()).run().ok()