diff options
Diffstat (limited to 'tests/template_tests/tests.py')
| -rw-r--r-- | tests/template_tests/tests.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py index 7364c7ca64..573fd9db2e 100644 --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -1,10 +1,16 @@ import sys +import unittest +from typing import TYPE_CHECKING from django.template import Context, Engine, TemplateDoesNotExist, TemplateSyntaxError from django.template.base import UNKNOWN_SOURCE from django.test import SimpleTestCase, override_settings from django.urls import NoReverseMatch from django.utils import translation +from django.utils.version import PY314 + +if TYPE_CHECKING: + type AnnotatedKwarg = str class TemplateTestMixin: @@ -221,6 +227,21 @@ class TemplateTestMixin: template = self._engine().from_string("{{ description.count }}") self.assertEqual(template.render(Context({"description": "test"})), "") + @unittest.skipUnless(PY314, "Deferred annotations are Python 3.14+ only") + def test_callable_uses_deferred_annotations(self): + """ + Missing required arguments are gracefully handled when a signature uses + deferred annotations. + """ + + class MyObject: + @staticmethod + def uses_deferred_annotations(value: AnnotatedKwarg): + return value + + template = self._engine().from_string("{{ obj.uses_deferred_annotations }}") + self.assertEqual(template.render(Context({"obj": MyObject()})), "") + class TemplateTests(TemplateTestMixin, SimpleTestCase): debug_engine = False |
