Skip to content

Commit bf44537

Browse files
authored
Merge branch 'pytest-dev:main' into bugfix-12625-ignorebuild
2 parents 3f105b4 + de56152 commit bf44537

17 files changed

+239
-163
lines changed

Diff for: .github/workflows/deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
persist-credentials: false
3232

3333
- name: Build and Check Package
34-
uses: hynek/build-and-inspect-python-package@v2.9.0
34+
uses: hynek/build-and-inspect-python-package@v2.10.0
3535
with:
3636
attest-build-provenance-github: 'true'
3737

Diff for: .github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
fetch-depth: 0
4141
persist-credentials: false
4242
- name: Build and Check Package
43-
uses: hynek/build-and-inspect-python-package@v2.9.0
43+
uses: hynek/build-and-inspect-python-package@v2.10.0
4444

4545
build:
4646
needs: [package]

Diff for: .pre-commit-config.yaml

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: "v0.6.9"
3+
rev: "v0.7.2"
44
hooks:
55
- id: ruff
66
args: ["--fix"]
@@ -12,7 +12,7 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: check-yaml
1414
- repo: https://github.com/adamchainz/blacken-docs
15-
rev: 1.19.0
15+
rev: 1.19.1
1616
hooks:
1717
- id: blacken-docs
1818
additional_dependencies: [black==24.1.1]
@@ -28,7 +28,7 @@ repos:
2828
hooks:
2929
- id: python-use-type-annotations
3030
- repo: https://github.com/pre-commit/mirrors-mypy
31-
rev: v1.11.2
31+
rev: v1.13.0
3232
hooks:
3333
- id: mypy
3434
files: ^(src/|testing/|scripts/)
@@ -44,13 +44,13 @@ repos:
4444
# on <3.11
4545
- exceptiongroup>=1.0.0rc8
4646
- repo: https://github.com/tox-dev/pyproject-fmt
47-
rev: "2.3.1"
47+
rev: "v2.5.0"
4848
hooks:
4949
- id: pyproject-fmt
5050
# https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version
5151
additional_dependencies: ["tox>=4.9"]
5252
- repo: https://github.com/asottile/pyupgrade
53-
rev: v3.18.0
53+
rev: v3.19.0
5454
hooks:
5555
- id: pyupgrade
5656
stages: [manual]
@@ -61,7 +61,8 @@ repos:
6161
entry: pylint
6262
language: system
6363
types: [python]
64-
args: ["-rn", "-sn", "--fail-on=I"]
64+
args: ["-rn", "-sn", "--fail-on=I", "--enable-all-extentions"]
65+
require_serial: true
6566
stages: [manual]
6667
- id: rst
6768
name: rst

Diff for: changelog/10829.doc.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve documentation on the current handling of the ``--basetemp`` option and its lack of retention functionality (:ref:`temporary directory location and retention`).
File renamed without changes.
File renamed without changes.

Diff for: doc/en/how-to/tmp_path.rst

+35-15
Original file line numberDiff line numberDiff line change
@@ -133,27 +133,47 @@ API for details.
133133
Temporary directory location and retention
134134
------------------------------------------
135135

136-
Temporary directories are by default created as sub-directories of
137-
the system temporary directory. The base name will be ``pytest-NUM`` where
138-
``NUM`` will be incremented with each test run.
139-
By default, entries older than 3 temporary directories will be removed.
140-
This behavior can be configured with :confval:`tmp_path_retention_count` and
141-
:confval:`tmp_path_retention_policy`.
136+
The temporary directories,
137+
as returned by the :fixture:`tmp_path` and (now deprecated) :fixture:`tmpdir` fixtures,
138+
are automatically created under a base temporary directory,
139+
in a structure that depends on the ``--basetemp`` option:
142140

143-
Using the ``--basetemp``
144-
option will remove the directory before every run, effectively meaning the temporary directories
145-
of only the most recent run will be kept.
141+
- By default (when the ``--basetemp`` option is not set),
142+
the temporary directories will follow this template:
146143

147-
You can override the default temporary directory setting like this:
144+
.. code-block:: text
148145
149-
.. code-block:: bash
146+
{temproot}/pytest-of-{user}/pytest-{num}/{testname}/
150147
151-
pytest --basetemp=mydir
148+
where:
152149

153-
.. warning::
150+
- ``{temproot}`` is the system temporary directory
151+
as determined by :py:func:`tempfile.gettempdir`.
152+
It can be overridden by the :envvar:`PYTEST_DEBUG_TEMPROOT` environment variable.
153+
- ``{user}`` is the user name running the tests,
154+
- ``{num}`` is a number that is incremented with each test suite run
155+
- ``{testname}`` is a sanitized version of :py:attr:`the name of the current test <_pytest.nodes.Node.name>`.
154156

155-
The contents of ``mydir`` will be completely removed, so make sure to use a directory
156-
for that purpose only.
157+
The auto-incrementing ``{num}`` placeholder provides a basic retention feature
158+
and avoids that existing results of previous test runs are blindly removed.
159+
By default, the last 3 temporary directories are kept,
160+
but this behavior can be configured with
161+
:confval:`tmp_path_retention_count` and :confval:`tmp_path_retention_policy`.
162+
163+
- When the ``--basetemp`` option is used (e.g. ``pytest --basetemp=mydir``),
164+
it will be used directly as base temporary directory:
165+
166+
.. code-block:: text
167+
168+
{basetemp}/{testname}/
169+
170+
Note that there is no retention feature in this case:
171+
only the results of the most recent run will be kept.
172+
173+
.. warning::
174+
175+
The directory given to ``--basetemp`` will be cleared blindly before each test run,
176+
so make sure to use a directory for that purpose only.
157177

158178
When distributing tests on the local machine using ``pytest-xdist``, care is taken to
159179
automatically configure a `basetemp` directory for the sub processes such that all temporary

0 commit comments

Comments
 (0)