You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like the way Pytest does this is that when it calls a fixture function (in _pytest.fixtures.call_fixture_func), and it detects that the function is a generator, then it calls request.addfinalizer to make sure the cleanup happens.
I don't think this works for us... I guess what we would need to do is to do a second pass over the the fixture tree to call some AsyncFixture.cleanup method, and then implement that for fixtures that are async generators?
Well only trouble in my example is if the async generator fixture contains itself async fixtures.
I think we can solve this by customizing _install_coroutine_fixture_if_needed to make it install CoroutineFixture for regular async fixture and a new AsyncGeneratorFixture which resolve method would only resolve the fixture's fixtures and return the async generator function ready to be used (i.e. with a partial or a wrapper function injecting it parameter fixtures).
Yeah, the problem is that in general async generator fixtures could appear anywhere in the fixture DAG, so whatever we do with them is going to need to somehow involve a recursion over that DAG.
Activity
touilleMan commentedon Dec 11, 2017
I think we can implement this in the
_bootstrap_fixture_and_run_testfunction:touilleMan commentedon Dec 11, 2017
Well only trouble in my example is if the async generator fixture contains itself async fixtures.
I think we can solve this by customizing
_install_coroutine_fixture_if_neededto make it installCoroutineFixturefor regular async fixture and a newAsyncGeneratorFixturewhichresolvemethod would only resolve the fixture's fixtures and return the async generator function ready to be used (i.e. with apartialor a wrapper function injecting it parameter fixtures).njsmith commentedon Dec 11, 2017
Yeah, the problem is that in general async generator fixtures could appear anywhere in the fixture DAG, so whatever we do with them is going to need to somehow involve a recursion over that DAG.
touilleMan commentedon Dec 15, 2017
implemented in #17