mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-05 20:49:36 -05:00
* ✏️ Fix typo in security intro * ✨ Add testing docs and tests * 🐛 Debug Travis coverage * 🐛 Debug Travis coverage, report XML * 💚 Make Travis/Flit use same code install * ⏪ Revert Travis/Codecov debugging changes
19 lines
336 B
Python
19 lines
336 B
Python
from fastapi import FastAPI
|
|
from starlette.testclient import TestClient
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/")
|
|
async def read_main():
|
|
return {"msg": "Hello World"}
|
|
|
|
|
|
client = TestClient(app)
|
|
|
|
|
|
def test_read_main():
|
|
response = client.get("/")
|
|
assert response.status_code == 200
|
|
assert response.json() == {"msg": "Hello World"}
|