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

14 statements  

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

1import importlib 1abdc

2 

3import pytest 1abdc

4from fastapi.testclient import TestClient 1abdc

5from pytest import MonkeyPatch 1abdc

6 

7 

8@pytest.fixture(name="app", params=[pytest.param("tutorial001_py310")]) 1abdc

9def get_app(request: pytest.FixtureRequest, monkeypatch: MonkeyPatch): 1abdc

10 monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com") 1abc

11 mod = importlib.import_module(f"docs_src.settings.{request.param}") 1abc

12 return mod.app 1abc

13 

14 

15def test_settings(app): 1abdc

16 client = TestClient(app) 1efg

17 response = client.get("/info") 1efg

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

19 assert response.json() == { 1efg

20 "app_name": "Awesome API", 

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

22 "items_per_user": 50, 

23 }