Closed YannickJadoul closed 5 years ago
@YannickJadoul, thanks a lot! It looks really good. I will definitely merge this PR but I need a little bit of time to get familiar with the new code and understand how it solves the limitations.
@TvoroG Great! Thank you :-) Thanks as well for making this library in the first place, by the way.
If you have any questions, do let me know.
I can give a quick, intuitive summary of the changes if that helps:
fm.getfixturedefs
, I call fm.getfixtureclosure
and apply the parametrization for all of these, in a loop. This fixes the case where lazily-used fixtures have parametrized subfixtures.metafunc.definition.parent
. Before pytest 3.10.0, it's really hard to get hold of this (which is why you wrote get_nodeid
before, I'm guessing?), but we can intercept that node from the pytest_pycollect_makeitem
hook, since during this hook, pytest_generate_tests
will be called.pytest_fixture_setup
hook, where we resolve request.param
if it is a lazy fixture placeholder.I am now also thinking that I will make the last commit into a different PR, since it has a different purpose. This should make it easier to review, as well :-)
This PR should allow for more complex combinations of lazy fixtures:
lazy_fixture
s that require other parametrized fixtures themselves, this would now result in an error (see testtest_lazy_fixtures_with_subfixtures
) This should also fix issue #23, as demonstrated in the added testtest_issues23
.lazy_fixture
s would not have these lazy fixtures resolved (resulting in type errors; see testtest_lazy_fixtures_in_subfixture
). This is similar to PR #28, except that it resolves nestedlazy_fixture
s in the parameters instead of as return values (as I am assuming is the aim of this project?).EDIT: Oh, yes, the first commit of this PR also fixes a few existing tests, after direct application of marks inside
parametrize
values were deprecated/removed.