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

11 statements  

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

1from fastapi.testclient import TestClient 1ghijkl

2from pytest import MonkeyPatch 1ghijkl

3 

4from ...utils import needs_pydanticv2 1ghijkl

5 

6 

7@needs_pydanticv2 1ghijkl

8def test_settings(monkeypatch: MonkeyPatch): 1ghijkl

9 monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com") 1abcdef

10 from docs_src.settings.tutorial001 import app 1abcdef

11 

12 client = TestClient(app) 1abcdef

13 response = client.get("/info") 1abcdef

14 assert response.status_code == 200, response.text 1abcdef

15 assert response.json() == { 1abcdef

16 "app_name": "Awesome API", 

17 "admin_email": "admin@example.com", 

18 "items_per_user": 50, 

19 }