Files
fastapi/tests/test_tutorial/test_settings/test_app02.py
Sebastián Ramírez 9ebd800d9b Update docs to use Pydantic v2 settings and add note and example about v1 (#9788)
*  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
2023-07-03 22:11:49 +02:00

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()