Fix step detection for generation

This commit is contained in:
Alessio Bogon 2022-07-26 18:03:07 +02:00
parent 14df243323
commit 91fe7ed33c
2 changed files with 4 additions and 8 deletions

View File

@ -127,16 +127,9 @@ def _find_step_fixturedef(
fixturemanager: FixtureManager, item: Function, name: str, type_: str
) -> Sequence[FixtureDef[Any]] | None:
"""Find step fixturedef."""
step_fixture_name = get_step_fixture_name(name, type_)
fixturedefs = fixturemanager.getfixturedefs(step_fixture_name, item.nodeid)
if fixturedefs is not None:
return fixturedefs
with patch_argumented_step_functions(name=name, type_=type_, fixturemanager=fixturemanager, nodeid=item.nodeid):
bdd_name = get_parsed_step_fixture_name(name, type_)
fixturedefs = fixturemanager.getfixturedefs(bdd_name, item.nodeid)
if fixturedefs is not None:
return fixturedefs
return None
return fixturemanager.getfixturedefs(bdd_name, item.nodeid)
def parse_feature_files(paths: list[str], **kwargs: Any) -> tuple[list[Feature], list[ScenarioTemplate], list[Step]]:

View File

@ -79,6 +79,9 @@ def patch_argumented_step_functions(name: str, type_, fixturemanager, nodeid: st
# respect the fixture scope
fixture_defs_by_path = [(tuple(iterparentnodeids(x.baseid)), x) for x in fixturedefs]
resorted = sorted(fixture_defs_by_path, key=lambda x: x[0])
if not resorted:
yield
return
bdd_step_defs = fixturemanager._arg2fixturedefs[bdd_name] = []
for fixture_path, fixturedef in resorted: