unstale

pypi / pytest

pytest

What changed in pytest 8 to 9, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.

28 breaking1 security17 deprecations19 new APIs and options3 performance22 behavior and defaults2 tooling45 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

pytest 9135 changes

Breaking changes 28

  • A nonexistent path, directory, or unsupported format now produces a usage error instead of being ignored or causing an unhandled FileNotFoundError.

    9.2.0release notes

  • TOML files passed via -c now read configuration from [pytest]; existing [tool.pytest] and [tool.pytest.ini_options] styles remain supported, but mixing styles is an error.

    9.2.0release notes

  • Cache keys resolving outside the cache directory are rejected.

    9.2.0release notes

  • A registered option whose configured value does not match its type now raises UsageError rather than TypeError or ValueError.

    9.2.0release notes

  • An implicit destination that conflicts with an existing option now produces a clear error instead of silently overriding it.

    9.2.0release notes

  • Tests are reordered by parameter value rather than index, grouping equal values to share fixture setup; test order may change and unhashable values retain index-based grouping.

    9.2.0release notes

  • Accepted values are registered; invalid values now produce a usage error, and pytest --help lists accepted values.

    9.2.0release notes

  • Invalid values are now reported as a usage error.

    9.2.0release notes

  • The indirect, ids, and scope arguments are now keyword-only; positional use fails with a TypeError.

    9.2.0release notes

  • The flag suppresses only pytest's own summary and no longer skips the pytest_terminal_summary hook, allowing plugins to write summaries.

    9.2.0release notes

  • The method now stores a Mark in node.keywords, matching marks applied during collection, rather than storing a MarkDecorator.

    9.2.0release notes

  • pluggy>=1.6 is now required; older versions could leave the logging plugin's wrapper suspended and cause a subsequent test's caplog to see no records.

    9.2.0release notes

  • Infinite relative tolerances for datetime.timedelta values now raise a clear ValueError instead of OverflowError.

    9.2.0release notes

  • Nested containers of any type now raise TypeError rather than being accepted and silently compared without applying tolerance.

    9.2.0release notes

  • Plugin import failures are classified as usage or internal errors, and pytest.main returns the corresponding exit codes instead of raising ImportError.

    9.2.0release notes

  • Top-level options now raise an error when no [pytest] table is present instead of being silently ignored.

    9.2.0release notes

  • Unmatched warnings are no longer re-emitted with module="warnings", so module-based warning filters are applied using the warning filename.

    9.2.0release notes

  • Building pytest from a git checkout now requires setuptools-scm >= 10.1.

    9.2.0release notes

  • Autouse fixtures with module, package, or session scope defined inline in Python test modules may execute twice when doctest modules are enabled.

    9.1.0release notes

  • Fixture overrides are resolved first by visibility in the collection tree, so a more specific node takes precedence over a more general node regardless of registration order.

    9.1.0release notes

  • Unraisable exceptions from finalizers are collected during pytest_unconfigure before session warning filters are torn down, so matching error filters promote them to failures regardless of plugin cleanup order.

    9.1.0release notes

  • It is no longer considered an interactive exception, so pytest_exception_interact is no longer called for it.

    9.1.0release notes

  • Disallows blocking a conftest.py file and raises a clear UsageError explaining that conftest files are not plugins and cannot be disabled via -p.

    9.0.3release notes

  • CI mode is activated only when CI or BUILD_NUMBER is defined and has a non-empty value.

    9.0.0release notes

  • A file argument with parametrization syntax is now reported as a usage error instead of silently being treated as the file path.

    9.0.0release notes

  • Warnings of this type now raise errors by default; affected features are slated for removal in pytest 9.1.

    9.0.0release notes

  • pytest no longer supports Python 3.9.

    9.0.0release notes

  • A single --version no longer loads the plugin infrastructure; passing it twice retains the behavior of showing pytest and plugin information. It only works when passed directly on the command line.

    9.0.0release notes

Security 1

