diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 61fb7eaa4..79a24632b 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -228,6 +228,22 @@ def pytest_addoption(parser: Parser) -> None: ), ) + group.addoption( + "--tmp-path-retention-count", + dest="tmp_path_retention_count", + default=3, + metavar="num", + help="How many sessions should we keep the `tmp_path` directories, according to `tmp_path_retention_policy`.", + ) + + group.addoption( + "--tmp-path-retention-policy", + default="failed", + choices=["all", "failed", "none"], + dest="tmp_path_retention_policy", + help="Controls which directories created by the `tmp_path` fixture are kept around, based on test outcome.", + ) + def validate_basetemp(path: str) -> str: # GH 7119