Skip to content

Commit 5694c57

Browse files
committed
Fix generate-missing for parsed fixtures
1 parent 0d43cc4 commit 5694c57

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pytest_bdd/generation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def _find_step_fixturedef(fixturemanager, item, name, type_):
120120
if not fixturedefs:
121121
name = find_argumented_step_fixture_name(name, type_, fixturemanager)
122122
if name:
123-
return _find_step_fixturedef(fixturemanager, item, name, type_)
123+
return fixturemanager._arg2fixturedefs.get(name, None)
124124
else:
125125
return fixturedefs
126126

tests/generation/test_generate_missing.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_generate_missing(testdir):
2525
2626
Background:
2727
Given I have a foobar
28+
And I have 3 baz
2829
2930
Scenario: Scenario tests which are already bound to the tests stay as is
3031
Given I have a bar
@@ -45,14 +46,18 @@ def test_generate_missing(testdir):
4546
"""\
4647
import functools
4748
48-
from pytest_bdd import scenario, given
49+
from pytest_bdd import scenario, given, parsers
4950
5051
scenario = functools.partial(scenario, "generation.feature")
5152
5253
@given("I have a bar")
5354
def i_have_a_bar():
5455
return "bar"
5556
57+
@given(parsers.parse("I have {n:d} baz"))
58+
def i_have_n_baz(n):
59+
return "baz"
60+
5661
@scenario("Scenario tests which are already bound to the tests stay as is")
5762
def test_foo():
5863
pass
@@ -80,6 +85,8 @@ def test_missing_steps():
8085
]
8186
)
8287

88+
assert 'Step Given "I have 3 baz" is not defined' not in result.stdout.str()
89+
8390
result.stdout.fnmatch_lines(
8491
['Step Given "I have a foobar" is not defined in the background of the feature "Missing code generation" *']
8592
)

0 commit comments

Comments
 (0)