mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-18 02:49:51 -05:00
* ➕ Add pydantic-settings to all extras * 📝 Update docs for Pydantic settings * 📝 Update Settings source examples to use Pydantic v2, and add a Pydantic v1 version * ✅ Add tests for settings with Pydantic v1 and v2 * 🔥 Remove solved TODO comment * ♻️ Update conditional OpenAPI to use new Pydantic v2 settings
21 lines
488 B
Python
21 lines
488 B
Python
from pytest import MonkeyPatch
|
|
|
|
from ...utils import needs_pydanticv2
|
|
|
|
|
|
@needs_pydanticv2
|
|
def test_settings(monkeypatch: MonkeyPatch):
|
|
from docs_src.settings.app02 import main
|
|
|
|
monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com")
|
|
settings = main.get_settings()
|
|
assert settings.app_name == "Awesome API"
|
|
assert settings.items_per_user == 50
|
|
|
|
|
|
@needs_pydanticv2
|
|
def test_override_settings():
|
|
from docs_src.settings.app02 import test_main
|
|
|
|
test_main.test_app()
|