diff --git a/pytest_bdd/parser.py b/pytest_bdd/parser.py index 8cbfbb14..81ddec38 100644 --- a/pytest_bdd/parser.py +++ b/pytest_bdd/parser.py @@ -357,8 +357,16 @@ def params(self): return tuple(frozenset(STEP_PARAM_RE.findall(self.name))) def render(self, context: typing.Mapping[str, typing.Any]): + example_params = set() + if self.scenario: + example_params |= set(self.scenario.feature.examples.example_params) + if hasattr(self.scenario, "examples"): + example_params |= set(self.scenario.examples.example_params) + def replacer(m: typing.Match): varname = m.group(1) + if varname not in example_params: + return m.group(0) return str(context[varname]) return STEP_PARAM_RE.sub(replacer, self.name) diff --git a/tests/feature/test_steps.py b/tests/feature/test_steps.py index 63ed1498..4c9a7fd8 100644 --- a/tests/feature/test_steps.py +++ b/tests/feature/test_steps.py @@ -11,12 +11,12 @@ def test_steps(testdir): are not mandatory in some cases. Scenario: Executed step by step - Given I have a foo fixture with value "foo" + Given I have a foo fixture with value "