From eea02ddeea978ef88a1c64479c5182bc4f770a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sun, 21 Dec 2025 16:58:41 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Update=20tests=20to=20capture=20war?= =?UTF-8?q?nings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test_pydantic_v1_in_v2/test_tutorial002.py | 9 ++++++++- .../test_pydantic_v1_in_v2/test_tutorial003.py | 9 ++++++++- .../test_pydantic_v1_in_v2/test_tutorial004.py | 9 ++++++++- .../test_request_form_models/test_tutorial002_pv1.py | 9 ++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial002.py b/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial002.py index 266d25944..ab7e1d8a7 100644 --- a/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial002.py +++ b/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial002.py @@ -1,4 +1,5 @@ import sys +import warnings import pytest from inline_snapshot import snapshot @@ -24,7 +25,13 @@ from ...utils import needs_py310 ], ) def get_client(request: pytest.FixtureRequest): - mod = importlib.import_module(f"docs_src.pydantic_v1_in_v2.{request.param}") + with warnings.catch_warnings(record=True): + warnings.filterwarnings( + "ignore", + message=r"pydantic\.v1 is deprecated and will soon stop being supported by FastAPI\..*", + category=DeprecationWarning, + ) + mod = importlib.import_module(f"docs_src.pydantic_v1_in_v2.{request.param}") c = TestClient(mod.app) return c diff --git a/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial003.py b/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial003.py index 693c3ba29..c45e04248 100644 --- a/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial003.py +++ b/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial003.py @@ -1,4 +1,5 @@ import sys +import warnings import pytest from inline_snapshot import snapshot @@ -24,7 +25,13 @@ from ...utils import needs_py310 ], ) def get_client(request: pytest.FixtureRequest): - mod = importlib.import_module(f"docs_src.pydantic_v1_in_v2.{request.param}") + with warnings.catch_warnings(record=True): + warnings.filterwarnings( + "ignore", + message=r"pydantic\.v1 is deprecated and will soon stop being supported by FastAPI\..*", + category=DeprecationWarning, + ) + mod = importlib.import_module(f"docs_src.pydantic_v1_in_v2.{request.param}") c = TestClient(mod.app) return c diff --git a/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial004.py b/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial004.py index 0fd084c84..f3da849e0 100644 --- a/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial004.py +++ b/tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial004.py @@ -1,4 +1,5 @@ import sys +import warnings import pytest from inline_snapshot import snapshot @@ -24,7 +25,13 @@ from ...utils import needs_py310 ], ) def get_client(request: pytest.FixtureRequest): - mod = importlib.import_module(f"docs_src.pydantic_v1_in_v2.{request.param}") + with warnings.catch_warnings(record=True): + warnings.filterwarnings( + "ignore", + message=r"pydantic\.v1 is deprecated and will soon stop being supported by FastAPI\..*", + category=DeprecationWarning, + ) + mod = importlib.import_module(f"docs_src.pydantic_v1_in_v2.{request.param}") c = TestClient(mod.app) return c diff --git a/tests/test_tutorial/test_request_form_models/test_tutorial002_pv1.py b/tests/test_tutorial/test_request_form_models/test_tutorial002_pv1.py index 9ab30086b..515a5a8d7 100644 --- a/tests/test_tutorial/test_request_form_models/test_tutorial002_pv1.py +++ b/tests/test_tutorial/test_request_form_models/test_tutorial002_pv1.py @@ -1,4 +1,5 @@ import importlib +import warnings import pytest from fastapi.testclient import TestClient @@ -14,7 +15,13 @@ from ...utils import needs_pydanticv1 ], ) def get_client(request: pytest.FixtureRequest): - mod = importlib.import_module(f"docs_src.request_form_models.{request.param}") + with warnings.catch_warnings(record=True): + warnings.filterwarnings( + "ignore", + message=r"pydantic\.v1 is deprecated and will soon stop being supported by FastAPI\..*", + category=DeprecationWarning, + ) + mod = importlib.import_module(f"docs_src.request_form_models.{request.param}") client = TestClient(mod.app) return client