TvoroG / pytest-lazy-fixture

It helps to use fixtures in pytest.mark.parametrize
MIT License
375 stars 29 forks source link

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

Open sandeep-gh opened 1 year ago

sandeep-gh commented 1 year ago

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

- 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 commented 9 months ago

Have the same issue