Browse Source

🔥 Remove tests and markers for Pydantic v1

pull/14609/head
Sebastián Ramírez 7 months ago
parent
commit
127f6328d1
  1. 12
      tests/test_tutorial/test_settings/test_app03.py
  2. 10
      tests/test_tutorial/test_settings/test_tutorial001.py
  3. 2
      tests/utils.py

12
tests/test_tutorial/test_settings/test_app03.py

@ -5,8 +5,6 @@ import pytest
from fastapi.testclient import TestClient
from pytest import MonkeyPatch
from ...utils import needs_pydanticv1
@pytest.fixture(
name="mod_path",
@ -34,16 +32,6 @@ def test_settings(main_mod: ModuleType, monkeypatch: MonkeyPatch):
assert settings.items_per_user == 50
@needs_pydanticv1
def test_settings_pv1(mod_path: str, monkeypatch: MonkeyPatch):
monkeypatch.setenv("ADMIN_EMAIL", "[email protected]")
config_mod = importlib.import_module(f"{mod_path}.config_pv1")
settings = config_mod.Settings()
assert settings.app_name == "Awesome API"
assert settings.admin_email == "[email protected]"
assert settings.items_per_user == 50
def test_endpoint(main_mod: ModuleType, monkeypatch: MonkeyPatch):
monkeypatch.setenv("ADMIN_EMAIL", "[email protected]")
client = TestClient(main_mod.app)

10
tests/test_tutorial/test_settings/test_tutorial001.py

@ -4,16 +4,8 @@ import pytest
from fastapi.testclient import TestClient
from pytest import MonkeyPatch
from ...utils import needs_pydanticv1
@pytest.fixture(
name="app",
params=[
pytest.param("tutorial001_py39"),
pytest.param("tutorial001_pv1_py39", marks=needs_pydanticv1),
],
)
@pytest.fixture(name="app", params=[pytest.param("tutorial001_py39")])
def get_app(request: pytest.FixtureRequest, monkeypatch: MonkeyPatch):
monkeypatch.setenv("ADMIN_EMAIL", "[email protected]")
mod = importlib.import_module(f"docs_src.settings.{request.param}")

2
tests/utils.py

@ -10,8 +10,6 @@ needs_py_lt_314 = pytest.mark.skipif(
sys.version_info >= (3, 14), reason="requires python3.13-"
)
needs_pydanticv1 = needs_py_lt_314
def skip_module_if_py_gte_314():
"""Skip entire module on Python 3.14+ at import time."""

Loading…
Cancel
Save