Change8

9.0.0

📦 pytestView on GitHub →
8 features🐛 6 fixes🔧 11 symbols

Summary

pytest 9.0.0 adds experimental subtests, native TOML config, a global strict mode, terminal progress reporting, and several new configuration options while improving performance and error messages.

Migration Steps

  1. Choose either native TOML `[tool.pytest]` or INI `[tool.pytest.ini_options]` configuration; do not use both in the same project.
  2. If you relied on the old `--strict` flag behavior, be aware it now enables strict mode; consider pinning pytest version or adjusting the `strict` setting.
  3. Update any custom plugins that call `Parser.addini` to use the new `aliases` parameter if you need alternative option names.
  4. If you need the previous automatic uniquification of parametrization IDs, either disable `strict_parametrization_ids` or adjust your test IDs accordingly.
  5. Note that `--junitxml` output summary is suppressed when `--quiet`; remove `--quiet` if you still need the summary.
  6. If you want faulthandler to abort the pytest process on timeout, set `faulthandler_exit_on_timeout = true` in your config.

✨ New Features

  • Support for subtests via the experimental `subtests` fixture and `unittest.TestCase.subTest` (see issue #1367).
  • Native TOML configuration files are now supported (`pyproject.toml` under `[tool.pytest]` or `pytest.toml`/`.pytest.toml` under `[pytest]`).
  • A new "strict mode" can be enabled with the `strict` configuration option or the previously‑deprecated `--strict` flag, activating several strictness checks.
  • Added `strict_parametrization_ids` configuration option to enforce unique parametrization IDs.
  • Terminal progress display using the OSC 9;4; ANSI sequence, automatically enabled in supported TTYs and disableable with `-p no:terminalprogress`.
  • PEP420 implicit namespace packages are now accepted as `--pyargs` targets when `consider_namespace_packages` is true.
  • New `faulthandler_exit_on_timeout` configuration option (default false) to let faulthandler interrupt the pytest process on timeout.
  • Configuration option aliases can be registered via the `aliases` parameter of `Parser.addini()`.

🐛 Bug Fixes

  • Warning emitted when pytest configuration is spread over multiple files, clarifying which file is used.
  • `--version` now runs without loading the full plugin infrastructure, making the command faster; double `--version` still shows plugin info.
  • Added aliases `strict_xfail`, `strict_config`, and `strict_markers` for consistency with other strict options.
  • `--junitxml` no longer prints the generated XML summary when `--quiet` is used.
  • Filtering warnings now only logs a message if a referenced class cannot be imported, instead of failing the test run.
  • Error message for `pytest.raises()` regex mismatches has been clarified.

🔧 Affected Symbols

pytest.Subtestspytest.Parser.addinistrict (config option)strict_parametrization_idsstrict_xfailstrict_configstrict_markersfaulthandler_exit_on_timeoutterminalprogress pluginconsider_namespace_packagespytest.raises