Coverage for tests/test_tutorial/test_settings/test_tutorial001.py: 100%
15 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-09-09 09:16 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-09-09 09:16 +0000
1import importlib 1abcdef
3import pytest 1abcdef
4from fastapi.testclient import TestClient 1abcdef
5from pytest import MonkeyPatch 1abcdef
7from ...utils import needs_pydanticv1, needs_pydanticv2 1abcdef
10@pytest.fixture( 1abcdef
11 name="app",
12 params=[
13 pytest.param("tutorial001", marks=needs_pydanticv2),
14 pytest.param("tutorial001_pv1", marks=needs_pydanticv1),
15 ],
16)
17def get_app(request: pytest.FixtureRequest, monkeypatch: MonkeyPatch): 1abcdef
18 monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com") 1abcdef
19 mod = importlib.import_module(f"docs_src.settings.{request.param}") 1abcdef
20 return mod.app 1abcdef
23def test_settings(app): 1abcdef
24 client = TestClient(app) 1ghijkl
25 response = client.get("/info") 1ghijkl
26 assert response.status_code == 200, response.text 1ghijkl
27 assert response.json() == { 1ghijkl
28 "app_name": "Awesome API",
29 "admin_email": "admin@example.com",
30 "items_per_user": 50,
31 }