Async fixture teardown
See original GitHub issueHi! I have question regarding how asynchronous fixture teardown (e.g. closing a connection that was open asynchronously) is supposed to work.
When I have a fixture such as:
@pytest.fixture(scope='session')
@async_generator
async def fixture():
# ... async opening of a connection
connection = await asyncpg.connect(...)
await yield_(connection)
await connection.close()
I am getting the following error: ValueError: Async generator fixture didn't stop.Yield only once.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Is it OK to use async TearDown in Selenium NUnit tests?
Yes. It is fine for any of the NUnit setup or teardown methods to be marked as async methods. There are many existing...
Read more >Automating tests for async services using pytest
Setup and TearDown for pytest-asyncio: ... A way around is to create a class-level fixture, then auto-use it on your test cases to...
Read more >async test patterns for Pytest - Anthony Shaw
I've found async testing in both pytest and unittest painful, confusing and ... The pytest-asyncio extension also enables async fixtures, ...
Read more >Setup and Teardown - Jest
This can be especially bothersome when the setup is asynchronous, so you can't do it inline. Jest provides beforeAll and afterAll hooks to ......
Read more >Testing with AnyIO — AnyIO 3.6.2 documentation
For async generator based fixtures, the test runner spawns a task that handles both the setup and teardown phases to enable context-sensitive code...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is there a solution for Python 3.5, too? Because it was nice to be able to confirm that packages work with Python 3.5, too.
I can confirm that with Python 3.6, it works: