Change8

Migrating to pytest 9.1.0

Version 9.1.0 introduces 1 breaking change. This guide details how to update your code.

Released: 6/13/2026

1
Breaking Changes
8
Migration Steps
15
Affected Symbols

⚠️ Check Your Code

If you use any of these symbols, you need to read this guide:

pytest.FixtureRequest.getfixturevalue@pytest.mark.parametrizepytest.Metafunc.parametrizeconfig.inicfgpytest.Config.getinipytest.FixtureDefpytest.deprecated_callpytest.raisespytest.warnspytest.fixturepytest.ScopeNameyield_fixturepytest.approxpytest.console_mainpytest.main

Breaking Changes

Issue #1

When using --doctest-modules, autouse fixtures with scope 'module', 'package', or 'session' defined inline in Python test modules (not plugins or conftests) may now execute twice. Move fixture definitions to a conftest.py file if this behavior is undesirable.

Migration Steps

  1. 1
    If autouse fixtures defined inline in test modules execute twice when using --doctest-modules, move the fixture definition to a conftest.py file.
  2. 2
    For class-scoped fixtures defined as instance methods, add the @classmethod decorator.
  3. 3
    When requesting fixtures during teardown, ensure the fixture was already requested during setup/execution, or prepare for an error in pytest 10.
  4. 4
    Use collections.abc.Collection iterables (like lists or tuples) for the argvalues parameter in @pytest.mark.parametrize.
  5. 5
    Access configuration values using config.getini() instead of config.inicfg.
  6. 6
    When registering fixtures, use the node parameter instead of baseid or nodeid.
  7. 7
    Use pytest.main() instead of pytest.console_main() for programmatic execution.
  8. 8
    If using the --pastebin option, switch to the external plugin 'pytest-pastebin'.

Release Summary

Pytest 9.1.0 introduces imperative fixture registration and new CLI options for reporting and warning limits. This release also contains several deprecations targeting internal APIs and older usage patterns, scheduled for removal in pytest 10.

Need More Details?

View the full release notes and all changes for pytest 9.1.0.

View Full Changelog