-
-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Description
Pytest allows fixtures to contain a yield, and do both setup and teardown:
@pytest.fixture
def http_server():
server = start_server()
yield
server.stop()We should support this for async fixtures.
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?
Ugh, Pytest is so confusing and complicated.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels