pytest-dev / pytest-dev/pytest-bdd

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

Open
#620 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
251
Avg merge
43m
Merged PRs (30d)
2

Description

@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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the shown @given example with normal_fixture and generated_fixture, then inspect how pytest-bdd resolves step arguments alongside pytest_generate_tests in conftest.py. Done means the example collects and runs with generated_fixture values 1, 2, and 3 without the “fixture not found” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.