From 092d4c733e0e19aaab75149552080c94b061d771 Mon Sep 17 00:00:00 2001 From: Vitaliy Kucheryaviy Date: Fri, 6 Dec 2024 20:01:35 +0200 Subject: [PATCH] added tests for pydantic.URL serialization --- tests/test_response.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_response.py b/tests/test_response.py index 6b234a6cb..72921ddc3 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -6,6 +6,7 @@ import pytest from django.http import HttpResponse from pydantic import BaseModel, ValidationError +from pydantic_core import Url from ninja import Router from ninja.responses import Response @@ -172,3 +173,10 @@ def test_enum_encoding(): response = Response(data) response_data = json.loads(response.content) assert response_data["enum"] == str(data["enum"]) + + +def test_pydantic_url(): + data = {"url": Url("https://django-ninja.dev/")} + response = Response(data) + response_data = json.loads(response.content) + assert response_data == {"url": "https://django-ninja.dev/"}