From 327766ca2564f4d275cbe078e9d796aab32bbff0 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 14 Nov 2025 00:21:02 +0200 Subject: [PATCH] Merge pull request #13958 from bluetech/fix-tmpdir-retention-toml doc: fix TOML example for `tmp_path_retention_count`, it's a string (cherry picked from commit 9652bc714d0cae7f849d285aaa9f5a7e42e89ee3) --- changelog/13904.bugfix.rst | 1 + doc/en/reference/reference.rst | 4 ++-- src/_pytest/tmpdir.py | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changelog/13904.bugfix.rst diff --git a/changelog/13904.bugfix.rst b/changelog/13904.bugfix.rst new file mode 100644 index 00000000000..f5a42215ca8 --- /dev/null +++ b/changelog/13904.bugfix.rst @@ -0,0 +1 @@ +Fixed the TOML type of the :confval:`tmp_path_retention_count` settings in the API reference from number to string. diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 139140afdfa..496fc1b7dbc 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -2460,14 +2460,14 @@ passed multiple times. The expected format is ``name=value``. For example:: .. confval:: tmp_path_retention_count How many sessions should we keep the `tmp_path` directories, - according to `tmp_path_retention_policy`. + according to :confval:`tmp_path_retention_policy`. .. tab:: toml .. code-block:: toml [pytest] - tmp_path_retention_count = 3 + tmp_path_retention_count = "3" .. tab:: ini diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index dcd5784f88f..855ad273ecf 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -225,13 +225,16 @@ def pytest_addoption(parser: Parser) -> None: parser.addini( "tmp_path_retention_count", help="How many sessions should we keep the `tmp_path` directories, according to `tmp_path_retention_policy`.", - default=3, + default="3", + # NOTE: Would have been better as an `int` but can't change it now. + type="string", ) parser.addini( "tmp_path_retention_policy", help="Controls which directories created by the `tmp_path` fixture are kept around, based on test outcome. " "(all/failed/none)", + type="string", default="all", )