Open chrcoen opened 2 months ago
I also setup an example to report the issue and stumbled upon this one.
Feature: Numbers
Scenario: Increment
Given the number "1"
And the number is "1"
When the number is incremented
Then the number is "2"
from pytest_bdd import given, parsers, scenario, then, when
@scenario("numbers.feature", "Increment")
def test_increment():
pass
@given(parsers.parse('the number "{value:d}"'), target_fixture="number")
def the_number(value):
return value
@when("the number is incremented", target_fixture="number")
def the_number_is_changed_to(number):
number += 1
return number
@given(parsers.parse('the number is "{expected_value:d}"'))
@then(parsers.parse('the number is "{expected_value:d}"'))
def the_number_is(expected_value, number):
assert expected_value == number
While And the number is "1"
is fine the Then the number is "2"
step feiles since the target fixture number
is not correctly updated.
Confirming that pytest == 8.0.2
still works. Thanks @chrcoen for this important detail.
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.
It seems like the target fixture values are chached and the when step is not executed again.