# pytest 8.4.0 - Product: pytest (https://whatsnew.fyi/product/pytest) - Vendor: pytest - Date: 2025-06-02 - Version: 8.4.0 - Original notes: https://github.com/pytest-dev/pytest/releases/tag/8.4.0 - Permalink: https://whatsnew.fyi/product/pytest/releases/8.4.0 What's New is an index, not a publisher: every entry below links to the vendor's own release notes, which are the authoritative source. Entries are labelled where they are hand-curated sample data, pre-releases, or drawn from a secondary source such as a developer blog. Reuse: release facts (products, versions, dates, links, CVE ids and flags) are open data under CC BY 4.0, from the API at https://whatsnew.fyi/api/v1 or the nightly dataset at https://github.com/whatsnew-fyi/dataset. The summaries, labels and curation are © What's New: quote freely with attribution and a link back; wholesale republication of them is not permitted — terms: https://whatsnew.fyi/terms. The vendors' own release notes remain their publishers'. --- Changes to check: - **Behavior changed:** `async tests` (from the vendor's breaking-changes section) - **Behavior changed:** `Tests will now fail` (from the vendor's breaking-changes section) - **Requirement raised:** `Python 3.8` → `3.9` (from the vendor's breaking-changes section) - **Behavior changed:** `Test functions containing a yield` (from the vendor's breaking-changes section) - **Deprecated:** `pytest_fixture_setup` (from the vendor's deprecations section) - **Behavior changed:** `pytest.mark.usefixtures` (inferred by a model) - **Requirement raised:** `pygments` → `required` (inferred by a model) - **Behavior changed:** `xfail reason prefix` (inferred by a model) - **removed** — Async tests will now fail instead of warning and skipping if you don't have any suitable plugin installed - **removed** — Tests will now fail instead of raising a warning if they return any value other than None - **removed** — Dropped support for Python 3.8 following its end of life - **removed** — Test functions containing a yield now cause an explicit error instead of being marked as expected failure - **deprecated** — Requesting an asynchronous fixture without a pytest_fixture_setup hook that resolves it will now give a DeprecationWarning - **added** — Added pytest.RaisesGroup as an equivalent to pytest.raises for expecting ExceptionGroup - **added** — Added pytest.RaisesExc which is the logic behind pytest.raises and can be used as parameter to pytest.RaisesGroup - **added** — Added capteesys fixture to capture and pass output to next handler set by --capture= - **changed** — pytest.mark.xfail now accepts pytest.RaisesGroup for the raises parameter when you expect an exception group - **added** — Added --force-short-summary option to force condensed summary output regardless of verbosity level - **added** — Added collect_imported_tests configuration option to prevent collecting imported classes and functions from test files - **added** — Added truncation_limit_lines and truncation_limit_chars configuration options to set thresholds for snippet truncation - **changed** — console_output_style now supports times to show execution time of each test - **changed** — pytest.raises will now raise a warning when passing an empty string to match - **changed** — pytest.raises will now print a helpful string diff if matching fails and the match parameter has ^ and $ and is otherwise escaped - **added** — Added check parameter to pytest.raises that accepts a function which takes a raised exception and returns a boolean - **added** — hidden-param can now be used in id of pytest.param #### pytest 8.4.0 (2025-06-02) ##### Removals and backward incompatible breaking changes - [#11372](https://github.com/pytest-dev/pytest/issues/11372): Async tests will now fail, instead of warning+skipping, if you don\'t have any suitable plugin installed. - [#12346](https://github.com/pytest-dev/pytest/issues/12346): Tests will now fail, instead of raising a warning, if they return any value other than None. - [#12874](https://github.com/pytest-dev/pytest/issues/12874): We dropped support for Python 3.8 following its end of life (2024-10-07). - [#12960](https://github.com/pytest-dev/pytest/issues/12960): Test functions containing a yield now cause an explicit error. They have not been run since pytest 4.0, and were previously marked as an expected failure and deprecation warning. See `the docs `{.interpreted-text role="ref"} for more information. ##### Deprecations (removal in next major release) - [#10839](https://github.com/pytest-dev/pytest/issues/10839): Requesting an asynchronous fixture without a [pytest_fixture_setup]{.title-ref} hook that resolves it will now give a DeprecationWarning. This most commonly happens if a sync test requests an async fixture. This should have no effect on a majority of users with async tests or fixtures using async pytest plugins, but may affect non-standard hook setups or `autouse=True`. For guidance on how to work around this warning see `sync-test-async-fixture`{.interpreted-text role="ref"}. ##### New features - [#11538](https://github.com/pytest-dev/pytest/issues/11538): Added `pytest.RaisesGroup`{.interpreted-text role="class"} as an equivalent to `pytest.raises`{.interpreted-text role="func"} for expecting `ExceptionGroup`{.interpreted-text role="exc"}. Also adds `pytest.RaisesExc`{.interpreted-text role="class"} which is now the logic behind `pytest.raises`{.interpreted-text role="func"} and used as parameter to `pytest.RaisesGroup`{.interpreted-text role="class"}. `RaisesGroup` includes the ability to specify multiple different expected exceptions, the structure of nested exception groups, and flags for emulating `except* `{.interpreted-text role="ref"}. See `assert-matching-exception-groups`{.interpreted-text role="ref"} and docstrings for more information. - [#12081](https://github.com/pytest-dev/pytest/issues/12081): Added `capteesys`{.interpreted-text role="fixture"} to capture AND pass output to next handler set by `--capture=`. - [#12504](https://github.com/pytest-dev/pytest/issues/12504): `pytest.mark.xfail`{.interpreted-text role="func"} now accepts `pytest.RaisesGroup`{.interpreted-text role="class"} for the `raises` parameter when you expect an exception group. You can also pass a `pytest.RaisesExc`{.interpreted-text role="class"} if you e.g. want to make use of the `check` parameter. - [#12713](https://github.com/pytest-dev/pytest/issues/12713): New [\--force-short-summary]{.title-ref} option to force condensed summary output regardless of verbosity level. This lets users still see condensed summary output of failures for quick reference in log files from job outputs, being especially useful if non-condensed output is very verbose. - [#12749](https://github.com/pytest-dev/pytest/issues/12749): pytest traditionally collects classes/functions in the test module namespace even if they are imported from another file. For example: ``` python # contents of src/domain.py class Testament: ... # contents of tests/test_testament.py from domain import Testament def test_testament(): ... ``` In this scenario with the default options, pytest will collect the class [Testament]{.title-ref} from [tests/test_testament.py]{.title-ref} because it starts with [Test]{.title-ref}, even though in this case it is a production class being imported in the test module namespace. This behavior can now be prevented by setting the new `collect_imported_tests`{.interpreted-t _[Truncated at 4000 characters — full notes: https://github.com/pytest-dev/pytest/releases/tag/8.4.0]_