Skip to content

Commit 87569cd

Browse files
committed
Merge branch 'main' into no-cache-fixture
2 parents 27f442d + 7add2af commit 87569cd

19 files changed

+607
-228
lines changed

.github/workflows/deploy.yml

+2-2
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.8.0
34+
uses: hynek/build-and-inspect-python-package@v2.9.0
3535
with:
3636
attest-build-provenance-github: 'true'
3737

@@ -54,7 +54,7 @@ jobs:
5454
path: dist
5555

5656
- name: Publish package to PyPI
57-
uses: pypa/[email protected].1
57+
uses: pypa/[email protected].2
5858
with:
5959
attestations: true
6060

.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.8.0
43+
uses: hynek/build-and-inspect-python-package@v2.9.0
4444

4545
build:
4646
needs: [package]

.github/workflows/update-plugin-list.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747

4848
- name: Create Pull Request
4949
id: pr
50-
uses: peter-evans/create-pull-request@8867c4aba1b742c39f8d0ba35429c2dfa4b6cb20
50+
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f
5151
with:
5252
commit-message: '[automated] Update plugin list'
5353
author: 'pytest bot <[email protected]>'

.pre-commit-config.yaml

+2-2
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.3"
3+
rev: "v0.6.8"
44
hooks:
55
- id: ruff
66
args: ["--fix"]
@@ -46,7 +46,7 @@ repos:
4646
# on <3.11
4747
- exceptiongroup>=1.0.0rc8
4848
- repo: https://github.com/tox-dev/pyproject-fmt
49-
rev: "2.2.1"
49+
rev: "2.2.4"
5050
hooks:
5151
- id: pyproject-fmt
5252
# https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ Paul Müller
328328
Paul Reece
329329
Pauli Virtanen
330330
Pavel Karateev
331+
Pavel Zhukov
331332
Paweł Adamczak
332333
Pedro Algarvio
333334
Petter Strandmark

changelog/12592.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed :class:`KeyError` crash when using ``--import-mode=importlib`` in a directory layout where a directory contains a child directory with the same name.

changelog/12765.feature.rst

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Thresholds to trigger snippet truncation can now be set with :confval:`truncation_limit_lines` and :confval:`truncation_limit_chars`.
2+
3+
See :ref:`truncation-params` for more information.

doc/en/how-to/capture-stdout-stderr.rst

+15-27
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ of the failing function and hide the other one:
106106
Accessing captured output from a test function
107107
---------------------------------------------------
108108

109-
The ``capsys``, ``capsysbinary``, ``capfd``, and ``capfdbinary`` fixtures
110-
allow access to stdout/stderr output created during test execution. Here is
111-
an example test function that performs some output related checks:
109+
The :fixture:`capsys`, :fixture:`capsysbinary`, :fixture:`capfd`, and :fixture:`capfdbinary` fixtures
110+
allow access to ``stdout``/``stderr`` output created during test execution.
111+
112+
Here is an example test function that performs some output related checks:
112113

113114
.. code-block:: python
114115
@@ -125,40 +126,27 @@ an example test function that performs some output related checks:
125126
The ``readouterr()`` call snapshots the output so far -
126127
and capturing will be continued. After the test
127128
function finishes the original streams will
128-
be restored. Using ``capsys`` this way frees your
129+
be restored. Using :fixture:`capsys` this way frees your
129130
test from having to care about setting/resetting
130131
output streams and also interacts well with pytest's
131132
own per-test capturing.
132133

133-
If you want to capture on filedescriptor level you can use
134-
the ``capfd`` fixture which offers the exact
135-
same interface but allows to also capture output from
136-
libraries or subprocesses that directly write to operating
137-
system level output streams (FD1 and FD2).
138-
139-
140-
141134
The return value from ``readouterr`` changed to a ``namedtuple`` with two attributes, ``out`` and ``err``.
142135

143-
144-
145-
If the code under test writes non-textual data, you can capture this using
146-
the ``capsysbinary`` fixture which instead returns ``bytes`` from
136+
If the code under test writes non-textual data (``bytes``), you can capture this using
137+
the :fixture:`capsysbinary` fixture which instead returns ``bytes`` from
147138
the ``readouterr`` method.
148139

140+
If you want to capture at the file descriptor level you can use
141+
the :fixture:`capfd` fixture which offers the exact
142+
same interface but allows to also capture output from
143+
libraries or subprocesses that directly write to operating
144+
system level output streams (FD1 and FD2). Similarly to :fixture:`capsysbinary`, :fixture:`capfdbinary` can be
145+
used to capture ``bytes`` at the file descriptor level.
149146

150147

151-
152-
If the code under test writes non-textual data, you can capture this using
153-
the ``capfdbinary`` fixture which instead returns ``bytes`` from
154-
the ``readouterr`` method. The ``capfdbinary`` fixture operates on the
155-
filedescriptor level.
156-
157-
158-
159-
160-
To temporarily disable capture within a test, both ``capsys``
161-
and ``capfd`` have a ``disabled()`` method that can be used
148+
To temporarily disable capture within a test, the capture fixtures
149+
have a ``disabled()`` method that can be used
162150
as a context manager, disabling capture inside the ``with`` block:
163151

164152
.. code-block:: python

doc/en/how-to/output.rst

+22
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,28 @@ captured output:
549549
By default, parametrized variants of skipped tests are grouped together if
550550
they share the same skip reason. You can use ``--no-fold-skipped`` to print each skipped test separately.
551551

552+
553+
.. _truncation-params:
554+
555+
Modifying truncation limits
556+
--------------------------------------------------
557+
558+
.. versionadded: 8.4
559+
560+
Default truncation limits are 8 lines or 640 characters, whichever comes first.
561+
To set custom truncation limits you can use following ``pytest.ini`` file options:
562+
563+
.. code-block:: ini
564+
565+
[pytest]
566+
truncation_limit_lines = 10
567+
truncation_limit_chars = 90
568+
569+
That will cause pytest to truncate the assertions to 10 lines or 90 characters, whichever comes first.
570+
571+
Setting both :confval:`truncation_limit_lines` and :confval:`truncation_limit_chars` to ``0`` will disable the truncation.
572+
However, setting only one of those values will disable one truncation mode, but will leave the other one intact.
573+
552574
Creating resultlog format files
553575
--------------------------------------------------
554576

0 commit comments

Comments
 (0)