Migrating to pytest 8.4.0
Version 8.4.0 introduces 4 breaking changes. This guide details how to update your code.
Released: 6/2/2025
⚠️ Check Your Code
If you use any of these symbols, you need to read this guide:
pytest.RaisesGrouppytest.RaisesExccapteesyspytest.mark.xfailcollect_imported_teststruncation_limit_linestruncation_limit_charsconsole_output_stylepytest.raiseshidden-param--disable-plugin-autoloadBreaking Changes
●Issue #1
Async tests now fail instead of warning+skipping when no suitable async plugin is installed; install an appropriate plugin or disable async tests to avoid failures.
●Issue #2
Test functions that return a value other than None now cause a failure; ensure test functions return None or remove return statements.
●Issue #3
Support for Python 3.8 has been removed; upgrade the interpreter to Python 3.9 or newer.
●Issue #4
Test functions containing a yield now raise an explicit error; rewrite yield‑based tests using standard parametrization or other mechanisms.
Migration Steps
- 1Install an async‑test plugin (e.g., pytest-asyncio) or remove async tests to avoid failures caused by the new async test handling.
- 2Remove any return statements from test functions or ensure they return None to comply with the new non‑None return failure rule.
- 3Rewrite or delete tests that use yield statements; they now raise an explicit error.
- 4If you rely on async fixtures without a pytest_fixture_setup hook, add the appropriate hook or adjust fixture definitions to silence the DeprecationWarning.
- 5Consider setting collect_imported_tests = false in your pytest.ini if you want to avoid collecting imported test classes/functions.
- 6Update any custom truncation logic to use the new truncation_limit_lines or truncation_limit_chars settings if needed.
- 7If you used the PYTEST_DISABLE_PLUGIN_AUTOLOAD environment variable, you can now replace it with the --disable-plugin-autoload flag or the corresponding addopts entry.
Release Summary
pytest 8.4.0 introduces significant breaking changes—removing Python 3.8 support, enforcing stricter test return values, and disallowing yield tests—while adding powerful new features like RaisesGroup, enhanced xfail handling, and configurable output options.
Need More Details?
View the full release notes and all changes for pytest 8.4.0.
View Full Changelog