From b2522cf0b11fb33ecc1f4895fa1dffbb9252a63d Mon Sep 17 00:00:00 2001 From: pytest bot Date: Sat, 13 Jun 2026 18:14:53 +0000 Subject: [PATCH] Prepare release version 9.1.0 --- changelog/10819.deprecation.rst | 3 - changelog/11022.doc.rst | 1 - changelog/11225.improvement.rst | 1 - changelog/11295.improvement.rst | 1 - changelog/11307.doc.rst | 1 - changelog/12376.feature.rst | 7 - changelog/12882.deprecation.rst | 3 - changelog/13038.doc.rst | 1 - changelog/13155.doc.rst | 1 - changelog/13192.bugfix.rst | 1 - changelog/13241.improvement.rst | 2 - changelog/13304.doc.rst | 1 - changelog/13409.deprecation.rst | 8 - changelog/13484.bugfix.rst | 1 - changelog/13626.bugfix.rst | 2 - changelog/13784.bugfix.rst | 1 - changelog/13817.bugfix.rst | 1 - changelog/13862.improvement.rst | 1 - changelog/13884.bugfix.rst | 1 - changelog/13885.bugfix.rst | 1 - changelog/13902.doc.rst | 1 - changelog/13917.bugfix.rst | 1 - changelog/13946.deprecation.rst | 4 - changelog/13963.bugfix.rst | 3 - changelog/14004.bugfix.rst | 6 - changelog/14004.deprecation.rst | 7 - changelog/14012.doc.rst | 1 - changelog/14023.feature.rst | 1 - changelog/14026.improvement.rst | 1 - changelog/14050.bugfix.rst | 1 - changelog/14080.bugfix.rst | 1 - changelog/14114.bugfix.rst | 1 - changelog/14137.improvement.rst | 1 - changelog/14148.doc.rst | 2 - changelog/14161.bugfix.rst | 1 - changelog/14214.bugfix.rst | 1 - changelog/14234.bugfix.rst | 1 - changelog/14248.bugfix.rst | 1 - changelog/14263.bugfix.rst | 1 - changelog/14303.doc.rst | 1 - changelog/14335.deprecation.rst | 2 - changelog/14342.improvement.rst | 2 - changelog/14371.feature.rst | 1 - changelog/14373.improvement.rst | 1 - changelog/14377.bugfix.rst | 1 - changelog/14381.bugfix.rst | 1 - changelog/14389.bugfix.rst | 1 - changelog/14392.bugfix.rst | 1 - changelog/14430.improvement.rst | 1 - changelog/14434.deprecation.rst | 3 - changelog/14441.improvement.rst | 1 - changelog/14442.bugfix.rst | 3 - changelog/14456.bugfix.rst | 1 - changelog/14461.improvement.rst | 1 - changelog/14465.doc.rst | 1 - changelog/14474.bugfix.rst | 1 - changelog/14483.bugfix.rst | 1 - changelog/14492.bugfix.rst | 1 - changelog/14513.deprecation.rst | 2 - changelog/14513.improvement.rst | 5 - changelog/14524.improvement.rst | 1 - changelog/14533.breaking.rst | 8 - changelog/14582.misc.rst | 1 - changelog/1764.deprecation.rst | 2 - changelog/1764.improvement.rst | 1 - changelog/3697.bugfix.rst | 3 - changelog/3850.bugfix.rst | 1 - changelog/5848.bugfix.rst | 1 - changelog/6757.feature.rst | 3 - changelog/719.bugfix.rst | 3 - changelog/8265.improvement.rst | 4 - changelog/8395.feature.rst | 1 - doc/en/announce/index.rst | 1 + doc/en/announce/release-9.1.0.rst | 98 +++++++++ doc/en/builtin.rst | 34 +-- doc/en/changelog.rst | 310 ++++++++++++++++++++++++++++ doc/en/example/parametrize.rst | 6 +- doc/en/example/pythoncollection.rst | 4 +- doc/en/example/reportingdemo.rst | 20 +- doc/en/getting-started.rst | 2 +- doc/en/how-to/cache.rst | 4 +- doc/en/how-to/fixtures.rst | 2 +- doc/en/reference/reference.rst | 14 +- 83 files changed, 454 insertions(+), 177 deletions(-) delete mode 100644 changelog/10819.deprecation.rst delete mode 100644 changelog/11022.doc.rst delete mode 100644 changelog/11225.improvement.rst delete mode 100644 changelog/11295.improvement.rst delete mode 100644 changelog/11307.doc.rst delete mode 100644 changelog/12376.feature.rst delete mode 100644 changelog/12882.deprecation.rst delete mode 100644 changelog/13038.doc.rst delete mode 100644 changelog/13155.doc.rst delete mode 100644 changelog/13192.bugfix.rst delete mode 100644 changelog/13241.improvement.rst delete mode 100644 changelog/13304.doc.rst delete mode 100644 changelog/13409.deprecation.rst delete mode 100644 changelog/13484.bugfix.rst delete mode 100644 changelog/13626.bugfix.rst delete mode 100644 changelog/13784.bugfix.rst delete mode 100644 changelog/13817.bugfix.rst delete mode 100644 changelog/13862.improvement.rst delete mode 100644 changelog/13884.bugfix.rst delete mode 100644 changelog/13885.bugfix.rst delete mode 100644 changelog/13902.doc.rst delete mode 100644 changelog/13917.bugfix.rst delete mode 100644 changelog/13946.deprecation.rst delete mode 100644 changelog/13963.bugfix.rst delete mode 100644 changelog/14004.bugfix.rst delete mode 100644 changelog/14004.deprecation.rst delete mode 100644 changelog/14012.doc.rst delete mode 100644 changelog/14023.feature.rst delete mode 100644 changelog/14026.improvement.rst delete mode 100644 changelog/14050.bugfix.rst delete mode 100644 changelog/14080.bugfix.rst delete mode 100644 changelog/14114.bugfix.rst delete mode 100644 changelog/14137.improvement.rst delete mode 100644 changelog/14148.doc.rst delete mode 100644 changelog/14161.bugfix.rst delete mode 100644 changelog/14214.bugfix.rst delete mode 100644 changelog/14234.bugfix.rst delete mode 100644 changelog/14248.bugfix.rst delete mode 100644 changelog/14263.bugfix.rst delete mode 100644 changelog/14303.doc.rst delete mode 100644 changelog/14335.deprecation.rst delete mode 100644 changelog/14342.improvement.rst delete mode 100644 changelog/14371.feature.rst delete mode 100644 changelog/14373.improvement.rst delete mode 100644 changelog/14377.bugfix.rst delete mode 100644 changelog/14381.bugfix.rst delete mode 100644 changelog/14389.bugfix.rst delete mode 100644 changelog/14392.bugfix.rst delete mode 100644 changelog/14430.improvement.rst delete mode 100644 changelog/14434.deprecation.rst delete mode 100644 changelog/14441.improvement.rst delete mode 100644 changelog/14442.bugfix.rst delete mode 100644 changelog/14456.bugfix.rst delete mode 100644 changelog/14461.improvement.rst delete mode 100644 changelog/14465.doc.rst delete mode 100644 changelog/14474.bugfix.rst delete mode 100644 changelog/14483.bugfix.rst delete mode 100644 changelog/14492.bugfix.rst delete mode 100644 changelog/14513.deprecation.rst delete mode 100644 changelog/14513.improvement.rst delete mode 100644 changelog/14524.improvement.rst delete mode 100644 changelog/14533.breaking.rst delete mode 100644 changelog/14582.misc.rst delete mode 100644 changelog/1764.deprecation.rst delete mode 100644 changelog/1764.improvement.rst delete mode 100644 changelog/3697.bugfix.rst delete mode 100644 changelog/3850.bugfix.rst delete mode 100644 changelog/5848.bugfix.rst delete mode 100644 changelog/6757.feature.rst delete mode 100644 changelog/719.bugfix.rst delete mode 100644 changelog/8265.improvement.rst delete mode 100644 changelog/8395.feature.rst create mode 100644 doc/en/announce/release-9.1.0.rst diff --git a/changelog/10819.deprecation.rst b/changelog/10819.deprecation.rst deleted file mode 100644 index ebb306379b7..00000000000 --- a/changelog/10819.deprecation.rst +++ /dev/null @@ -1,3 +0,0 @@ -Added a deprecation warning for class-scoped fixtures defined as instance methods (without ``@classmethod``). Such fixtures set attributes on a different instance than the test methods use, leading to unexpected behavior. Use ``@classmethod`` decorator instead -- by :user:`yastcher`. - -See :issue:`10819` and :issue:`14011`. diff --git a/changelog/11022.doc.rst b/changelog/11022.doc.rst deleted file mode 100644 index 45f08aeec4f..00000000000 --- a/changelog/11022.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Document safer alternatives and scope guidance for monkeypatching standard library functions. diff --git a/changelog/11225.improvement.rst b/changelog/11225.improvement.rst deleted file mode 100644 index 53005bfa505..00000000000 --- a/changelog/11225.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -:func:`pytest.warns` now shows "Regex pattern did not match" instead of "DID NOT WARN" when warnings were emitted but the ``match`` pattern did not match. diff --git a/changelog/11295.improvement.rst b/changelog/11295.improvement.rst deleted file mode 100644 index fc29956f04c..00000000000 --- a/changelog/11295.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Improved output of ``--fixtures-per-test`` by excluding internal-implementation fixtures generated by ``@pytest.mark.parametrize`` and similar. diff --git a/changelog/11307.doc.rst b/changelog/11307.doc.rst deleted file mode 100644 index fd9702e3d23..00000000000 --- a/changelog/11307.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Document that ``@pytest.hookimpl(specname=...)`` only works for function names starting with ``pytest_``. diff --git a/changelog/12376.feature.rst b/changelog/12376.feature.rst deleted file mode 100644 index 49551b5b2a4..00000000000 --- a/changelog/12376.feature.rst +++ /dev/null @@ -1,7 +0,0 @@ -Added :func:`pytest.register_fixture()` to register fixtures using an imperative interface. - -This is an advanced function intended for use by plugins. - -Normally, fixtures should be registered declaratively using the :func:`@pytest.fixture ` decorator. -Pytest looks for these fixture definitions during the collection phase and registers them automatically. -For some plugin usecases the declarative interface can be cumbersome or unviable, in which case this imperative interface can be used. diff --git a/changelog/12882.deprecation.rst b/changelog/12882.deprecation.rst deleted file mode 100644 index ba5f3240946..00000000000 --- a/changelog/12882.deprecation.rst +++ /dev/null @@ -1,3 +0,0 @@ -Calling :meth:`request.getfixturevalue() ` during teardown to request a fixture that was not already requested is now deprecated and will become an error in pytest 10. - -See :ref:`dynamic-fixture-request-during-teardown` for details. diff --git a/changelog/13038.doc.rst b/changelog/13038.doc.rst deleted file mode 100644 index b04ae1b807c..00000000000 --- a/changelog/13038.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Document that doctests do not support parametrized fixtures, including parametrized autouse fixtures. diff --git a/changelog/13155.doc.rst b/changelog/13155.doc.rst deleted file mode 100644 index a4faf22fa4a..00000000000 --- a/changelog/13155.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Clarified how the ``request`` fixture provides indirect parametrization values via ``request.param``. diff --git a/changelog/13192.bugfix.rst b/changelog/13192.bugfix.rst deleted file mode 100644 index cc7f9bc5487..00000000000 --- a/changelog/13192.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed `|` (pipe) not being treated as a regex meta-character that needs escaping in :func:`pytest.raises(match=...) `. diff --git a/changelog/13241.improvement.rst b/changelog/13241.improvement.rst deleted file mode 100644 index 41ba55e280a..00000000000 --- a/changelog/13241.improvement.rst +++ /dev/null @@ -1,2 +0,0 @@ -:func:`pytest.raises`, :func:`pytest.warns` and :func:`pytest.deprecated_call` now uses :class:`ParamSpec` for the type hint to the (old and not recommended) callable overload, instead of :class:`Any`. This allows type checkers to raise errors when passing incorrect function parameters. -``func`` can now also be passed as a kwarg, which the type hint previously showed as possible but didn't accept. diff --git a/changelog/13304.doc.rst b/changelog/13304.doc.rst deleted file mode 100644 index 665a61b8462..00000000000 --- a/changelog/13304.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Clarified in the documentation that hook implementations defined in ``conftest.py`` files are not available to other plugins during their ``pytest_addoption()`` execution, as conftest files are discovered and loaded after builtin and third-party plugins have been initialized. However, initial conftest files themselves can implement ``pytest_addoption()`` to add their own command-line options. diff --git a/changelog/13409.deprecation.rst b/changelog/13409.deprecation.rst deleted file mode 100644 index d4fcf2c8a5a..00000000000 --- a/changelog/13409.deprecation.rst +++ /dev/null @@ -1,8 +0,0 @@ -Using non-:class:`~collections.abc.Collection` iterables (such as generators, iterators, or custom iterable objects) for the ``argvalues`` parameter in :ref:`@pytest.mark.parametrize ` and :meth:`metafunc.parametrize ` is now deprecated. - -These iterables get exhausted after the first iteration, -leading to tests getting unexpectedly skipped in cases such as running :func:`pytest.main()` multiple times, -using class-level parametrize decorators, -or collecting tests multiple times. - -See :ref:`parametrize-iterators` for details and suggestions. diff --git a/changelog/13484.bugfix.rst b/changelog/13484.bugfix.rst deleted file mode 100644 index 4407003e8e9..00000000000 --- a/changelog/13484.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed ``-W`` option values being duplicated in ``Config.known_args_namespace``. diff --git a/changelog/13626.bugfix.rst b/changelog/13626.bugfix.rst deleted file mode 100644 index e58c76749fa..00000000000 --- a/changelog/13626.bugfix.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fixed function-scoped fixture values being kept alive after a test was interrupted by ``KeyboardInterrupt`` or early exit, -allowing them to potentially be released more promptly. diff --git a/changelog/13784.bugfix.rst b/changelog/13784.bugfix.rst deleted file mode 100644 index a2f4cf54327..00000000000 --- a/changelog/13784.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed ``capteesys`` producing doubled output when used with ``--capture=no`` (``-s``). diff --git a/changelog/13817.bugfix.rst b/changelog/13817.bugfix.rst deleted file mode 100644 index 08c9a6a53c3..00000000000 --- a/changelog/13817.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a secondary `AttributeError` masking the original error when an option argument fails to initialize. diff --git a/changelog/13862.improvement.rst b/changelog/13862.improvement.rst deleted file mode 100644 index 6a89cbc323b..00000000000 --- a/changelog/13862.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Improved the readability of "DID NOT RAISE" error messages by using the exception type's name instead of its `repr`. diff --git a/changelog/13884.bugfix.rst b/changelog/13884.bugfix.rst deleted file mode 100644 index af0f08eb00c..00000000000 --- a/changelog/13884.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed rare internal IndexError caused by `builtins.compile` being overridden in client code. diff --git a/changelog/13885.bugfix.rst b/changelog/13885.bugfix.rst deleted file mode 100644 index c4b7ebe4b4e..00000000000 --- a/changelog/13885.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed autouse fixtures defined inside a :class:`unittest.TestCase` class running even when the class is decorated with :func:`unittest.skip` or :func:`unittest.skipIf` -- regression since pytest 8.1.0. diff --git a/changelog/13902.doc.rst b/changelog/13902.doc.rst deleted file mode 100644 index f11a1936051..00000000000 --- a/changelog/13902.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Clarified how subtest progress markers are shown in the documentation. diff --git a/changelog/13917.bugfix.rst b/changelog/13917.bugfix.rst deleted file mode 100644 index d2cf90c2894..00000000000 --- a/changelog/13917.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -:class:`unittest.SkipTest` is no longer considered an interactive exception, i.e. :hook:`pytest_exception_interact` is no longer called for it. diff --git a/changelog/13946.deprecation.rst b/changelog/13946.deprecation.rst deleted file mode 100644 index 88371c4cc1c..00000000000 --- a/changelog/13946.deprecation.rst +++ /dev/null @@ -1,4 +0,0 @@ -The private ``config.inicfg`` attribute is now deprecated. -Use :meth:`config.getini() ` to access configuration values instead. - -See :ref:`config-inicfg` for more details. diff --git a/changelog/13963.bugfix.rst b/changelog/13963.bugfix.rst deleted file mode 100644 index 8717b265c72..00000000000 --- a/changelog/13963.bugfix.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fixed subtests running with :pypi:`pytest-xdist` when their contexts contain objects that are not JSON-serializable. - -Fixes `pytest-dev/pytest-xdist#1273 `__. diff --git a/changelog/14004.bugfix.rst b/changelog/14004.bugfix.rst deleted file mode 100644 index 357f85e6436..00000000000 --- a/changelog/14004.bugfix.rst +++ /dev/null @@ -1,6 +0,0 @@ -Fixed conftest.py fixture scoping when :confval:`testpaths` points outside of the :ref:`rootdir `. - -Previously, fixtures from nested conftest.py files would incorrectly leak to sibling directories -when using a relative ``testpaths`` like ``../tests/sdk``. - -Conftest fixtures are now parsed during :class:`Directory ` collection, using the ``Directory`` node for proper scoping. diff --git a/changelog/14004.deprecation.rst b/changelog/14004.deprecation.rst deleted file mode 100644 index d707b9cc309..00000000000 --- a/changelog/14004.deprecation.rst +++ /dev/null @@ -1,7 +0,0 @@ -Passing ``baseid`` to :class:`~pytest.FixtureDef` or ``nodeid`` strings to fixture registration APIs is now deprecated. These are internal pytest APIs that are used by some plugins. - -Use the ``node`` parameter instead for fixture scoping. This enables more robust node-based -matching instead of string prefix matching. -If you've used ``nodeid=None``, pass ``node=session`` instead. - -This will be removed in pytest 10. diff --git a/changelog/14012.doc.rst b/changelog/14012.doc.rst deleted file mode 100644 index 95942e4a86f..00000000000 --- a/changelog/14012.doc.rst +++ /dev/null @@ -1 +0,0 @@ -The :ref:`ini options ref` section of the API Reference now specified the type and default value of every configuration option. diff --git a/changelog/14023.feature.rst b/changelog/14023.feature.rst deleted file mode 100644 index 5d0f07c942e..00000000000 --- a/changelog/14023.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Added `--report-chars` long CLI option. diff --git a/changelog/14026.improvement.rst b/changelog/14026.improvement.rst deleted file mode 100644 index 7025ba80481..00000000000 --- a/changelog/14026.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Added test coverage for compiled regex patterns in :func:`pytest.raises` match parameter. diff --git a/changelog/14050.bugfix.rst b/changelog/14050.bugfix.rst deleted file mode 100644 index 451b248576f..00000000000 --- a/changelog/14050.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Display dictionary differences in assertion failures using the original key insertion order instead of sorted order. diff --git a/changelog/14080.bugfix.rst b/changelog/14080.bugfix.rst deleted file mode 100644 index 1140b4716db..00000000000 --- a/changelog/14080.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -fix missing type annotations on ``Pytester.makepyfile`` and ``Pytester.maketxtfile`` methods. diff --git a/changelog/14114.bugfix.rst b/changelog/14114.bugfix.rst deleted file mode 100644 index bcb1713c475..00000000000 --- a/changelog/14114.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -An exception from :hook:`pytest_fixture_post_finalizer` no longer prevents fixtures from being torn down, causing additional errors in the following tests. diff --git a/changelog/14137.improvement.rst b/changelog/14137.improvement.rst deleted file mode 100644 index 7585433ac9c..00000000000 --- a/changelog/14137.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -`pytest.ScopeName` is now public to allow using it in function signatures. diff --git a/changelog/14148.doc.rst b/changelog/14148.doc.rst deleted file mode 100644 index b54ae2cd8e3..00000000000 --- a/changelog/14148.doc.rst +++ /dev/null @@ -1,2 +0,0 @@ -Documented a safe ``pytestconfig.cache`` access pattern when the -``cacheprovider`` plugin is disabled. diff --git a/changelog/14161.bugfix.rst b/changelog/14161.bugfix.rst deleted file mode 100644 index d19f3f4ad60..00000000000 --- a/changelog/14161.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed :meth:`monkeypatch.setattr() ` leaving a stale entry on the undo stack when the underlying ``setattr()`` call fails (e.g. on immutable targets), causing an ``AttributeError`` crash during teardown. diff --git a/changelog/14214.bugfix.rst b/changelog/14214.bugfix.rst deleted file mode 100644 index ed87a66fc57..00000000000 --- a/changelog/14214.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed ``-v`` hint in :func:`pytest.raises` match diff not working because assertion verbosity was not propagated. diff --git a/changelog/14234.bugfix.rst b/changelog/14234.bugfix.rst deleted file mode 100644 index 5a5b8a8b3f9..00000000000 --- a/changelog/14234.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Allow :ref:`pytest.HIDDEN_PARAM ` in :ref:`@pytest.mark.parametrize(ids=...) ` typing. diff --git a/changelog/14248.bugfix.rst b/changelog/14248.bugfix.rst deleted file mode 100644 index 1c8563fa954..00000000000 --- a/changelog/14248.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed direct parametrization causing the static fixture closure (as reflected in :data:`request.fixturenames `) to omit fixtures that are requested transitively from overridden fixtures. diff --git a/changelog/14263.bugfix.rst b/changelog/14263.bugfix.rst deleted file mode 100644 index dba08435b18..00000000000 --- a/changelog/14263.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Unraisable exceptions from finalizers are now collected during ``pytest_unconfigure``, before pytest tears down the warning filters installed for the session. Previously the collection ran from a cleanup callback whose order relative to other plugins' cleanups was not guaranteed, so an active ``error`` filter could be removed before the exception surfaced and a late resource leak would pass silently. A ``-W error`` filter, or any filter matching :class:`pytest.PytestUnraisableExceptionWarning`, now promotes these exceptions to failures regardless of plugin cleanup order. diff --git a/changelog/14303.doc.rst b/changelog/14303.doc.rst deleted file mode 100644 index 377c6d6057b..00000000000 --- a/changelog/14303.doc.rst +++ /dev/null @@ -1 +0,0 @@ -The documentation is now built with Sphinx >= 9. diff --git a/changelog/14335.deprecation.rst b/changelog/14335.deprecation.rst deleted file mode 100644 index e173ac6938f..00000000000 --- a/changelog/14335.deprecation.rst +++ /dev/null @@ -1,2 +0,0 @@ -The method of configuring hooks using markers, deprecated since pytest 7.2, is now scheduled to be removed in pytest 10. -See :ref:`hook-markers` for more details. diff --git a/changelog/14342.improvement.rst b/changelog/14342.improvement.rst deleted file mode 100644 index 5b1d8d2afe7..00000000000 --- a/changelog/14342.improvement.rst +++ /dev/null @@ -1,2 +0,0 @@ -Marked ``yield_fixture`` as deprecated to type checkers using the ``deprecated`` decorator. Note it -:ref:`has originally been deprecated ` in pytest 6.2 already. diff --git a/changelog/14371.feature.rst b/changelog/14371.feature.rst deleted file mode 100644 index 2993b8c536f..00000000000 --- a/changelog/14371.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Added :option:`--max-warnings` command-line option and :confval:`max_warnings` configuration option to fail the test run when the number of warnings exceeds a given threshold -- by :user:`miketheman`. diff --git a/changelog/14373.improvement.rst b/changelog/14373.improvement.rst deleted file mode 100644 index ea145f8b4a8..00000000000 --- a/changelog/14373.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Added type annotations for :func:`pytest.approx`. diff --git a/changelog/14377.bugfix.rst b/changelog/14377.bugfix.rst deleted file mode 100644 index 5d94fed0f54..00000000000 --- a/changelog/14377.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed crash in `Config.get_terminal_writer` when an assertion fails with the ``terminalreporter`` plugin disabled. diff --git a/changelog/14381.bugfix.rst b/changelog/14381.bugfix.rst deleted file mode 100644 index d3552a6304d..00000000000 --- a/changelog/14381.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed ``-V`` (short form of ``--version``) to properly display the current version. diff --git a/changelog/14389.bugfix.rst b/changelog/14389.bugfix.rst deleted file mode 100644 index f0d85169d0b..00000000000 --- a/changelog/14389.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Improved :func:`pytest.raises(..., match=...) ` failures to suppress the mismatched exception as a cause of the resulting ``AssertionError``. diff --git a/changelog/14392.bugfix.rst b/changelog/14392.bugfix.rst deleted file mode 100644 index b67ff0ffec9..00000000000 --- a/changelog/14392.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a bug in :func:`pytest.raises(match=...) ` "fully escaped" detection, causing the regex diff display to be shown in some instances when the raw string diff display should be shown instead. diff --git a/changelog/14430.improvement.rst b/changelog/14430.improvement.rst deleted file mode 100644 index 84206b37033..00000000000 --- a/changelog/14430.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -When using ``--setup-show``, a space is now printed after the test name (and possibly used fixtures), to separate it from the test result. diff --git a/changelog/14434.deprecation.rst b/changelog/14434.deprecation.rst deleted file mode 100644 index 8f4454e76f8..00000000000 --- a/changelog/14434.deprecation.rst +++ /dev/null @@ -1,3 +0,0 @@ -The :option:`--pastebin` option is now deprecated. -The same functionality is now available in an external plugin, :pypi:`pytest-pastebin`. -See :ref:`pastebin-deprecated` for more details. diff --git a/changelog/14441.improvement.rst b/changelog/14441.improvement.rst deleted file mode 100644 index d37e6466b06..00000000000 --- a/changelog/14441.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Reduced the default number of ``gc.collect()`` passes in the ``unraisableexception`` plugin from 5 to 1 on CPython, where reference counting makes a single pass sufficient. PyPy retains 5 passes due to object resurrection via ``__del__``. This can noticeably speed up test suites that trigger many pytester runs. diff --git a/changelog/14442.bugfix.rst b/changelog/14442.bugfix.rst deleted file mode 100644 index 90999cc9572..00000000000 --- a/changelog/14442.bugfix.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fixed a regression in pytest 9.0 where :option:`--strict-markers` and :option:`--strict-config` specified through :confval:`addopts` were silently ignored. - -Note that when targeting pytest >= 9.0, it's nicer to use :confval:`strict_markers` and :confval:`strict_config`, or :ref:`strict mode `. diff --git a/changelog/14456.bugfix.rst b/changelog/14456.bugfix.rst deleted file mode 100644 index ccd9ca20a8f..00000000000 --- a/changelog/14456.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed :func:`pytest.approx` not recognizing types with ``__array_interface__`` as numpy-like arrays. diff --git a/changelog/14461.improvement.rst b/changelog/14461.improvement.rst deleted file mode 100644 index 709772ede9b..00000000000 --- a/changelog/14461.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Improved assertion failure explanations for equality comparisons between mapping objects that are not ``dict`` instances. diff --git a/changelog/14465.doc.rst b/changelog/14465.doc.rst deleted file mode 100644 index 2c950292911..00000000000 --- a/changelog/14465.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Updated the hooks how-to page to link the ``newhooks.py`` file in ``pytest-xdist`` at tag ``v3.8.0`` instead of an unrelated 2017-era commit under the old layout. Pointing at a tag keeps the example in sync with the version users actually install, while remaining stable when the project's main branch moves on. diff --git a/changelog/14474.bugfix.rst b/changelog/14474.bugfix.rst deleted file mode 100644 index 333d4d34d9a..00000000000 --- a/changelog/14474.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a regression where ``-k`` and ``-m`` expressions containing both backslash characters in identifiers and string literal arguments would incorrectly raise a ``SyntaxError`` about escaping. diff --git a/changelog/14483.bugfix.rst b/changelog/14483.bugfix.rst deleted file mode 100644 index cdc5d0f5af7..00000000000 --- a/changelog/14483.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed JUnit XML report incorrectly escaping high Unicode codepoints (supplementary plane characters like emoji) in test failure messages. -- by :user:`EternalRights` diff --git a/changelog/14492.bugfix.rst b/changelog/14492.bugfix.rst deleted file mode 100644 index 1e5c6b778d3..00000000000 --- a/changelog/14492.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed ``Code.getargs()`` incorrectly including local variable names in the returned argument tuple for functions with ``*args`` and/or ``**kwargs``. The method was using ``co_flags`` bitmask values (``4`` and ``8``) directly as counts instead of converting them to ``1`` via ``bool()``, and was not accounting for ``co_kwonlyargcount`` when ``var=True``. diff --git a/changelog/14513.deprecation.rst b/changelog/14513.deprecation.rst deleted file mode 100644 index b5b17f06c06..00000000000 --- a/changelog/14513.deprecation.rst +++ /dev/null @@ -1,2 +0,0 @@ -The private ``FixtureDef.has_location`` attribute is now deprecated and will be removed in pytest 10. -See :ref:`fixturedef-has-location-deprecated` for details. diff --git a/changelog/14513.improvement.rst b/changelog/14513.improvement.rst deleted file mode 100644 index 7bd07fdcee8..00000000000 --- a/changelog/14513.improvement.rst +++ /dev/null @@ -1,5 +0,0 @@ -The order in which fixture definitions overriding each other are resolved is now determined first by their *visibility* in the collection tree rather than by the order in which they are registered. - -A fixture defined for a more specific node (e.g. a module or an item) now always takes precedence over one with the same name defined for a more general node (e.g. the session), even when the more general one was registered later. -Fixtures with non-comparable visibility or the same visibility keep the existing behavior of "last registered wins". -This change is supposed to only affect plugins which register multiple fixtures programmatically with the same name. diff --git a/changelog/14524.improvement.rst b/changelog/14524.improvement.rst deleted file mode 100644 index e6b7c996077..00000000000 --- a/changelog/14524.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Add official Python 3.15 support. diff --git a/changelog/14533.breaking.rst b/changelog/14533.breaking.rst deleted file mode 100644 index d63f4d3a852..00000000000 --- a/changelog/14533.breaking.rst +++ /dev/null @@ -1,8 +0,0 @@ -When using :option:`--doctest-modules`, autouse fixtures with ``module``, ``package`` or ``session`` scope that are defined inline in Python test modules (not plugins or conftests) will now possibly execute twice. - -If this is undesirable, move the fixture definition to a ``conftest.py`` file if possible. - -Technical explanation for those interested: -When using `--doctest-modules`, pytest possibly collects Python modules twice, once as :class:`pytest.Module` and once as a ``DoctestModule`` (depending on the configuration). -Due to improvements in pytest's fixture implementation, if e.g. the ``DoctestModule`` collects a fixture, it is now visible to it only, and not to the ``Module``. -This means that both need to register the fixtures independently. diff --git a/changelog/14582.misc.rst b/changelog/14582.misc.rst deleted file mode 100644 index e824c3e6d09..00000000000 --- a/changelog/14582.misc.rst +++ /dev/null @@ -1 +0,0 @@ -Improved the recursion traceback test to exercise all requested traceback styles. diff --git a/changelog/1764.deprecation.rst b/changelog/1764.deprecation.rst deleted file mode 100644 index 7e57c17b62a..00000000000 --- a/changelog/1764.deprecation.rst +++ /dev/null @@ -1,2 +0,0 @@ -:func:`pytest.console_main` is now deprecated and will be removed in pytest 10. -It was never intended for programmatic use; use :func:`pytest.main` instead. diff --git a/changelog/1764.improvement.rst b/changelog/1764.improvement.rst deleted file mode 100644 index 0a25f39faf9..00000000000 --- a/changelog/1764.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Improved argparse program name to show ``pytest``, ``python -m pytest``, or ``pytest.main()`` based on how pytest was invoked, making help and error messages clearer. diff --git a/changelog/3697.bugfix.rst b/changelog/3697.bugfix.rst deleted file mode 100644 index 59f1872786d..00000000000 --- a/changelog/3697.bugfix.rst +++ /dev/null @@ -1,3 +0,0 @@ -Logging capture now works for non-propagating loggers. -Previously only logs which reached the root logger were captured. -This includes :fixture:`caplog` and the "Captured log calls" test reporting. diff --git a/changelog/3850.bugfix.rst b/changelog/3850.bugfix.rst deleted file mode 100644 index 2486d4b59d2..00000000000 --- a/changelog/3850.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed JUnit XML report: the ``tests`` attribute of the ```` element now always matches the number of ```` elements in the file. In some cases (test passes but fails during teardown) the ``tests`` attribute would report an incorrect number of testcases in the XML file. diff --git a/changelog/5848.bugfix.rst b/changelog/5848.bugfix.rst deleted file mode 100644 index c516ce92473..00000000000 --- a/changelog/5848.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -:hook:`pytest_fixture_post_finalizer` is no longer called extra times for the same fixture teardown in some cases. diff --git a/changelog/6757.feature.rst b/changelog/6757.feature.rst deleted file mode 100644 index 0c154d3d6ff..00000000000 --- a/changelog/6757.feature.rst +++ /dev/null @@ -1,3 +0,0 @@ -Added the :confval:`assertion_text_diff_style` configuration option, allowing -string equality failures to be rendered as separate ``Left:`` and ``Right:`` -blocks instead of ``ndiff`` output. diff --git a/changelog/719.bugfix.rst b/changelog/719.bugfix.rst deleted file mode 100644 index c2063ad0503..00000000000 --- a/changelog/719.bugfix.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fixed :ref:`@pytest.mark.parametrize ` not unpacking single-element tuple values when using a string argnames with a trailing comma (e.g., ``"arg,"``). - -The trailing comma form now correctly behaves like the tuple form ``("arg",)``, treating argvalues as a list of tuples to unpack. diff --git a/changelog/8265.improvement.rst b/changelog/8265.improvement.rst deleted file mode 100644 index e59b12052fe..00000000000 --- a/changelog/8265.improvement.rst +++ /dev/null @@ -1,4 +0,0 @@ -Emit a ``PytestCollectionWarning`` when a module-level ``__getattr__`` returns ``None`` for ``pytestmark`` instead of raising ``AttributeError``. - -Previously this caused a cryptic ``TypeError: got None instead of Mark`` error. -Now pytest issues a helpful warning and continues collecting the module normally. diff --git a/changelog/8395.feature.rst b/changelog/8395.feature.rst deleted file mode 100644 index 61c16216182..00000000000 --- a/changelog/8395.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Added support for :class:`~datetime.datetime` and :class:`~datetime.timedelta` comparisons with :func:`pytest.approx`. An explicit ``abs`` or ``rel`` tolerance as a :class:`~datetime.timedelta` is required and relative tolerance is not supported for datetime comparisons -- by :user:`hamza-mobeen`. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 4a5e8b86544..d9b95a2c95f 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-9.1.0 release-9.0.3 release-9.0.2 release-9.0.1 diff --git a/doc/en/announce/release-9.1.0.rst b/doc/en/announce/release-9.1.0.rst new file mode 100644 index 00000000000..55cc7a64713 --- /dev/null +++ b/doc/en/announce/release-9.1.0.rst @@ -0,0 +1,98 @@ +pytest-9.1.0 +======================================= + +The pytest team is proud to announce the 9.1.0 release! + +This release contains new features, improvements, and bug fixes, +the full list of changes is available in the changelog: + + https://docs.pytest.org/en/stable/changelog.html + +For complete documentation, please visit: + + https://docs.pytest.org/en/stable/ + +As usual, you can upgrade from PyPI via: + + pip install -U pytest + +Thanks to all of the contributors to this release: + +* 1Utkarsh1 +* Aditya Giri +* Alejandro Villate +* Alex Waygood +* Anton Zhilin +* Antonis Gardi +* Bruno Oliveira +* Bubble-Interface +* Charles-Meldhine Madi Mnemoi +* DavidAG +* Denis Cherednichenko +* DetachHead +* Dhruva Kumar +* Dr Alex Mitre +* EternalRights +* Fazeel Usmani +* Florian Bruhin +* Freya Bruhin +* Fridayworks +* Garion Milazzo +* Hamza Mobeen +* Hugo van Kemenade +* Ilya Manafi +* John Litborn +* Julia Knaak +* Junhao Liao +* Kadir Can Ozden +* Lai Jia Yang +* Liam DeVoe +* Lily Wu +* Marco Edward Gorelli +* Maxime Grenu +* Mike Fiedler +* Mikhail Golikov +* Mukunda Rao Katta +* NIYONSHUTI Emmanuel +* Nikesh Chavhan +* Noa Levi +* Paul Zuradzki +* Philipp A. +* Pierre Sassoulas +* Praneeth Kodumagulla +* Puneet Dixit +* Ran Benita +* Randy Döring +* Ronald Eddy Jr +* Ronny Pfannschmidt +* Samuel Newbold +* Stanis Trendelenburg +* Sviatoslav Sydorenko +* Sylvain MARIE +* Syncrain +* Sóla Lusøt +* Tejas Verma +* Tobias Deiminger +* Tom Most +* V1SHAL421 +* Varun Chawla +* Vladimir +* Warren +* Will Toohey +* Yast +* Yusuke Kadowaki +* arya rizky +* dariomesic +* isra17 +* jakkdl +* jiayang lai +* jxramos +* minbang930 +* morning-verlu +* ron +* 사재혁 +* 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) + + +Happy testing, +The pytest Development Team diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index 9d38b329454..3184c9a22e2 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -22,7 +22,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a cachedir: .pytest_cache rootdir: /home/sweet/project collected 0 items - cache -- .../_pytest/cacheprovider.py:566 + cache -- .../_pytest/cacheprovider.py:560 Return a cache object that can persist state between testing sessions. cache.get(key, default) @@ -33,7 +33,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a Values can be any object handled by the json stdlib module. - capsys -- .../_pytest/capture.py:1000 + capsys -- .../_pytest/capture.py:1007 Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsys.readouterr()`` method @@ -51,7 +51,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capsys.readouterr() assert captured.out == "hello\n" - capteesys -- .../_pytest/capture.py:1028 + capteesys -- .../_pytest/capture.py:1035 Enable simultaneous text capturing and pass-through of writes to ``sys.stdout`` and ``sys.stderr`` as defined by ``--capture=``. @@ -74,7 +74,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capteesys.readouterr() assert captured.out == "hello\n" - capsysbinary -- .../_pytest/capture.py:1063 + capsysbinary -- .../_pytest/capture.py:1070 Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsysbinary.readouterr()`` @@ -92,7 +92,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capsysbinary.readouterr() assert captured.out == b"hello\n" - capfd -- .../_pytest/capture.py:1091 + capfd -- .../_pytest/capture.py:1098 Enable text capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method @@ -110,7 +110,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capfd.readouterr() assert captured.out == "hello\n" - capfdbinary -- .../_pytest/capture.py:1119 + capfdbinary -- .../_pytest/capture.py:1126 Enable bytes capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method @@ -128,7 +128,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capfdbinary.readouterr() assert captured.out == b"hello\n" - doctest_namespace [session scope] -- .../_pytest/doctest.py:722 + doctest_namespace [session scope] -- .../_pytest/doctest.py:721 Fixture that returns a :py:class:`dict` that will be injected into the namespace of doctests. @@ -142,7 +142,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a For more details: :ref:`doctest_namespace`. - pytestconfig [session scope] -- .../_pytest/fixtures.py:1431 + pytestconfig [session scope] -- .../_pytest/fixtures.py:1563 Session-scoped fixture that returns the session's :class:`pytest.Config` object. @@ -152,7 +152,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a if pytestconfig.get_verbosity() > 0: ... - record_property -- .../_pytest/junitxml.py:277 + record_property -- .../_pytest/junitxml.py:275 Add extra properties to the calling test. User properties become part of the test report and are available to the @@ -166,13 +166,13 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a def test_function(record_property): record_property("example_key", 1) - record_xml_attribute -- .../_pytest/junitxml.py:300 + record_xml_attribute -- .../_pytest/junitxml.py:298 Add extra xml attributes to the tag for the calling test. The fixture is callable with ``name, value``. The value is automatically XML-encoded. - record_testsuite_property [session scope] -- .../_pytest/junitxml.py:338 + record_testsuite_property [session scope] -- .../_pytest/junitxml.py:336 Record a new ```` tag as child of the root ````. This is suitable to writing global information regarding the entire test @@ -214,7 +214,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a .. _legacy_path: https://py.readthedocs.io/en/latest/path.html - caplog -- .../_pytest/logging.py:596 + caplog -- .../_pytest/logging.py:611 Access and control log capturing. Captured logs are available through the following properties/methods:: @@ -225,7 +225,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a * caplog.record_tuples -> list of (logger_name, level, message) tuples * caplog.clear() -> clear captured records and formatted log output string - monkeypatch -- .../_pytest/monkeypatch.py:33 + monkeypatch -- .../_pytest/monkeypatch.py:36 A convenient fixture for monkey-patching. The fixture provides these methods to modify objects, dictionaries, or @@ -249,18 +249,18 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a To undo modifications done by the fixture in a contained scope, use :meth:`context() `. - recwarn -- .../_pytest/recwarn.py:34 + recwarn -- .../_pytest/recwarn.py:37 Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions. See :ref:`warnings` for information on warning categories. - subtests -- .../_pytest/subtests.py:129 + subtests -- .../_pytest/subtests.py:136 Provides subtests functionality. - tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:265 + tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:276 Return a :class:`pytest.TempPathFactory` instance for the test session. - tmp_path -- .../_pytest/tmpdir.py:280 + tmp_path -- .../_pytest/tmpdir.py:291 Return a temporary directory (as :class:`pathlib.Path` object) which is unique to each test function invocation. The temporary directory is created as a subdirectory diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 6b1793bd503..b15c7e48aba 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -31,6 +31,316 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 9.1.0 (2026-06-13) +========================= + +Removals and backward incompatible breaking changes +--------------------------------------------------- + +- `#14533 `_: When using :option:`--doctest-modules`, autouse fixtures with ``module``, ``package`` or ``session`` scope that are defined inline in Python test modules (not plugins or conftests) will now possibly execute twice. + + If this is undesirable, move the fixture definition to a ``conftest.py`` file if possible. + + Technical explanation for those interested: + When using `--doctest-modules`, pytest possibly collects Python modules twice, once as :class:`pytest.Module` and once as a ``DoctestModule`` (depending on the configuration). + Due to improvements in pytest's fixture implementation, if e.g. the ``DoctestModule`` collects a fixture, it is now visible to it only, and not to the ``Module``. + This means that both need to register the fixtures independently. + + + +Deprecations (removal in next major release) +-------------------------------------------- + +- `#10819 `_: Added a deprecation warning for class-scoped fixtures defined as instance methods (without ``@classmethod``). Such fixtures set attributes on a different instance than the test methods use, leading to unexpected behavior. Use ``@classmethod`` decorator instead -- by :user:`yastcher`. + + See :issue:`10819` and :issue:`14011`. + + +- `#12882 `_: Calling :meth:`request.getfixturevalue() ` during teardown to request a fixture that was not already requested is now deprecated and will become an error in pytest 10. + + See :ref:`dynamic-fixture-request-during-teardown` for details. + + +- `#13409 `_: Using non-:class:`~collections.abc.Collection` iterables (such as generators, iterators, or custom iterable objects) for the ``argvalues`` parameter in :ref:`@pytest.mark.parametrize ` and :meth:`metafunc.parametrize ` is now deprecated. + + These iterables get exhausted after the first iteration, + leading to tests getting unexpectedly skipped in cases such as running :func:`pytest.main()` multiple times, + using class-level parametrize decorators, + or collecting tests multiple times. + + See :ref:`parametrize-iterators` for details and suggestions. + + +- `#13946 `_: The private ``config.inicfg`` attribute is now deprecated. + Use :meth:`config.getini() ` to access configuration values instead. + + See :ref:`config-inicfg` for more details. + + +- `#14004 `_: Passing ``baseid`` to :class:`~pytest.FixtureDef` or ``nodeid`` strings to fixture registration APIs is now deprecated. These are internal pytest APIs that are used by some plugins. + + Use the ``node`` parameter instead for fixture scoping. This enables more robust node-based + matching instead of string prefix matching. + If you've used ``nodeid=None``, pass ``node=session`` instead. + + This will be removed in pytest 10. + + +- `#14335 `_: The method of configuring hooks using markers, deprecated since pytest 7.2, is now scheduled to be removed in pytest 10. + See :ref:`hook-markers` for more details. + + +- `#14434 `_: The :option:`--pastebin` option is now deprecated. + The same functionality is now available in an external plugin, :pypi:`pytest-pastebin`. + See :ref:`pastebin-deprecated` for more details. + + +- `#14513 `_: The private ``FixtureDef.has_location`` attribute is now deprecated and will be removed in pytest 10. + See :ref:`fixturedef-has-location-deprecated` for details. + + +- `#1764 `_: :func:`pytest.console_main` is now deprecated and will be removed in pytest 10. + It was never intended for programmatic use; use :func:`pytest.main` instead. + + + +New features +------------ + +- `#12376 `_: Added :func:`pytest.register_fixture()` to register fixtures using an imperative interface. + + This is an advanced function intended for use by plugins. + + Normally, fixtures should be registered declaratively using the :func:`@pytest.fixture ` decorator. + Pytest looks for these fixture definitions during the collection phase and registers them automatically. + For some plugin usecases the declarative interface can be cumbersome or unviable, in which case this imperative interface can be used. + + +- `#14023 `_: Added `--report-chars` long CLI option. + + +- `#14371 `_: Added :option:`--max-warnings` command-line option and :confval:`max_warnings` configuration option to fail the test run when the number of warnings exceeds a given threshold -- by :user:`miketheman`. + + +- `#6757 `_: Added the :confval:`assertion_text_diff_style` configuration option, allowing + string equality failures to be rendered as separate ``Left:`` and ``Right:`` + blocks instead of ``ndiff`` output. + + +- `#8395 `_: Added support for :class:`~datetime.datetime` and :class:`~datetime.timedelta` comparisons with :func:`pytest.approx`. An explicit ``abs`` or ``rel`` tolerance as a :class:`~datetime.timedelta` is required and relative tolerance is not supported for datetime comparisons -- by :user:`hamza-mobeen`. + + + +Improvements in existing functionality +-------------------------------------- + +- `#11225 `_: :func:`pytest.warns` now shows "Regex pattern did not match" instead of "DID NOT WARN" when warnings were emitted but the ``match`` pattern did not match. + + +- `#11295 `_: Improved output of ``--fixtures-per-test`` by excluding internal-implementation fixtures generated by ``@pytest.mark.parametrize`` and similar. + + +- `#13241 `_: :func:`pytest.raises`, :func:`pytest.warns` and :func:`pytest.deprecated_call` now uses :class:`ParamSpec` for the type hint to the (old and not recommended) callable overload, instead of :class:`Any`. This allows type checkers to raise errors when passing incorrect function parameters. + ``func`` can now also be passed as a kwarg, which the type hint previously showed as possible but didn't accept. + + +- `#13862 `_: Improved the readability of "DID NOT RAISE" error messages by using the exception type's name instead of its `repr`. + + +- `#14026 `_: Added test coverage for compiled regex patterns in :func:`pytest.raises` match parameter. + + +- `#14137 `_: `pytest.ScopeName` is now public to allow using it in function signatures. + + +- `#14342 `_: Marked ``yield_fixture`` as deprecated to type checkers using the ``deprecated`` decorator. Note it + :ref:`has originally been deprecated ` in pytest 6.2 already. + + +- `#14373 `_: Added type annotations for :func:`pytest.approx`. + + +- `#14430 `_: When using ``--setup-show``, a space is now printed after the test name (and possibly used fixtures), to separate it from the test result. + + +- `#14441 `_: Reduced the default number of ``gc.collect()`` passes in the ``unraisableexception`` plugin from 5 to 1 on CPython, where reference counting makes a single pass sufficient. PyPy retains 5 passes due to object resurrection via ``__del__``. This can noticeably speed up test suites that trigger many pytester runs. + + +- `#14461 `_: Improved assertion failure explanations for equality comparisons between mapping objects that are not ``dict`` instances. + + +- `#14513 `_: The order in which fixture definitions overriding each other are resolved is now determined first by their *visibility* in the collection tree rather than by the order in which they are registered. + + A fixture defined for a more specific node (e.g. a module or an item) now always takes precedence over one with the same name defined for a more general node (e.g. the session), even when the more general one was registered later. + Fixtures with non-comparable visibility or the same visibility keep the existing behavior of "last registered wins". + This change is supposed to only affect plugins which register multiple fixtures programmatically with the same name. + + +- `#14524 `_: Add official Python 3.15 support. + + +- `#1764 `_: Improved argparse program name to show ``pytest``, ``python -m pytest``, or ``pytest.main()`` based on how pytest was invoked, making help and error messages clearer. + + +- `#8265 `_: Emit a ``PytestCollectionWarning`` when a module-level ``__getattr__`` returns ``None`` for ``pytestmark`` instead of raising ``AttributeError``. + + Previously this caused a cryptic ``TypeError: got None instead of Mark`` error. + Now pytest issues a helpful warning and continues collecting the module normally. + + + +Bug fixes +--------- + +- `#13192 `_: Fixed `|` (pipe) not being treated as a regex meta-character that needs escaping in :func:`pytest.raises(match=...) `. + + +- `#13484 `_: Fixed ``-W`` option values being duplicated in ``Config.known_args_namespace``. + + +- `#13626 `_: Fixed function-scoped fixture values being kept alive after a test was interrupted by ``KeyboardInterrupt`` or early exit, + allowing them to potentially be released more promptly. + + +- `#13784 `_: Fixed ``capteesys`` producing doubled output when used with ``--capture=no`` (``-s``). + + +- `#13817 `_: Fixed a secondary `AttributeError` masking the original error when an option argument fails to initialize. + + +- `#13884 `_: Fixed rare internal IndexError caused by `builtins.compile` being overridden in client code. + + +- `#13885 `_: Fixed autouse fixtures defined inside a :class:`unittest.TestCase` class running even when the class is decorated with :func:`unittest.skip` or :func:`unittest.skipIf` -- regression since pytest 8.1.0. + + +- `#13917 `_: :class:`unittest.SkipTest` is no longer considered an interactive exception, i.e. :hook:`pytest_exception_interact` is no longer called for it. + + +- `#13963 `_: Fixed subtests running with :pypi:`pytest-xdist` when their contexts contain objects that are not JSON-serializable. + + Fixes `pytest-dev/pytest-xdist#1273 `__. + + +- `#14004 `_: Fixed conftest.py fixture scoping when :confval:`testpaths` points outside of the :ref:`rootdir `. + + Previously, fixtures from nested conftest.py files would incorrectly leak to sibling directories + when using a relative ``testpaths`` like ``../tests/sdk``. + + Conftest fixtures are now parsed during :class:`Directory ` collection, using the ``Directory`` node for proper scoping. + + +- `#14050 `_: Display dictionary differences in assertion failures using the original key insertion order instead of sorted order. + + +- `#14080 `_: fix missing type annotations on ``Pytester.makepyfile`` and ``Pytester.maketxtfile`` methods. + + +- `#14114 `_: An exception from :hook:`pytest_fixture_post_finalizer` no longer prevents fixtures from being torn down, causing additional errors in the following tests. + + +- `#14161 `_: Fixed :meth:`monkeypatch.setattr() ` leaving a stale entry on the undo stack when the underlying ``setattr()`` call fails (e.g. on immutable targets), causing an ``AttributeError`` crash during teardown. + + +- `#14214 `_: Fixed ``-v`` hint in :func:`pytest.raises` match diff not working because assertion verbosity was not propagated. + + +- `#14234 `_: Allow :ref:`pytest.HIDDEN_PARAM ` in :ref:`@pytest.mark.parametrize(ids=...) ` typing. + + +- `#14248 `_: Fixed direct parametrization causing the static fixture closure (as reflected in :data:`request.fixturenames `) to omit fixtures that are requested transitively from overridden fixtures. + + +- `#14263 `_: Unraisable exceptions from finalizers are now collected during ``pytest_unconfigure``, before pytest tears down the warning filters installed for the session. Previously the collection ran from a cleanup callback whose order relative to other plugins' cleanups was not guaranteed, so an active ``error`` filter could be removed before the exception surfaced and a late resource leak would pass silently. A ``-W error`` filter, or any filter matching :class:`pytest.PytestUnraisableExceptionWarning`, now promotes these exceptions to failures regardless of plugin cleanup order. + + +- `#14377 `_: Fixed crash in `Config.get_terminal_writer` when an assertion fails with the ``terminalreporter`` plugin disabled. + + +- `#14381 `_: Fixed ``-V`` (short form of ``--version``) to properly display the current version. + + +- `#14389 `_: Improved :func:`pytest.raises(..., match=...) ` failures to suppress the mismatched exception as a cause of the resulting ``AssertionError``. + + +- `#14392 `_: Fixed a bug in :func:`pytest.raises(match=...) ` "fully escaped" detection, causing the regex diff display to be shown in some instances when the raw string diff display should be shown instead. + + +- `#14442 `_: Fixed a regression in pytest 9.0 where :option:`--strict-markers` and :option:`--strict-config` specified through :confval:`addopts` were silently ignored. + + Note that when targeting pytest >= 9.0, it's nicer to use :confval:`strict_markers` and :confval:`strict_config`, or :ref:`strict mode `. + + +- `#14456 `_: Fixed :func:`pytest.approx` not recognizing types with ``__array_interface__`` as numpy-like arrays. + + +- `#14474 `_: Fixed a regression where ``-k`` and ``-m`` expressions containing both backslash characters in identifiers and string literal arguments would incorrectly raise a ``SyntaxError`` about escaping. + + +- `#14483 `_: Fixed JUnit XML report incorrectly escaping high Unicode codepoints (supplementary plane characters like emoji) in test failure messages. -- by :user:`EternalRights` + + +- `#14492 `_: Fixed ``Code.getargs()`` incorrectly including local variable names in the returned argument tuple for functions with ``*args`` and/or ``**kwargs``. The method was using ``co_flags`` bitmask values (``4`` and ``8``) directly as counts instead of converting them to ``1`` via ``bool()``, and was not accounting for ``co_kwonlyargcount`` when ``var=True``. + + +- `#3697 `_: Logging capture now works for non-propagating loggers. + Previously only logs which reached the root logger were captured. + This includes :fixture:`caplog` and the "Captured log calls" test reporting. + + +- `#3850 `_: Fixed JUnit XML report: the ``tests`` attribute of the ```` element now always matches the number of ```` elements in the file. In some cases (test passes but fails during teardown) the ``tests`` attribute would report an incorrect number of testcases in the XML file. + + +- `#5848 `_: :hook:`pytest_fixture_post_finalizer` is no longer called extra times for the same fixture teardown in some cases. + + +- `#719 `_: Fixed :ref:`@pytest.mark.parametrize ` not unpacking single-element tuple values when using a string argnames with a trailing comma (e.g., ``"arg,"``). + + The trailing comma form now correctly behaves like the tuple form ``("arg",)``, treating argvalues as a list of tuples to unpack. + + + +Improved documentation +---------------------- + +- `#11022 `_: Document safer alternatives and scope guidance for monkeypatching standard library functions. + + +- `#11307 `_: Document that ``@pytest.hookimpl(specname=...)`` only works for function names starting with ``pytest_``. + + +- `#13038 `_: Document that doctests do not support parametrized fixtures, including parametrized autouse fixtures. + + +- `#13155 `_: Clarified how the ``request`` fixture provides indirect parametrization values via ``request.param``. + + +- `#13304 `_: Clarified in the documentation that hook implementations defined in ``conftest.py`` files are not available to other plugins during their ``pytest_addoption()`` execution, as conftest files are discovered and loaded after builtin and third-party plugins have been initialized. However, initial conftest files themselves can implement ``pytest_addoption()`` to add their own command-line options. + + +- `#13902 `_: Clarified how subtest progress markers are shown in the documentation. + + +- `#14012 `_: The :ref:`ini options ref` section of the API Reference now specified the type and default value of every configuration option. + + +- `#14148 `_: Documented a safe ``pytestconfig.cache`` access pattern when the + ``cacheprovider`` plugin is disabled. + + +- `#14303 `_: The documentation is now built with Sphinx >= 9. + + +- `#14465 `_: Updated the hooks how-to page to link the ``newhooks.py`` file in ``pytest-xdist`` at tag ``v3.8.0`` instead of an unrelated 2017-era commit under the old layout. Pointing at a tag keeps the example in sync with the version users actually install, while remaining stable when the project's main branch moves on. + + + +Miscellaneous internal changes +------------------------------ + +- `#14582 `_: Improved the recursion traceback test to exercise all requested traceback styles. + + pytest 9.0.3 (2026-04-07) ========================= diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index de668def863..7e118d0b2ca 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -162,7 +162,7 @@ objects, they are still using the default pytest representation: rootdir: /home/sweet/project collected 8 items - + @@ -239,7 +239,7 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia rootdir: /home/sweet/project collected 4 items - + @@ -318,7 +318,7 @@ Let's first see how it looks like at collection time: rootdir: /home/sweet/project collected 2 items - + diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 48ee2c8533f..4f11f0d4dba 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -142,7 +142,7 @@ The test collection would look like this: configfile: pytest.toml collected 2 items - + @@ -205,7 +205,7 @@ You can always peek at the collection tree without running tests like this: configfile: pytest.toml collected 3 items - + diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index 29ba190b7e7..1eef1322927 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -429,7 +429,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: def test_raises_doesnt(self): > raises(OSError, int, "3") - E Failed: DID NOT RAISE + E Failed: DID NOT RAISE OSError failure_demo.py:171: Failed __________________________ TestRaises.test_raise ___________________________ @@ -574,12 +574,12 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + where False = ('456') E + where = '123'.startswith E + where '123' = .f at 0xdeadbeef0029>() - E + and '456' = .g at 0xdeadbeef002a>() + E + and '456' = .g at 0xdeadbeef0002>() failure_demo.py:237: AssertionError _____________________ TestMoreErrors.test_global_func ______________________ - self = + self = def test_global_func(self): > assert isinstance(globf(42), float) @@ -590,18 +590,18 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:240: AssertionError _______________________ TestMoreErrors.test_instance _______________________ - self = + self = def test_instance(self): self.x = 6 * 7 > assert self.x != 42 E assert 42 != 42 - E + where 42 = .x + E + where 42 = .x failure_demo.py:244: AssertionError _______________________ TestMoreErrors.test_compare ________________________ - self = + self = def test_compare(self): > assert globf(10) < 5 @@ -611,7 +611,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:247: AssertionError _____________________ TestMoreErrors.test_try_finally ______________________ - self = + self = def test_try_finally(self): x = 1 @@ -622,7 +622,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:252: AssertionError ___________________ TestCustomAssertMsg.test_single_line ___________________ - self = + self = def test_single_line(self): class A: @@ -637,7 +637,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:263: AssertionError ____________________ TestCustomAssertMsg.test_multiline ____________________ - self = + self = def test_multiline(self): class A: @@ -656,7 +656,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:270: AssertionError ___________________ TestCustomAssertMsg.test_custom_repr ___________________ - self = + self = def test_custom_repr(self): class JSON: diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 76a4428c163..1bef840b891 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -20,7 +20,7 @@ Install ``pytest`` .. code-block:: bash $ pytest --version - pytest 9.0.3 + pytest 9.1.0 .. _`simpletest`: diff --git a/doc/en/how-to/cache.rst b/doc/en/how-to/cache.rst index c030e487563..ef0919ef1c8 100644 --- a/doc/en/how-to/cache.rst +++ b/doc/en/how-to/cache.rst @@ -247,7 +247,7 @@ If you run this command for the first time, you can see the print statement: > assert mydata == 23 E assert 42 == 23 - test_caching.py:19: AssertionError + test_caching.py:26: AssertionError -------------------------- Captured stdout setup --------------------------- running expensive computation... ========================= short test summary info ========================== @@ -270,7 +270,7 @@ the cache and nothing will be printed: > assert mydata == 23 E assert 42 == 23 - test_caching.py:19: AssertionError + test_caching.py:26: AssertionError ========================= short test summary info ========================== FAILED test_caching.py::test_function - assert 42 == 23 1 failed in 0.12s diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index 35e4a02a69f..c89d38c4bab 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -1423,7 +1423,7 @@ Running the above tests results in the following test IDs being used: rootdir: /home/sweet/project collected 12 items - + diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 7972663421c..ea7eff68f5d 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -3448,7 +3448,8 @@ All the command-line flags can also be obtained by running ``pytest --help``:: verbosity level. -q, --quiet Decrease verbosity --verbosity=VERBOSE Set verbosity. Default: 0. - -r chars Show extra test summary info as specified by chars: + -r, --report-chars chars + Show extra test summary info as specified by chars: (f)ailed, (E)rror, (s)kipped, (x)failed, (X)passed, (p)assed, (P)assed with output, (a)ll except passed (p/P), or (A)ll. (w)arnings are enabled by default @@ -3480,8 +3481,8 @@ All the command-line flags can also be obtained by running ``pytest --help``:: -W, --pythonwarnings PYTHONWARNINGS Set which warnings to report, see -W option of Python itself - --max-warnings=num Exit with error if the number of warnings exceeds - this threshold + --max-warnings=num Exit with error if all tests pass but the number of + warnings exceeds this threshold collection: --collect-only, --co Only collect tests, don't execute them @@ -3605,8 +3606,8 @@ All the command-line flags can also be obtained by running ``pytest --help``:: warnings.filterwarnings. Processed after -W/--pythonwarnings. max_warnings (string): - Maximum number of warnings allowed before failing - the test run + Exit with error if all tests pass but the number of + warnings exceeds this threshold norecursedirs (args): Directory patterns to avoid for recursion testpaths (args): Directories to search for tests when no files or directories are given on the command line @@ -3662,6 +3663,9 @@ All the command-line flags can also be obtained by running ``pytest --help``:: truncation_limit_chars (string): Set threshold of CHARS after which truncation will take effect + assertion_text_diff_style (string): + Choose how pytest renders diffs for string equality + assertions: ndiff or block verbosity_assertions (string): Specify a verbosity level for assertions, overriding the main level. Higher levels will provide more