Coverage for tests / test_tutorial / test_custom_response / test_tutorial005.py: 100%

12 statements  

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

1from fastapi.testclient import TestClient 1abcd

2from inline_snapshot import snapshot 1abcd

3 

4from docs_src.custom_response.tutorial005_py310 import app 1abcd

5 

6client = TestClient(app) 1abcd

7 

8 

9def test_get(): 1abcd

10 response = client.get("/") 1efg

11 assert response.status_code == 200, response.text 1efg

12 assert response.text == "Hello World" 1efg

13 

14 

15def test_openapi_schema(): 1abcd

16 response = client.get("/openapi.json") 1hij

17 assert response.status_code == 200, response.text 1hij

18 assert response.json() == snapshot( 1hij

19 { 

20 "openapi": "3.1.0", 

21 "info": {"title": "FastAPI", "version": "0.1.0"}, 

22 "paths": { 

23 "/": { 

24 "get": { 

25 "summary": "Main", 

26 "operationId": "main__get", 

27 "responses": { 

28 "200": { 

29 "description": "Successful Response", 

30 "content": { 

31 "text/plain": {"schema": {"type": "string"}} 

32 }, 

33 } 

34 }, 

35 } 

36 } 

37 }, 

38 } 

39 )