From be7a0e0c37f68f6d31386ffa7da112956edd5d8e Mon Sep 17 00:00:00 2001 From: Maxime Grenu Date: Thu, 19 Feb 2026 15:13:42 +0100 Subject: [PATCH 1/2] doc: fix removed pytest.config reference in historical-notes pytest.config was removed in pytest 5.0, but the documentation on 'Conditions as strings instead of booleans' still showed it as the modern equivalent of string-based skipif conditions. Replace the broken example with the current recommended approach using request.config (via an autouse fixture), and add a note pointing to the removal notice in the deprecations page. Fixes #12377 --- doc/en/historical-notes.rst | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/en/historical-notes.rst b/doc/en/historical-notes.rst index 600aed4c17b..0af68461a23 100644 --- a/doc/en/historical-notes.rst +++ b/doc/en/historical-notes.rst @@ -263,20 +263,30 @@ configuration value which you might have added: @pytest.mark.skipif("not config.getvalue('db')") def test_function(): ... -The equivalent with "boolean conditions" is: +The equivalent with "boolean conditions" using ``request.config`` is: .. code-block:: python - @pytest.mark.skipif(not pytest.config.getvalue("db"), reason="--db was not specified") + @pytest.fixture(autouse=True) + def skip_if_no_db(request): + if not request.config.getoption("--db", default=False): + pytest.skip("--db was not specified") + def test_function(): pass .. note:: - You cannot use ``pytest.config.getvalue()`` in code + ``pytest.config`` was removed in pytest 5.0. Use ``request.config`` + (via the ``request`` fixture) or the ``pytestconfig`` fixture instead. + See :ref:`pytest.config global deprecated` for details. + +.. note:: + + You cannot use ``request.config.getoption()`` in code imported before pytest's argument parsing takes place. For example, ``conftest.py`` files are imported before command line parsing and thus - ``config.getvalue()`` will not execute correctly. + ``request.config.getoption()`` will not execute correctly at module level. ``pytest.set_trace()`` ---------------------- From 9c79dfe724380f6b1bb850f7c6be1fe7d79b5309 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 14:14:21 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/en/historical-notes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/en/historical-notes.rst b/doc/en/historical-notes.rst index 0af68461a23..5877923bf55 100644 --- a/doc/en/historical-notes.rst +++ b/doc/en/historical-notes.rst @@ -272,6 +272,7 @@ The equivalent with "boolean conditions" using ``request.config`` is: if not request.config.getoption("--db", default=False): pytest.skip("--db was not specified") + def test_function(): pass