Coverage for tests / test_tutorial / test_response_change_status_code / test_tutorial001.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-04-06 01:24 +0000

1from fastapi.testclient import TestClient 1efgh

2 

3from docs_src.response_change_status_code.tutorial001_py310 import app 1efgh

4 

5client = TestClient(app) 1efgh

6 

7 

8def test_path_operation(): 1efgh

9 response = client.put("/get-or-create-task/foo") 1abcd

10 print(response.content) 1abcd

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

12 assert response.json() == "Listen to the Bar Fighters" 1abcd

13 response = client.put("/get-or-create-task/bar") 1abcd

14 assert response.status_code == 201, response.text 1abcd

15 assert response.json() == "This didn't exist before" 1abcd