Skip to content

tmp_path_retention_count config value type incorrect #14092

@AJDurant

Description

@AJDurant

I'm using pytest 9.0.2 and Python 3.13.5 (from uv) on Ubuntu 22.04

In my pyproject.toml I'm using the new pytest options (not ini_options), but for the setting tmp_path_retention_count if I set it to an int value (as in the schema) I get the following error:

pyproject.toml: config option 'tmp_path_retention_count' expects a string, got int: 1

If I set it as a string the schema validation fails as it expects me to be using ini_options

pyproject.toml settings:

[tool.pytest]
cache_dir = ".cache/pytest"
junit_logging = "system-out"
junit_log_passing_tests = false
# Only keep one set of test output, and only if failed
tmp_path_retention_count = 1
tmp_path_retention_policy = "failed"

full trace:

uv run pytest --basetemp=diagnostics --junit-xml=project.junit.xml
warning: No `requires-python` value found in the workspace. Defaulting to `>=3.13`.
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/adurant/project/1/.venv/lib/python3.13/site-packages/_pytest/main.py", line 314, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~^^
INTERNALERROR>   File "/home/adurant/project/1/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1159, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/adurant/project/1/.venv/lib/python3.13/site-packages/pluggy/_hooks.py", line 534, in call_historic
INTERNALERROR>     res = self._hookexec(self.name, self._hookimpls.copy(), kwargs, False)
INTERNALERROR>   File "/home/adurant/project/1/.venv/lib/python3.13/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/adurant/project/1/.venv/lib/python3.13/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR>     raise exception
INTERNALERROR>   File "/home/adurant/project/1/.venv/lib/python3.13/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/adurant/project/1/.venv/lib/python3.13/site-packages/_pytest/tmpdir.py", line 220, in pytest_configure
INTERNALERROR>     _tmp_path_factory = TempPathFactory.from_config(config, _ispytest=True)
INTERNALERROR>   File "/home/adurant/project/1/.venv/lib/python3.13/site-packages/_pytest/tmpdir.py", line 89, in from_config
INTERNALERROR>     count = int(config.getini("tmp_path_retention_count"))
INTERNALERROR>                 ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/adurant/project/1/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1662, in getini
INTERNALERROR>     self._inicache[canonical_name] = val = self._getini(canonical_name)
INTERNALERROR>                                            ~~~~~~~~~~~~^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/adurant/project/1/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1706, in _getini
INTERNALERROR>     return self._getini_toml(name, canonical_name, type, value, default)
INTERNALERROR>            ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/adurant/project/1/.venv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1847, in _getini_toml
INTERNALERROR>     raise TypeError(
INTERNALERROR>     ...<2 lines>...
INTERNALERROR>     )
INTERNALERROR> TypeError: /home/adurant/project/1/pyproject.toml: config option 'tmp_path_retention_count' expects a string, got int: 1

uv pip list:

uv pip list
Package                   Version
------------------------- -----------
attrs                     25.4.0
certifi                   2026.1.4
charset-normalizer        3.4.4
distro                    1.9.0
idna                      3.11
iniconfig                 2.3.0
jsonschema                4.25.1
jsonschema-specifications 2025.9.1
nodeenv                   1.10.0
packaging                 25.0
pluggy                    1.6.0
psutil                    7.2.1
pygments                  2.19.2
pyright                   1.1.407
pytest                    9.0.2
pytest-helpers-namespace  2021.12.29
pytest-shell-utilities    1.9.7
pytest-skip-markers       1.5.2
python-dateutil           2.9.0.post0
referencing               0.37.0
requests                  2.32.5
rpds-py                   0.30.0
ruff                      0.14.10
setuptools                80.9.0
six                       1.17.0
typing-extensions         4.15.0
urllib3                   2.6.2
  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions