pytest-dev / pytest-bdd

BDD library for the py.test runner
https://pytest-bdd.readthedocs.io/en/latest/
MIT License
1.3k stars 219 forks source link

pytest-bdd steps only support fixture using @pytest.fixture, but do not support fixture generated by pytest_generate_tests function #620

Open leehin opened 1 year ago

leehin commented 1 year ago

@given("test generated fixture") def test_generated_fixture(normal_fixture, generated_fixture): print(fixture) print(generated_fixture) return 1

@pytest.fixture def normal_fixture(): return 1

defined pytest_generated_tests in conftest.py

def pytest_generate_tests(metafunc): if "generated_fixture" in metafunc.fixturenames: metafunc.parametrize("generated_fixture", [1, 2, 3])

will result in error E fixture 'generated_fixture' not found