mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-14 10:45:54 -04:00
✨ Add docs and tests for Python 3.9 and Python 3.10 (#3712)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
This commit is contained in:
committed by
GitHub
parent
83f6781037
commit
d08a062ee2
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from ...utils import needs_py310
|
||||
|
||||
|
||||
@needs_py310
|
||||
def test():
|
||||
from docs_src.background_tasks.tutorial002_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
log = Path("log.txt")
|
||||
if log.is_file():
|
||||
os.remove(log) # pragma: no cover
|
||||
response = client.post("/send-notification/foo@example.com?q=some-query")
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == {"message": "Message sent"}
|
||||
with open("./log.txt") as f:
|
||||
assert "found query: some-query\nmessage to foo@example.com" in f.read()
|
||||
Reference in New Issue
Block a user