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

14 statements  

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

1import importlib 1abcd

2 

3import pytest 1abcd

4from fastapi.testclient import TestClient 1abcd

5from pytest import MonkeyPatch 1abcd

6 

7 

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

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

10 monkeypatch.setenv("ADMIN_EMAIL", "[email protected]") 1ijkl

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

12 return mod.app 1ijkl

13 

14 

15def test_settings(app): 1abcd

16 client = TestClient(app) 1efgh

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

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

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

20 "app_name": "Awesome API", 

21 "admin_email": "[email protected]", 

22 "items_per_user": 50, 

23 }