Coverage for tests / test_tutorial / test_settings / test_app02.py: 100%
23 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1import importlib 1abdc
2from types import ModuleType 1abdc
4import pytest 1abdc
5from pytest import MonkeyPatch 1abdc
8@pytest.fixture( 1abdc
9 name="mod_path",
10 params=[
11 pytest.param("app02_py310"),
12 pytest.param("app02_an_py310"),
13 ],
14)
15def get_mod_path(request: pytest.FixtureRequest): 1abdc
16 mod_path = f"docs_src.settings.{request.param}" 1abc
17 return mod_path 1abc
20@pytest.fixture(name="main_mod") 1abdc
21def get_main_mod(mod_path: str) -> ModuleType: 1abdc
22 main_mod = importlib.import_module(f"{mod_path}.main") 1abc
23 return main_mod 1abc
26@pytest.fixture(name="test_main_mod") 1abdc
27def get_test_main_mod(mod_path: str) -> ModuleType: 1abdc
28 test_main_mod = importlib.import_module(f"{mod_path}.test_main") 1abc
29 return test_main_mod 1abc
32def test_settings(main_mod: ModuleType, monkeypatch: MonkeyPatch): 1abdc
33 monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com") 1efg
34 settings = main_mod.get_settings() 1efg
35 assert settings.app_name == "Awesome API" 1efg
36 assert settings.items_per_user == 50 1efg
39def test_override_settings(test_main_mod: ModuleType): 1abdc
40 test_main_mod.test_app() 1hij