-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace deprecated startup and shutdown events with lifespan
- Loading branch information
Showing
3 changed files
with
23 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
import logging | ||
|
||
import pytest | ||
from fastapi import FastAPI | ||
|
||
from app.main import shutdown_event, startup_event | ||
from app.main import lifespan | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_startup_event_logging(caplog): | ||
async def test_lifespan_logging(caplog): | ||
caplog.set_level(logging.INFO) | ||
await startup_event() | ||
assert "Starting up..." in caplog.text | ||
app = FastAPI() | ||
|
||
async with lifespan(app): | ||
assert "Starting up..." in caplog.text | ||
|
||
@pytest.mark.asyncio | ||
async def test_shutdown_event_logging(caplog): | ||
caplog.set_level(logging.INFO) | ||
await shutdown_event() | ||
assert "Shutting down..." in caplog.text |