Skip to content

Commit bf7971a

Browse files
committed
Make sure we test what the "given" step receives
Also, no need for this to use scenario outlines.
1 parent f5c3faa commit bf7971a

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

tests/feature/test_scenario.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -368,44 +368,34 @@ def _():
368368
]
369369

370370

371-
def test_default_value_in_not_parsed(pytester):
372-
"""Test that angular brackets are not parsed for "Scenario"s.
373-
374-
(They should be parsed only when used in "Scenario Outline")
375-
376-
"""
371+
def test_default_value_is_used_as_fallback(pytester):
372+
"""Test that the default value for a step implementation is only used as a fallback."""
377373
pytester.makefile(
378374
".feature",
379375
simple="""
380376
Feature: Simple feature
381-
Scenario: Simple scenario
382-
Given a user with username
383-
Then check username defaultuser
377+
Scenario: Step using default arg
378+
Given a user with default username
384379
385-
Scenario Outline: Outlined scenario
386-
Given a user with username <username>
387-
Then check username <username>
388-
389-
Examples:
390-
| username |
391-
| user1 |
380+
Scenario: Step using explicit value
381+
Given a user with username "user1"
392382
""",
393383
)
394384
pytester.makepyfile(
395385
"""
396386
from pytest_bdd import scenarios, given, then, parsers
387+
from pytest_bdd.utils import dump_obj
397388
398389
scenarios("simple.feature")
399390
400-
@given('a user with username', target_fixture="user")
401-
@given(parsers.parse('a user with username {username}'), target_fixture="user")
391+
@given('a user with default username', target_fixture="user")
392+
@given(parsers.parse('a user with username "{username}"'), target_fixture="user")
402393
def create_user(username="defaultuser"):
403-
return username
394+
dump_obj(username)
404395
405-
@then(parsers.parse("check username {username}"))
406-
def _(user, username):
407-
assert user == username
408396
"""
409397
)
410-
result = pytester.runpytest()
398+
result = pytester.runpytest("-s")
411399
result.assert_outcomes(passed=2)
400+
401+
assert collect_dumped_objects(result) == ["defaultuser", "user1"]

0 commit comments

Comments
 (0)