]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
Skip tests for exclude_if for Pydantic less than 2.12
authorYurii Motov <yurii.motov.monte@gmail.com>
Fri, 20 Feb 2026 22:46:04 +0000 (23:46 +0100)
committerYurii Motov <yurii.motov.monte@gmail.com>
Fri, 20 Feb 2026 22:46:04 +0000 (23:46 +0100)
tests/test_pydantic/test_field.py

index ff83ff24894ccccaa55627df5ccc607d5905c0ee..2fcdc0d26dc0fbf97c188c53aa45fee51213049c 100644 (file)
@@ -4,6 +4,7 @@ from typing import Any, Literal
 import pytest
 from pydantic import ValidationError
 from sqlmodel import Field, Session, SQLModel, create_engine
+from sqlmodel._compat import PYDANTIC_MINOR_VERSION
 
 
 def test_decimal():
@@ -177,6 +178,10 @@ def test_deprecated_via_schema_extra():  # Current workaround. Remove after some
     assert model_schema["properties"]["another_old_field"]["deprecated"] is True
 
 
+@pytest.mark.skipif(
+    PYDANTIC_MINOR_VERSION < (2, 12),
+    reason="exlude_if requires Pydantic 2.12+",
+)
 def test_exclude_if():
     def is_empty_string(value: Any) -> bool:
         return value == ""
@@ -197,6 +202,10 @@ def test_exclude_if():
     assert "name" not in dict2
 
 
+@pytest.mark.skipif(
+    PYDANTIC_MINOR_VERSION < (2, 12),
+    reason="exlude_if requires Pydantic 2.12+",
+)
 def test_exclude_if_via_schema_extra():
     def is_empty_string(value: Any) -> bool:
         return value == ""