Skip to content

Commit 3a88adb

Browse files
Add changelog and note
1 parent fba008c commit 3a88adb

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

changelog/11284.deprecation.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
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.
2+
3+
This will become an error in pytest 9.

doc/en/deprecations.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,20 @@ The accompanying ``py.path.local`` based paths have been deprecated: plugins whi
278278
resolved in future versions as we slowly get rid of the :pypi:`py`
279279
dependency (see :issue:`9283` for a longer discussion).
280280

281+
.. _item-funcargs-deprecation:
282+
283+
Accessing ``item.funcargs`` with not directly requested fixture names
284+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
285+
286+
.. deprecated:: 8.0
287+
.. versionremoved:: 9.0
288+
289+
Accessing ``item.funcargs`` with not directly requested fixture names issues warning and
290+
will be erroneous starting from pytest 9. Directly requested fixtures are the direct args
291+
to the test, the ``usefixtures`` fixtures and the ``autouse`` ones.
292+
293+
To request fixtures other than the directly requested ones, user could use
294+
``request.getfixturevalue`` instead.
281295

282296
.. _nose-deprecation:
283297

src/_pytest/deprecated.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
)
5151

5252
ITEM_FUNCARGS_MEMBERS = PytestRemovedIn9Warning(
53-
"Access to names other than initialnames i.e., direct args,"
54-
" the ones with `usefixture` or the ones with `autouse` through "
55-
"`item.funcargs` is deprecated and will raise `KeyError` from "
56-
"pytest 9. Please use `request.getfixturevalue` instead."
53+
"Accessing `item.funcargs` with a fixture name not directly requested"
54+
" by the item, through a direct argument, `usefixtures` marker or"
55+
" an `autouse` fixture, is deprecated and will raise KeyError starting"
56+
" from pytest 9. Please use request.getfixturevalue instead."
5757
)
5858

5959
# You want to make some `__init__` or function "private".

testing/deprecated_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def test(fixture2):
217217
test.setup()
218218
with pytest.warns(
219219
pytest.PytestRemovedIn9Warning,
220-
match=r"Access to names other than initialnames",
220+
match=r"Accessing `item.funcargs` with a fixture",
221221
) as record:
222222
test.funcargs["fixture1"]
223223
assert len(record) == 1

0 commit comments

Comments
 (0)