Skip to content

Commit

Permalink
Using lifespan manager to trigger startup and shutdown events
Browse files Browse the repository at this point in the history
  • Loading branch information
TanookiVerde committed Oct 18, 2024
1 parent 11cfb6d commit ac5397d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
16 changes: 15 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ qrcode = "^7.4.2"
pyotp = "^2.9.0"
fastapi-simple-rate-limiter = "^0.0.4"
fastapi-limiter = "^0.1.6"
asgi-lifespan = "^2.1.0"


[tool.poetry.group.dev.dependencies]
Expand Down
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import random
from httpx import AsyncClient
from tortoise import Tortoise
from asgi_lifespan import LifespanManager

import scripts.database_init_table
import scripts.create_user
Expand Down Expand Up @@ -36,8 +37,9 @@ def event_loop():

@pytest.fixture(scope="session")
async def client():
async with AsyncClient(app=app, base_url="http://test") as client_object:
yield client_object
async with LifespanManager(app):
async with AsyncClient(app=app, base_url="http://test") as client_object:
yield client_object


@pytest.fixture(scope="session", autouse=True)
Expand Down

0 comments on commit ac5397d

Please sign in to comment.