Skip to content

Commit 14997ab

Browse files
authored
feat: add examples tag to scenario tags
1 parent 01c99a6 commit 14997ab

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/pytest_bdd/parser.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def render(self, context: Mapping[str, object]) -> Scenario:
208208
Returns:
209209
Scenario: A Scenario object with steps rendered based on the context.
210210
"""
211+
example = self.find_scenario_example_from_context(context)
211212
base_steps = self.all_background_steps + self._steps
212213
scenario_steps = [
213214
Step(
@@ -227,10 +228,17 @@ def render(self, context: Mapping[str, object]) -> Scenario:
227228
name=render_string(self.name, context),
228229
line_number=self.line_number,
229230
steps=scenario_steps,
230-
tags=self.tags,
231+
tags=self.tags | example.tags if example else self.tags,
231232
description=self.description,
232233
rule=self.rule,
233234
)
235+
236+
def find_scenario_example_from_context(self, context: Mapping[str, object]) -> Examples:
237+
for example in self.examples:
238+
example_param = dict(zip(example.example_params, example.examples[0]))
239+
if example_param == context:
240+
return example
241+
return None
234242

235243

236244
@dataclass(eq=False)

0 commit comments

Comments
 (0)