Skip to content

Commit

Permalink
Merge branch 'main' into no-cache-fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
niroshaimos committed Oct 3, 2024
2 parents 27f442d + 7add2af commit 87569cd
Show file tree
Hide file tree
Showing 19 changed files with 607 additions and 228 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
persist-credentials: false

- name: Build and Check Package
uses: hynek/build-and-inspect-python-package@v2.8.0
uses: hynek/build-and-inspect-python-package@v2.9.0
with:
attest-build-provenance-github: 'true'

Expand All @@ -54,7 +54,7 @@ jobs:
path: dist

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@v1.10.1
uses: pypa/gh-action-pypi-publish@v1.10.2
with:
attestations: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
fetch-depth: 0
persist-credentials: false
- name: Build and Check Package
uses: hynek/build-and-inspect-python-package@v2.8.0
uses: hynek/build-and-inspect-python-package@v2.9.0

build:
needs: [package]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-plugin-list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- name: Create Pull Request
id: pr
uses: peter-evans/create-pull-request@8867c4aba1b742c39f8d0ba35429c2dfa4b6cb20
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f
with:
commit-message: '[automated] Update plugin list'
author: 'pytest bot <pytestbot@users.noreply.github.com>'
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.3"
rev: "v0.6.8"
hooks:
- id: ruff
args: ["--fix"]
Expand Down Expand Up @@ -46,7 +46,7 @@ repos:
# on <3.11
- exceptiongroup>=1.0.0rc8
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.2.1"
rev: "2.2.4"
hooks:
- id: pyproject-fmt
# https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ Paul Müller
Paul Reece
Pauli Virtanen
Pavel Karateev
Pavel Zhukov
Paweł Adamczak
Pedro Algarvio
Petter Strandmark
Expand Down
1 change: 1 addition & 0 deletions changelog/12592.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +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.
3 changes: 3 additions & 0 deletions changelog/12765.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Thresholds to trigger snippet truncation can now be set with :confval:`truncation_limit_lines` and :confval:`truncation_limit_chars`.

See :ref:`truncation-params` for more information.
42 changes: 15 additions & 27 deletions doc/en/how-to/capture-stdout-stderr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ of the failing function and hide the other one:
Accessing captured output from a test function
---------------------------------------------------

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

Here is an example test function that performs some output related checks:

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

If you want to capture on filedescriptor level you can use
the ``capfd`` fixture which offers the exact
same interface but allows to also capture output from
libraries or subprocesses that directly write to operating
system level output streams (FD1 and FD2).



The return value from ``readouterr`` changed to a ``namedtuple`` with two attributes, ``out`` and ``err``.



If the code under test writes non-textual data, you can capture this using
the ``capsysbinary`` fixture which instead returns ``bytes`` from
If the code under test writes non-textual data (``bytes``), you can capture this using
the :fixture:`capsysbinary` fixture which instead returns ``bytes`` from
the ``readouterr`` method.

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



If the code under test writes non-textual data, you can capture this using
the ``capfdbinary`` fixture which instead returns ``bytes`` from
the ``readouterr`` method. The ``capfdbinary`` fixture operates on the
filedescriptor level.




To temporarily disable capture within a test, both ``capsys``
and ``capfd`` have a ``disabled()`` method that can be used
To temporarily disable capture within a test, the capture fixtures
have a ``disabled()`` method that can be used
as a context manager, disabling capture inside the ``with`` block:

.. code-block:: python
Expand Down
22 changes: 22 additions & 0 deletions doc/en/how-to/output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,28 @@ captured output:
By default, parametrized variants of skipped tests are grouped together if
they share the same skip reason. You can use ``--no-fold-skipped`` to print each skipped test separately.


.. _truncation-params:

Modifying truncation limits
--------------------------------------------------

.. versionadded: 8.4
Default truncation limits are 8 lines or 640 characters, whichever comes first.
To set custom truncation limits you can use following ``pytest.ini`` file options:

.. code-block:: ini
[pytest]
truncation_limit_lines = 10
truncation_limit_chars = 90
That will cause pytest to truncate the assertions to 10 lines or 90 characters, whichever comes first.

Setting both :confval:`truncation_limit_lines` and :confval:`truncation_limit_chars` to ``0`` will disable the truncation.
However, setting only one of those values will disable one truncation mode, but will leave the other one intact.

Creating resultlog format files
--------------------------------------------------

Expand Down
Loading

0 comments on commit 87569cd

Please sign in to comment.