Coverage for tests / test_tutorial / test_background_tasks / test_tutorial001.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
1import os 1abcd
2from pathlib import Path 1abcd
4from fastapi.testclient import TestClient 1abcd
6from docs_src.background_tasks.tutorial001_py310 import app 1abcd
7from tests.utils import workdir_lock 1abcd
9client = TestClient(app) 1abcd
12@workdir_lock 1abcd
13def test(): 1abcd
14 log = Path("log.txt") 1efgh
15 if log.is_file(): 1efgh
16 os.remove(log) # pragma: no cover
17 response = client.post("/send-notification/[email protected]") 1efgh
18 assert response.status_code == 200, response.text 1efgh
19 assert response.json() == {"message": "Notification sent in the background"} 1efgh
20 with open("./log.txt") as f: 1efgh
21 assert "notification for [email protected]: some notification" in f.read() 1efgh