Deprecations 17

  • The private name has been renamed to CallSpec; the old alias remains temporarily and is scheduled for removal in pytest 10 or 11.

    9.2.0release notes

  • Module-, package-, and session-scoped fixtures defined as instance methods are deprecated.

    9.2.0release notes

  • Pytest warns when a decorator prevents correct fixture discovery, including classmethod or staticmethod above pytest.fixture.

    9.2.0release notes

  • Passing a non-string value to a string-typed ini option in pyproject.toml now warns; pytest 10 will raise TypeError.

    9.2.0release notes

  • Passing bytes is deprecated; pass a str instead.

    9.2.0release notes

  • The yield_fixture decorator is scheduled for removal in pytest 10 or 11.

    9.2.0release notes

  • Class-scoped fixtures defined as instance methods without @classmethod now emit a deprecation warning; use @classmethod instead.

    9.1.0release notes

  • The private config.inicfg attribute is deprecated; use config.getini() to access configuration values.

    9.1.0release notes

  • Passing nodeid strings to fixture registration APIs is deprecated; use the node parameter for fixture scoping.

    9.1.0release notes

  • Passing baseid to FixtureDef is deprecated; use the node parameter for fixture scoping.

    9.1.0release notes

  • The private FixtureDef.has_location attribute is deprecated and will be removed in pytest 10.

    9.1.0release notes

  • Configuring hooks using markers, deprecated since pytest 7.2, is now scheduled for removal in pytest 10.

    9.1.0release notes

  • The option is deprecated; the same functionality is available in the external pytest-pastebin plugin.

    9.1.0release notes

  • This function is deprecated and will be removed in pytest 10; use pytest.main instead.

    9.1.0release notes

  • Type checkers now recognize yield_fixture as deprecated through the deprecated decorator.

    9.1.0release notes

  • The attribute will be deprecated in pytest 9.1 and removed in pytest 10.

    9.0.2release notes

  • Prints a warning when configuration is spread over more than one file, clarifying that only one is used.

    9.0.0release notes

New APIs and options 19

  • Controls handling of long str and bytes values in generated test IDs; supports short, sha256, legacy, and disallow strategies.

    9.2.0release notes

  • Exposed as the return type of pytest.approx for type annotations and isinstance checks.

    9.2.0release notes

  • Exposed as the return type of pytest.param for type annotations and isinstance checks.

    9.2.0release notes

  • Adds a setting to render string equality failures as separate Left: and Right: blocks instead of ndiff output.

    9.1.0release notes

  • Adds a command-line threshold that fails the test run when the number of warnings exceeds the given value.

    9.1.0release notes

  • Adds a configuration threshold that fails the test run when the number of warnings exceeds the given value.

    9.1.0release notes

  • Supports comparisons with datetime and timedelta; datetime comparisons require an explicit absolute or relative tolerance as a timedelta, and relative tolerance is unsupported.

    9.1.0release notes

  • Adds an imperative interface for registering fixtures, intended for plugins where declarative registration is cumbersome or unviable.

    9.1.0release notes

  • The callable overload uses ParamSpec instead of Any for type hints, and func can now be passed as a keyword argument.

    9.1.0release notes

  • Adds pytest.toml as a separate native TOML configuration file.

    9.0.0release notes

  • Adds .pytest.toml as a separate native TOML configuration file.

    9.0.0release notes

  • Adds a configuration option that enables strict_config, strict_markers, strict_parametrization_ids, and strict_xfail; individual options can override it.

    9.0.0release notes

  • Adds strict_config as a configuration option alias for the --strict-config flag.

    9.0.0release notes

  • Adds strict_markers as a configuration option alias for the --strict-markers flag.

    9.0.0release notes

  • When enabled, emits an error for non-unique parameter set IDs instead of automatically making them unique.

    9.0.0release notes

  • Adds strict_xfail as an alias to xfail_strict.

    9.0.0release notes

  • Adds subtests as an alternative to parametrization when values are not all known at collection time; failures are reported individually. The feature is experimental.

    9.0.0release notes

  • Adds native TOML configuration in the [tool.pytest] table of pyproject.toml; it cannot be used alongside [tool.pytest.ini_options].

    9.0.0release notes

  • pytest now supports unittest subTest.

    9.0.0release notes

