Add changelog and note

This commit is contained in:
Sadra Barikbin 2023-09-17 10:31:17 +03:30
parent fba008cf29
commit 3a88adb320
4 changed files with 22 additions and 5 deletions

View File

@ -0,0 +1,3 @@
Accessing ``item.funcargs`` with fixture names other than the direct ones, i.e. the direct args, the ones with ``autouse`` and the ones with ``usefixtures`` issues a warning.
This will become an error in pytest 9.

View File

@ -278,6 +278,20 @@ The accompanying ``py.path.local`` based paths have been deprecated: plugins whi
resolved in future versions as we slowly get rid of the :pypi:`py`
dependency (see :issue:`9283` for a longer discussion).
.. _item-funcargs-deprecation:
Accessing ``item.funcargs`` with not directly requested fixture names
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 8.0
.. versionremoved:: 9.0
Accessing ``item.funcargs`` with not directly requested fixture names issues warning and
will be erroneous starting from pytest 9. Directly requested fixtures are the direct args
to the test, the ``usefixtures`` fixtures and the ``autouse`` ones.
To request fixtures other than the directly requested ones, user could use
``request.getfixturevalue`` instead.
.. _nose-deprecation:

View File

@ -50,10 +50,10 @@ MARKED_FIXTURE = PytestRemovedIn9Warning(
)
ITEM_FUNCARGS_MEMBERS = PytestRemovedIn9Warning(
"Access to names other than initialnames i.e., direct args,"
" the ones with `usefixture` or the ones with `autouse` through "
"`item.funcargs` is deprecated and will raise `KeyError` from "
"pytest 9. Please use `request.getfixturevalue` instead."
"Accessing `item.funcargs` with a fixture name not directly requested"
" by the item, through a direct argument, `usefixtures` marker or"
" an `autouse` fixture, is deprecated and will raise KeyError starting"
" from pytest 9. Please use request.getfixturevalue instead."
)
# You want to make some `__init__` or function "private".

View File

@ -217,7 +217,7 @@ def test_deprecated_access_to_item_funcargs(pytester: Pytester) -> None:
test.setup()
with pytest.warns(
pytest.PytestRemovedIn9Warning,
match=r"Access to names other than initialnames",
match=r"Accessing `item.funcargs` with a fixture",
) as record:
test.funcargs["fixture1"]
assert len(record) == 1