- Notifications
You must be signed in to change notification settings - Fork 150
Open
Labels
questionA community question, closed when inactive.A community question, closed when inactive.
Description
- GINO version:0.8.6
- Python version: 3.8
- asyncpg version: 0.18
- aiocontextvars version:0.2.2
- PostgreSQL version:
Description
I'm trying to write tests for my Quart application. As per this ticket #512 it appears that pytest-async's fixtures doesn't allow us to yield the connection and rollback and it's suggested that we do something like this within each test:
from myproject import db # this is the usual gino db @pytest.mark.asyncio async def test_something(): async with db.bind.transaction() as transaction: # - first load whatever data into the db # - then perform test logic # - finally, clean up the DB by rolling back transaction.raise_rollback()` My issue is that when I utilize Quart's builtin test_client for testing of my routes that use Gino to perform db insert/update operations, my transactions performed in the endpoints are not rolled back. Is there a way to rollback these transactions? Is another db connection being spawned and used from my Pool? Is it because a new asyncio execution context is being used by test_client?
I can provide additional code if the below example is not clear.
What I Did
async def test_something(): async with db.bind.transaction() as transaction: # - first load whatever data into the db # - then perform test logic ### The operations performed in this call are not rolled back response = await test_app.post() # - finally, clean up the DB by rolling back transaction.raise_rollback()` Metadata
Metadata
Assignees
Labels
questionA community question, closed when inactive.A community question, closed when inactive.