Skip to content

Commit 6df2afb

Browse files
Copilotyoutux
andauthored
Add test for no usefixtures() warning when scenario has no fixture args
Agent-Logs-Url: https://github.com/pytest-dev/pytest-bdd/sessions/6e63f920-f1b8-408c-952d-4b688cc32427 Co-authored-by: youtux <778703+youtux@users.noreply.github.com>
1 parent 349b47d commit 6df2afb

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/feature/test_scenario.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,35 @@ def _():
397397
]
398398

399399

400+
def test_no_usefixtures_warning_when_no_args(pytester):
401+
"""Test that no PytestWarning about usefixtures() without arguments is emitted
402+
when scenario functions have no arguments (e.g. when using scenarios()).
403+
404+
Regression test for https://github.com/pytest-dev/pytest-bdd/issues/XXX
405+
"""
406+
pytester.makefile(
407+
".feature",
408+
simple="""
409+
Feature: Simple feature
410+
Scenario: Simple scenario with no args
411+
Given I have a bar
412+
""",
413+
)
414+
pytester.makepyfile(
415+
"""
416+
from pytest_bdd import scenarios, given
417+
418+
scenarios("simple.feature")
419+
420+
@given("I have a bar")
421+
def _():
422+
return "bar"
423+
"""
424+
)
425+
result = pytester.runpytest("-W", "error::pytest.PytestWarning")
426+
result.assert_outcomes(passed=1)
427+
428+
400429
def test_default_value_is_used_as_fallback(pytester):
401430
"""Test that the default value for a step implementation is only used as a fallback."""
402431
pytester.makefile(

0 commit comments

Comments
 (0)