mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
move await engine.dispose() to test client
This commit is contained in:
parent
bec67cf98b
commit
14eef23f85
@ -32,3 +32,6 @@ async def client() -> AsyncClient:
|
|||||||
) as client:
|
) as client:
|
||||||
await start_db()
|
await start_db()
|
||||||
yield client
|
yield client
|
||||||
|
# for AsyncEngine created in function scope, close and
|
||||||
|
# clean-up pooled connections
|
||||||
|
await engine.dispose()
|
||||||
|
@ -31,6 +31,4 @@ async def get_db() -> AsyncGenerator:
|
|||||||
raise ex
|
raise ex
|
||||||
finally:
|
finally:
|
||||||
await session.close()
|
await session.close()
|
||||||
# for AsyncEngine created in function scope, close and
|
|
||||||
# clean-up pooled connections
|
|
||||||
await engine.dispose()
|
|
||||||
|
@ -17,6 +17,7 @@ app.include_router(nonsense_router)
|
|||||||
async def start_db():
|
async def start_db():
|
||||||
async with engine.begin() as conn:
|
async with engine.begin() as conn:
|
||||||
await conn.run_sync(Base.metadata.create_all)
|
await conn.run_sync(Base.metadata.create_all)
|
||||||
|
await engine.dispose()
|
||||||
|
|
||||||
|
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user