1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
From: sarathak <aksarath@gmail.com>
Date: Fri, 15 Aug 2025 14:45:02 +0530
Subject: Fix test failures with djangorestframework 3.16.1 compatibility
(#1444)
Origin: upstream, https://github.com/sarathak/drf-spectacular/commit/1600c19015785b40673fe809b9060b76aa50ec58
Bug: https://github.com/tfranzel/drf-spectacular/issues/1444
Bug-Debian: https://bugs.debian.org/1114301
Last-Update: 2025-09-10
---
tests/test_i18n.py | 16 +++++++++++++++-
tests/test_i18n.yml | 2 +-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/tests/test_i18n.py b/tests/test_i18n.py
index 15b771a..a7c63b7 100644
--- a/tests/test_i18n.py
+++ b/tests/test_i18n.py
@@ -5,6 +5,7 @@ import yaml
from django.db import models
from django.urls import include, path
from django.utils import translation
+from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _
from rest_framework import mixins, routers, serializers, viewsets
from rest_framework.test import APIClient
@@ -66,8 +67,21 @@ urlpatterns = [
)
def test_i18n_strings(no_warnings):
with translation.override('de-de'):
+ id_desciption = gettext('A {value_type} identifying this {name}.').format(
+ value_type=_('unique integer value'),
+ name=I18nModel._meta.verbose_name,
+ )
schema = generate_schema(None, patterns=urlpatterns)
- assert_schema(schema, 'tests/test_i18n.yml')
+ assert_schema(
+ schema,
+ 'tests/test_i18n.yml',
+ reverse_transforms=[
+ lambda x: x.replace(
+ '\n description: A unique integer value identifying this root',
+ f'\n description: {id_desciption}'
+ )
+ ]
+ )
@pytest.mark.parametrize(['url', 'header', 'translated'], [
diff --git a/tests/test_i18n.yml b/tests/test_i18n.yml
index b5a8d02..443420b 100644
--- a/tests/test_i18n.yml
+++ b/tests/test_i18n.yml
@@ -106,7 +106,7 @@ paths:
name: id
schema:
type: integer
- description: A unique integer value identifying this Internätiönalisierung.
+ description: A unique integer value identifying this root
required: true
tags:
- x
|