Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lazy-fixture on fixture whose argument is a fixture #61

Open
sandeep-gh opened this issue Jul 7, 2023 · 1 comment
Open

lazy-fixture on fixture whose argument is a fixture #61

sandeep-gh opened this issue Jul 7, 2023 · 1 comment

Comments

@sandeep-gh
Copy link

I am missing something very obvious: Below is my use case as seems best to explain with example:

  • a fixture to create a bunch of parameters
@pytest.fixture(name="hc_tags", params=[("Label", TR.LabelMixin)])
def _hc_tags(request):
    return request.param

  • create derived object from parameter
@pytest.fixture
def Type_HC_Passive_NoStub(hc_tags):
...
return obj
  • create a test parametrized with above fixture (using lazy_fixture):
@pytest.mark.parametrize("Type_HCBase_NoStub",
                         [(lazy_fixture('Type_HC_Passive_NoStub'))]
                         )
def test_lazy(Type_HCBase_NoStub):
    print (Type_HCBase_NoStub)
    assert True

The above results in error:

============================== ERRORS ===============================
_________ ERROR collecting tests_internal/test_internal.py __________
In test_lazy: function uses no fixture 'hc_tags'
====================== short test summary info ======================
ERROR test_internal.py
!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!
========================= 1 error in 1.94s ==========================

Isn't fixture recursive resolution not allowed with lazy fixtures? If so, what is the workaround.

@dboeckenhoff
Copy link

Have the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants