Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changelog/12426.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A warning is now issued when :ref:`pytest.mark.usefixtures ref` is used without specifying any fixtures. Previously, empty usefixtures markers were silently ignored.
4 changes: 3 additions & 1 deletion src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,9 @@ def _getautousenames(self, node: nodes.Node) -> Iterator[str]:

def _getusefixturesnames(self, node: nodes.Item) -> Iterator[str]:
"""Return the names of usefixtures fixtures applicable to node."""
for mark in node.iter_markers(name="usefixtures"):
for marker_node, mark in node.iter_markers_with_node(name="usefixtures"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a automated test for this behavior and

if not mark.args:
marker_node.warn(Warning("usefixtures() is empty, so it has no effect"))
yield from mark.args

def getfixtureclosure(
Expand Down