(pytester)
| 109 | |
| 110 | |
| 111 | def test_argument_in_when(pytester): |
| 112 | pytester.makefile( |
| 113 | ".feature", |
| 114 | arguments=textwrap.dedent( |
| 115 | """\ |
| 116 | Feature: Step arguments |
| 117 | Scenario: Argument in when, step 1 |
| 118 | Given I have an argument 1 |
| 119 | When I get argument 5 |
| 120 | Then My argument should be 5 |
| 121 | """ |
| 122 | ), |
| 123 | ) |
| 124 | |
| 125 | pytester.makepyfile( |
| 126 | textwrap.dedent( |
| 127 | r""" |
| 128 | import pytest |
| 129 | from pytest_bdd import parsers, given, when, then, scenario |
| 130 | |
| 131 | |
| 132 | @pytest.fixture |
| 133 | def arguments(): |
| 134 | return dict() |
| 135 | |
| 136 | |
| 137 | @scenario("arguments.feature", "Argument in when, step 1") |
| 138 | def test_arguments(): |
| 139 | pass |
| 140 | |
| 141 | @given(parsers.re(r"I have an argument (?P<arg>\d+)")) |
| 142 | def _(arguments, arg): |
| 143 | arguments["arg"] = arg |
| 144 | |
| 145 | |
| 146 | @when(parsers.re(r"I get argument (?P<arg>\d+)")) |
| 147 | def _(arguments, arg): |
| 148 | arguments["arg"] = arg |
| 149 | |
| 150 | |
| 151 | @then(parsers.re(r"My argument should be (?P<arg>\d+)")) |
| 152 | def _(arguments, arg): |
| 153 | assert arguments["arg"] == arg |
| 154 | |
| 155 | """ |
| 156 | ) |
| 157 | ) |
| 158 | result = pytester.runpytest() |
| 159 | result.assert_outcomes(passed=1) |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…