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

11 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-05-05 00:03 +0000

1from fastapi import FastAPI 1abcdef

2from fastapi.testclient import TestClient 1abcdef

3 

4app = FastAPI() 1abcdef

5 

6 

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

8async def read_main(): 1abcdef

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

10 

11 

12client = TestClient(app) 1abcdef

13 

14 

15def test_read_main(): 1abcdef

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

17 assert response.status_code == 200 1ghijklmnopqr

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