(pytester)
| 121 | |
| 122 | |
| 123 | def test_step_functions_same_parser(pytester): |
| 124 | pytester.makefile( |
| 125 | ".feature", |
| 126 | target_fixture=textwrap.dedent( |
| 127 | """\ |
| 128 | Feature: A feature |
| 129 | Scenario: A scenario |
| 130 | Given there is a foo with value "(?P<value>\\w+)" |
| 131 | And there is a foo with value "testfoo" |
| 132 | When pass |
| 133 | Then pass |
| 134 | """ |
| 135 | ), |
| 136 | ) |
| 137 | pytester.makepyfile( |
| 138 | textwrap.dedent( |
| 139 | """\ |
| 140 | import pytest |
| 141 | from pytest_bdd import given, when, then, scenarios, parsers |
| 142 | from pytest_bdd.utils import dump_obj |
| 143 | |
| 144 | scenarios("target_fixture.feature") |
| 145 | |
| 146 | STEP = r'there is a foo with value "(?P<value>\\w+)"' |
| 147 | |
| 148 | @given(STEP) |
| 149 | def _(): |
| 150 | dump_obj(('str',)) |
| 151 | |
| 152 | @given(parsers.re(STEP)) |
| 153 | def _(value): |
| 154 | dump_obj(('re', value)) |
| 155 | |
| 156 | @when("pass") |
| 157 | @then("pass") |
| 158 | def _(): |
| 159 | pass |
| 160 | """ |
| 161 | ) |
| 162 | ) |
| 163 | result = pytester.runpytest("-s") |
| 164 | result.assert_outcomes(passed=1) |
| 165 | |
| 166 | [first_given, second_given] = collect_dumped_objects(result) |
| 167 | assert first_given == ("str",) |
| 168 | assert second_given == ("re", "testfoo") |
| 169 | |
| 170 | |
| 171 | def test_user_implements_a_step_generator(pytester): |
nothing calls this directly
no test coverage detected
searching dependent graphs…