Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions doc/en/historical-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,31 @@ 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()``
----------------------
Expand Down