Merge pull request #19 from grillazz/json-field-example

move await engine.dispose() to test client
This commit is contained in:
Jakub Miazek
2022-02-02 14:16:12 +01:00
committed by GitHub
3 changed files with 5 additions and 3 deletions

View File

@@ -32,3 +32,6 @@ async def client() -> AsyncClient:
) as client:
await start_db()
yield client
# for AsyncEngine created in function scope, close and
# clean-up pooled connections
await engine.dispose()

View File

@@ -31,6 +31,4 @@ async def get_db() -> AsyncGenerator:
raise ex
finally:
await session.close()
# for AsyncEngine created in function scope, close and
# clean-up pooled connections
await engine.dispose()

View File

@@ -17,6 +17,7 @@ app.include_router(nonsense_router)
async def start_db():
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
await engine.dispose()
@app.on_event("startup")