From 5386c5d6516edf9d5a150ddd4ce6d7dbc47121d1 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 2 Sep 2025 12:56:03 +0100 Subject: [PATCH] Prepare for pydantic 2.12.0 `tests/test_multi_body_errors.py::test_openapi_schema` failed with pydantic 2.12.0a1 due to https://github.com/pydantic/pydantic/pull/11987. Since we're testing the exact contents of the JSON schema, the easiest fix seems to be to add version-dependent handling for this. --- tests/test_multi_body_errors.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_multi_body_errors.py b/tests/test_multi_body_errors.py index 0102f0f1a..5bea0890d 100644 --- a/tests/test_multi_body_errors.py +++ b/tests/test_multi_body_errors.py @@ -185,7 +185,15 @@ def test_openapi_schema(): "title": "Age", "anyOf": [ {"exclusiveMinimum": 0.0, "type": "number"}, - {"type": "string"}, + IsOneOf( + # pydantic < 2.12.0a1 + {"type": "string"}, + # pydantic >= 2.12.0a1 + { + "type": "string", + "pattern": r"^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$", + }, + ), ], } )