Skip to content

Commit 7393c8f

Browse files
author
yunusyun
committed
test: add test case for scenario
1 parent cd471db commit 7393c8f

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/feature/test_scenario.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,46 @@ def _():
279279
("given", "che uso uno step con ", "esempio 2"),
280280
("then", "va tutto bene"),
281281
]
282+
283+
284+
def test_default_value_in_not_parsed(pytester):
285+
"""Test that angular brackets are not parsed for "Scenario"s.
286+
287+
(They should be parsed only when used in "Scenario Outline")
288+
289+
"""
290+
pytester.makefile(
291+
".feature",
292+
simple="""
293+
Feature: Simple feature
294+
Scenario: Simple scenario
295+
Given a user with username
296+
Then check username defaultuser
297+
298+
Scenario Outline: Outlined scenario
299+
Given a user with username <username>
300+
Then check username <username>
301+
302+
Examples:
303+
| username |
304+
| user1 |
305+
""",
306+
)
307+
pytester.makepyfile(
308+
"""
309+
from pytest_bdd import scenarios, given, then, parsers
310+
311+
scenarios("simple.feature")
312+
313+
@given('a user with username', target_fixture="user")
314+
@given(parsers.parse('a user with username {username}'), target_fixture="user")
315+
def create_user(username="defaultuser"):
316+
return username
317+
318+
@then(parsers.parse("check username {username}"))
319+
def _(user, username):
320+
assert user == username
321+
"""
322+
)
323+
result = pytester.runpytest()
324+
result.assert_outcomes(passed=2)

0 commit comments

Comments
 (0)