Skip to content

Commit 429205e

Browse files
committed
Make test more focussed on the issue
1 parent 781797c commit 429205e

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

tests/feature/test_outline.py

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,13 @@ def test_variable_reuse(pytester):
334334
"""\
335335
Feature: Example parameters reuse
336336
Scenario Outline: Check for example parameter re-use
337-
Given some <key> exists
338-
When I print <css_id>
339-
And I output "some value"
340-
And I echo <css_id>
341-
Then finish testing
337+
Given I get <param>
338+
When I set param to "other"
339+
Then I check <param>
342340
343341
Examples:
344-
| key | css_id |
345-
| foo | bar |
346-
| foo2 | bar2 |
342+
| param |
343+
| value |
347344
348345
"""
349346
),
@@ -353,37 +350,28 @@ def test_variable_reuse(pytester):
353350
textwrap.dedent(
354351
"""\
355352
from pytest_bdd import given, when, then, parsers, scenarios
353+
from pytest_bdd.utils import dump_obj
356354
357355
scenarios('outline.feature')
358356
359357
360-
@given(parsers.parse("some {key} exists"))
361-
def some_key_exists(key):
362-
print(f"some {key} exists")
363-
364-
365-
@when(parsers.parse('I print {css_id}'))
366-
def css_id(css_id):
367-
assert css_id in ('bar', 'bar2')
368-
358+
@given(parsers.parse('I get {param}'))
359+
def _(param):
360+
dump_obj(("param1", param))
369361
370-
@when(parsers.parse('I echo {css_id}'))
371-
def echo_val(css_id):
372-
assert css_id in ('bar', 'bar2')
373362
363+
@when(parsers.re('I set param to "(?P<param>.+)"'))
364+
def _(param):
365+
dump_obj(("param2", param))
374366
375-
@when(parsers.re('I output "(?P<css_id>.+)"'))
376-
def i_output(css_id):
377-
assert css_id == 'some value'
378367
379-
380-
@then('finish testing')
381-
def i_output():
382-
print("finished")
383-
assert True
368+
@then(parsers.parse('I check {param}'))
369+
def _(param):
370+
dump_obj(("param3", param))
384371
385372
"""
386373
)
387374
)
388375
result = pytester.runpytest("-s")
389-
result.assert_outcomes(passed=2)
376+
result.assert_outcomes(passed=1)
377+
assert collect_dumped_objects(result) == [("param1", "value"), ("param2", "other"), ("param3", "value")]

0 commit comments

Comments
 (0)