pytest-bdd
pytest-bdd copied to clipboard
Multiple step scenarios targeting the same fixture doesn't update the fixture
trafficstars
Env: Pytest 8.1.1 Pytest-bdd 7.1.2
more details
============================================================= test session starts =============================================================
platform linux -- Python 3.10.6, pytest-8.1.1, pluggy-1.5.0
cachedir: .pytest_cache
metadata: {'Python': '3.10.6', 'Platform': 'Linux-5.15.146.1-microsoft-standard-WSL2-x86_64-with-glibc2.35', 'Packages': {'pytest': '8.1.1', 'pluggy': '1.5.0'}, 'Plugins': {'metadata': '3.1.1', 'html': '4.1.1', 'retry': '1.6.2', 'syrupy': '4.6.1', 'bdd-html': '0.1.14a0', 'allure-pytest-bdd': '2.13.5', 'bdd': '7.1.2', 'check': '2.2.5'}, 'JAVA_HOME': '/usr/lib/jvm/java-17-openjdk-amd64'}
configfile: pyproject.toml
testpaths: tests
plugins: metadata-3.1.1, html-4.1.1, retry-1.6.2, syrupy-4.6.1, bdd-html-0.1.14a0, allure-pytest-bdd-2.13.5, bdd-7.1.2, check-2.2.5
Issue: when having multiple steps pointing to the same target_fixture, it's not getting updated, it seems it is only updated once when it is set for the first time. On pytest 7.4.2 and pytest-bdd 7.0.0 this works as expected
code to reproduce.
@when("it's AB", target_fixture="test")
def ab():
return "AB"
@when("result is AB")
def res1(test):
assert test == "AB"
@when("it's CD", target_fixture="test")
def cd():
return "CD"
@when("result is CD")
def res2(test):
assert test == "CD"
Scenario: Test
When it's AB
When result is AB
When it's CD
When result is CD
I am expecting the scenario above to pass, but it will fail
assert test == "CD"
E AssertionError: assert 'AB' == 'CD'
E
E - CD
E + AB