Performance 3

  • Default fd-level output capturing skips reading the capture buffer for tests that produce no output, reducing per-test overhead.

    9.2.0release notes

  • Temporary directory allocation no longer lists the whole base directory on each call; per-prefix counters skip names that already exist.

    9.2.0release notes

  • Quadratic-time behavior when handling unittest subtests in Python 3.10 was fixed.

    9.0.2release notes

Behavior and default changes 22

  • Large diffs are built lazily and capped to the truncation budget; the truncation footer no longer gives the exact number of hidden lines.

    9.2.0release notes

  • Assertion diffs for dict.items() and dict.keys() comparisons now identify missing items, as set comparisons do.

    9.2.0release notes

  • RecursionError tracebacks whose origin cannot be located show only the first and last 10 frames by default; this flag shows every frame.

    9.2.0release notes

  • The option now accepts native integer and boolean values in TOML configuration files while continuing to accept strings.

    9.2.0release notes

  • The default argument now accepts a MarkDecorator and returns its wrapped Mark.

    9.2.0release notes

  • The type argument now accepts Python type expressions, string Literals, and unions, in addition to existing string tags.

    9.2.0release notes

  • Warnings emitted while importing plugins through -p, PYTEST_PLUGINS, or entry point autoloading are captured, filtered, and reported like other warnings.

    9.2.0release notes

  • Cached rewritten modules are invalidated using a source hash and checked-hash pyc format rather than modification times, allowing caches to survive fresh checkout timestamps.

    9.2.0release notes

  • The variable now accepts installed plugin entry point names as well as importable module names.

    9.2.0release notes

  • The environment variable now accepts installed plugin entry point names as well as importable module names.

    9.2.0release notes

  • A warning is emitted when a float tolerance cannot be represented exactly for a Decimal comparison.

    9.2.0release notes

  • When strict_markers is enabled, marker names in -m expressions are validated against registered markers.

    9.2.0release notes

  • The option now accepts native integer values in TOML configuration files while continuing to accept strings.

    9.2.0release notes

  • Pytest no longer formats tracebacks for tests marked xfail(run=False).

    9.2.0release notes

  • Help and error messages identify pytest, python -m pytest, or pytest.main() according to how pytest was invoked.

    9.1.0release notes

  • Output excludes internal-implementation fixtures generated by @pytest.mark.parametrize and similar.

    9.1.0release notes

  • When warnings were emitted but the match pattern did not match, the message now says “Regex pattern did not match” instead of “DID NOT WARN”.

    9.1.0release notes

  • A PytestCollectionWarning is emitted when module-level __getattr__ returns None for pytestmark; collection then continues normally.

    9.1.0release notes

  • Output now prints a space after the test name and any listed fixtures to separate them from the test result.

    9.1.0release notes

  • The default number of gc.collect() passes is reduced from five to one on CPython; PyPy retains five passes.

    9.1.0release notes

  • Terminal progress is disabled by default except on Windows; enable it with -p terminalprogress.

    9.0.2release notes

  • The previously-deprecated flag now enables strict mode.

    9.0.0release notes

Tooling 2

  • Assertion diffs for dict.items() and dict.keys() comparisons now identify missing items, as set comparisons do.

    9.2.0release notes

  • GitHub source archives of arbitrary commits can now build into an sdist or wheel with a correct version; the file carries the describe output needed by setuptools-scm.

    9.2.0release notes

