Coverage for docs_src / app_testing / tutorial001_py310.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-12 18:15 +0000

1from fastapi import FastAPI 1abcd

2from fastapi.testclient import TestClient 1abcd

3 

4app = FastAPI() 1abcd

5 

6 

7@app.get("/") 1abcd

8async def read_main(): 1abcd

9 return {"msg": "Hello World"} 1efghij

10 

11 

12client = TestClient(app) 1abcd

13 

14 

15def test_read_main(): 1abcd

16 response = client.get("/") 1efghij

17 assert response.status_code == 200 1efghij

18 assert response.json() == {"msg": "Hello World"} 1efghij