Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pytest_bdd/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ def params(self) -> tuple[str, ...]:
def render(self, context: Mapping[str, Any]):
def replacer(m: Match):
varname = m.group(1)
return str(context[varname])
try:
return str(context[varname])
except KeyError:
return f"<{varname}>"

return STEP_PARAM_RE.sub(replacer, self.name)

Expand Down
33 changes: 33 additions & 0 deletions tests/feature/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,36 @@ def check_stuff(stuff):
"*Tearing down...*",
]
)


def test_missing_substitution_steps(testdir):
testdir.makefile(
".feature",
steps=textwrap.dedent(
"""\
Feature: Missing substitutions are left as is

Scenario: Missing substitution
Given Missing <substitution>
"""
),
)

testdir.makepyfile(
textwrap.dedent(
"""\
from pytest_bdd import given, when, then, scenario

@scenario("steps.feature", "Missing substitution")
def test_steps():
pass

@given('Missing <substitution>')
def foo():
pass

"""
)
)
result = testdir.runpytest()
result.assert_outcomes(passed=1, failed=0)