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

11 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-04 08:29 +0000

1from fastapi import FastAPI 1abcdefg

2from fastapi.testclient import TestClient 1abcdefg

3 

4app = FastAPI() 1abcdefg

5 

6 

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

8async def read_main(): 1abcdefg

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

10 

11 

12client = TestClient(app) 1abcdefg

13 

14 

15def test_read_main(): 1abcdefg

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

17 assert response.status_code == 200 1hijklmnopqrstu

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