Documentation update for tmp_path configurations

This commit is contained in:
Yusuke Kadowaki 2022-12-01 22:29:46 +09:00
parent f513d33d5a
commit 62e75c7d55
2 changed files with 10 additions and 5 deletions

View File

@ -131,10 +131,13 @@ The default base temporary directory
Temporary directories are by default created as sub-directories of Temporary directories are by default created as sub-directories of
the system temporary directory. The base name will be ``pytest-NUM`` where the system temporary directory. The base name will be ``pytest-NUM`` where
``NUM`` will be incremented with each test run. Moreover, entries older ``NUM`` will be incremented with each test run.
than 3 temporary directories will be removed. By default, only the directories of failed tests will be kept.
Also only the last 3 directries will remain at most.
This behavior can be configured with :confval:`tmp_path_retention_count` and
:confval:`tmp_path_retention_policy`.
The number of entries currently cannot be changed, but using the ``--basetemp`` Using the ``--basetemp``
option will remove the directory before every run, effectively meaning the temporary directories option will remove the directory before every run, effectively meaning the temporary directories
of only the most recent run will be kept. of only the most recent run will be kept.

View File

@ -267,8 +267,10 @@ def tmp_path(
directory. directory.
By default, a new base temporary directory is created each test session, By default, a new base temporary directory is created each test session,
and old bases are removed after 3 sessions, to aid in debugging. If and only the base of failed session is kept. Also it only keeps the last 3 bases
``--basetemp`` is used then it is cleared each session. See :ref:`base at most. This can be configured with :confval:`tmp_path_retention_count` and
:confval:`tmp_path_retention_policy`.
If ``--basetemp`` is used then it is cleared each session. See :ref:`base
temporary directory`. temporary directory`.
The returned object is a :class:`pathlib.Path` object. The returned object is a :class:`pathlib.Path` object.