TvoroG / pytest-lazy-fixture

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

indirect fixtures #19

Closed dburton90 closed 6 years ago

dburton90 commented 7 years ago

Hi, you asked me about some example for the issue I tried to resolve by the pull request from yestrday. So I added test to test_lazyfixture.py. It is basicly about indirect lazy_fixtures in test generator, which can do some modificition (in examle it is list modificition, but in real life it is usualy some db modificition etc...). If you run tests, the new test will fail on TypeError: 'LazyFixture' object does not support indexing. Beacause LazyFixture is never inicialized. If you uncommented lines 15-24 in pytest_lazyfixture.py, the test will pass.

TvoroG commented 6 years ago

Hi, @dburton90! Thanks for the example and finding a bug. There was a problem with incorrect order of fixture initialization. I fixed it in issues19 branch. Can you please test it on your project and give some feedback if it works for you?

dburton90 commented 6 years ago

Hi thanks for changes the old test passed. But I found new test, where the error occurs again: E TypeError: unsupported operand type(s) for +: 'int' and 'LazyFixture'

If I use pytest_fixture_setup hook it works. But I am actually not sure if this behaviour is supported by pytest or if this is just side-efect.

TvoroG commented 6 years ago

Hi! Sorry for the late response :) I'll check it. Maybe there is a better solution for this problem.

TvoroG commented 6 years ago

But I am actually not sure if this behaviour is supported by pytest or if this is just side-efect.

Yeah, me too :)

Anyway, I merged my changes to master and shipped it to pypi. For now I'll close it. Feel free to reopen if there will be more problems with the plugin :)