Coverage for tests / test_tutorial / test_settings / test_app02.py: 100%
23 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
1import importlib 1abcd
2from types import ModuleType 1abcd
4import pytest 1abcd
5from pytest import MonkeyPatch 1abcd
8@pytest.fixture( 1abcd
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): 1abcd
16 mod_path = f"docs_src.settings.{request.param}" 1efghijklmnopqr
17 return mod_path 1efghijklmnopqr
20@pytest.fixture(name="main_mod") 1abcd
21def get_main_mod(mod_path: str) -> ModuleType: 1abcd
22 main_mod = importlib.import_module(f"{mod_path}.main") 1ghjmnqr
23 return main_mod 1ghjmnqr
26@pytest.fixture(name="test_main_mod") 1abcd
27def get_test_main_mod(mod_path: str) -> ModuleType: 1abcd
28 test_main_mod = importlib.import_module(f"{mod_path}.test_main") 1efziklop
29 return test_main_mod 1efziklop
32def test_settings(main_mod: ModuleType, monkeypatch: MonkeyPatch): 1abcd
33 monkeypatch.setenv("ADMIN_EMAIL", "[email protected]") 1stuvwxy
34 settings = main_mod.get_settings() 1stuvwxy
35 assert settings.app_name == "Awesome API" 1stuvwxy
36 assert settings.items_per_user == 50 1stuvwxy
39def test_override_settings(test_main_mod: ModuleType): 1abcd
40 test_main_mod.test_app() 1ABCDEFGH