Fixes and other changes 43

  • Walrus expressions are no longer evaluated more than once during rewriting, preserving Python's left-to-right evaluation and reported values.

    9.2.0release notes

  • Glob matches outside the cache directory are ignored.

    9.2.0release notes

  • With the times style, durations just below a unit boundary are displayed in the next unit.

    9.2.0release notes

  • tryshort=True now strips the AssertionError prefix for failed assert statements in ExceptionInfo objects created by pytest.raises.

    9.2.0release notes

  • Fixture argument discovery is fixed for custom collectors that pass bound methods to pytest.Function.

    9.2.0release notes

  • Failure and error element message attributes are shortened to whole lines within 500 characters, with a note pointing to the full report in the element text.

    9.2.0release notes

  • The option no longer matches incidental attributes in a test function's __dict__ that are not intended as keywords.

    9.2.0release notes

  • Mapping diff key matching follows the mappings' own key equivalence, avoiding false missing-key reports for mappings such as case-insensitive header mappings.

    9.2.0release notes

  • Undoing a patch to an inherited instance attribute no longer creates an instance dictionary entry that shadows the class attribute.

    9.2.0release notes

  • A non-sequence parameter set now produces a clear collection error instead of crashing.

    9.2.0release notes

  • Cache writes now emit this warning when writing or closing the cache file fails.

    9.2.0release notes

  • The root directory is no longer derived from a configuration file that is not a regular file.

    9.2.0release notes

  • Restored loading files under <invocation dir>/test* as initial conftests when pytest is invoked without arguments, so hooks in those files can run.

    9.1.1release notes

  • Fixed mypy list-item typing errors for the argvalues parameter.

    9.1.1release notes

  • Fixed incorrect match messages that could pair an exception with the wrong error.

    9.1.1release notes

  • Logging capture now works for non-propagating loggers, not only logs that reach the root logger.

    9.1.0release notes

  • Fixes doubled output when capteesys is used with --capture=no (-s).

    9.1.0release notes

  • Fixes duplicated -W option values in Config.known_args_namespace.

    9.1.0release notes

  • Fixture values are released more promptly when a test is interrupted by KeyboardInterrupt or early exit.

    9.1.0release notes

  • High Unicode supplementary-plane characters, such as emoji, are no longer incorrectly escaped in test failure messages.

    9.1.0release notes

  • An exception from this hook no longer prevents fixtures from being torn down, avoiding additional errors in following tests.

    9.1.0release notes

  • Recognizes types with __array_interface__ as numpy-like arrays.

    9.1.0release notes

  • A trailing-comma single argument name such as "arg," now unpacks single-element tuple values like ("arg",).

    9.1.0release notes

  • The callable overload uses ParamSpec instead of Any for type hints, and func can now be passed as a keyword argument.

    9.1.0release notes

  • Assertion verbosity is propagated so the -v hint in match-diff output works.

    9.1.0release notes

  • Adds official support for Python 3.15.

    9.1.0release notes

  • Fixes a regression where --strict-config specified through addopts was silently ignored.

    9.1.0release notes

  • Fixes a regression where --strict-markers specified through addopts was silently ignored.

    9.1.0release notes

  • Autouse fixtures defined inside a skipped or skipIf-decorated test case no longer run.

    9.1.0release notes

  • The short form of --version now displays the current version correctly.

    9.1.0release notes

  • Correctly takes mapping key order into account when comparing mappings.

    9.0.3release notes

  • Fixes a crash when a test raises an exception group with __tracebackhide__ = True.

    9.0.3release notes

  • Non-string messages passed to subTest() are now printed.

    9.0.3release notes

  • The private attribute is restored to working order with a compatibility shim after a breaking change in pytest 9.0.0.

    9.0.2release notes

  • When TERM is dumb, pytest no longer emits escape codes, even if the terminal progress plugin is enabled.

    9.0.2release notes

  • Fixes a UserWarning on some earlier Python 3.12 and 3.13 point versions.

    9.0.1release notes

  • The plugin is automatically disabled when iTerm2 is detected because it generated desktop notifications instead of the desired functionality.

    9.0.1release notes

  • Raising unittest.SkipTest once again skips tests.

    9.0.1release notes

  • Fixes teardown handling for an ExceptionGroup containing only skipped exceptions, which previously appeared as an error.

    9.0.0release notes

  • Improves assertion and error messages when comparing mappings with differing lengths or keys.

    9.0.0release notes

  • Hidden .pytest.ini files are now selected as the configuration file even when empty.

    9.0.0release notes

  • Type annotations for pytest.skip and related functions are more spec-compliant to work across more type checkers.

    9.0.0release notes

  • A filter referencing a class that cannot be imported now produces a message instead of failing.

    9.0.0release notes

pytest 82 changes

Fixes and other changes 2

  • Avoids microseconds exceeding 1_000_000 when the date format uses the %f specifier, preventing the test suite from crashing.

    8.0.0release notes

  • The reason of a skip mark is now properly escaped when writing JUnit XML files.

    8.0.0release notes