-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use the same asyncio.Task between fixtures and each test coroutine so that they can have access to the same scoped db sessions #624
Comments
I think this is a dup of #127 @rnarkk have you tried using the anyio pytest plugin? It runs async fixture setup and teardown in the same task |
@graingert Yes, I'm setting |
Actually anyio doesn't seem to run async fixtures and testcases themselves in the same task. |
@rnarkk Is there a way you could provide a minimal, runnable reproducer for your problem? Otherwise, it will be hard to pinpoint your problem. |
@rnarkk Any update on this topic? |
@seifertm What I've found is when I try to refer contextvars or async_scoped_session from different files, it never was successful so I put both of them in conftest.py then It magically worked. Thank you for check-in. |
I've been trying to get the same
sqlalchemy.ext.asyncio.AsyncSession
instances bysqlalchemy.ext.asyncio.async_scoped_session
both from the initialisation methods of the Factory classes and from pytest fixtures provided as function arguments with each testcase. The problem is that the tasks in which theasync_scoped_session
is called are different, so the sessions provided as fixtures don't hold the pending states flushed by the Factory classes.The text was updated successfully, but these errors were encountered: