Skip to content

Commit 1b6b836

Browse files
committed
Improve warning message to indicate the node id
1 parent 0b51f91 commit 1b6b836

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/_pytest/fixtures.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,9 @@ def _getusefixturesnames(self, node: nodes.Item) -> Iterator[str]:
15661566
for marker_node, mark in node.iter_markers_with_node(name="usefixtures"):
15671567
if not mark.args:
15681568
marker_node.warn(
1569-
PytestWarning("usefixtures() without arguments has no effect")
1569+
PytestWarning(
1570+
f"usefixtures() in {node.nodeid} without arguments has no effect"
1571+
)
15701572
)
15711573
yield from mark.args
15721574

testing/python/fixtures.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,8 @@ def test_one():
14481448
)
14491449
result = pytester.runpytest()
14501450
result.stdout.fnmatch_lines(
1451-
"*PytestWarning: usefixtures() without arguments has no effect"
1451+
"*PytestWarning: usefixtures() in test_empty_usefixtures_marker.py::test_one"
1452+
" without arguments has no effect"
14521453
)
14531454

14541455
def test_usefixtures_ini(self, pytester: Pytester) -> None:

0 commit comments

Comments
 (0)