From 704faee3bd6a300e3fb414984e493399c686a2ee Mon Sep 17 00:00:00 2001 From: Christian-Sidak Date: Wed, 22 Apr 2026 05:23:10 +0000 Subject: [PATCH] test: fix pydantic v2 warning filter pattern in regression test --- tests/test_litellm/test_utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.py index 8bb8e241bb0..184028752bc 100644 --- a/tests/test_litellm/test_utils.py +++ b/tests/test_litellm/test_utils.py @@ -3893,7 +3893,15 @@ def test_no_pydantic_serialization_warning_with_tool_calls(): msg = _make_tool_call_message() with warnings.catch_warnings(): - warnings.filterwarnings("error", message="Pydantic serializer warnings") + # Pydantic v2 raises PydanticSerializationUnexpectedValue (a UserWarning + # subclass) with messages like "Expected `str` but got `int` - serialized + # value may not be as expected". The old pattern "Pydantic serializer + # warnings" never matched, making this guard a no-op. + warnings.filterwarnings( + "error", + message=".*serialized value may not be as expected.*", + category=UserWarning, + ) # Should not raise result = validate_and_fix_openai_messages( [