pytest-bdd
pytest-bdd copied to clipboard
Re-use of target_fixture not possible anymore
trafficstars
The following test will pass in pytest=8.0.2, pytest-bdd=7.2.1, but will fail in pytest=8.1.0, pytest-bdd=7.2.1.
@given(parsers.parse('the value {value:d}'), target_fixture='x')
def step(value):
return value
@when(parsers.parse('multiplied by {value:d}'), target_fixture='result')
def step(x, value):
return x * value
@then(parsers.parse('the result should be {value:d}'))
def step(result, value):
assert result == value
Scenario: Multiply
Given the value 7
When multiplied by 7
Then the result should be 49
When multiplied by 3
Then the result should be 27
result = 49, value = 27
@then(parsers.parse('the result should be {value:d}'))
def step(result, value):
> assert result == value
E assert 49 == 27
test_multiply.py:26: AssertionError
It seems like the target fixture values are chached and the when step is not executed again.