summaryrefslogtreecommitdiff
path: root/tests/admin_views
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2025-11-29 18:45:39 -0500
committerJacob Walls <jacobtylerwalls@gmail.com>2025-12-01 20:48:54 -0500
commit34186e731ca20a2344b1f88fd543a854d6b13a00 (patch)
treec9d993b6a358540bbf6b42b298507b2f1aa8f364 /tests/admin_views
parentce36c35e76f82f76cdfa5777456e794d481e5afc (diff)
Fixed #36712 -- Evaluated type annotations lazily in template tag registration.
Ideally, this will be reverted when an upstream solution is available for https://github.com/python/cpython/issues/141560. Thanks Patrick Rauscher for the report and Augusto Pontes for the first iteration and test.
Diffstat (limited to 'tests/admin_views')
-rw-r--r--tests/admin_views/test_templatetags.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/admin_views/test_templatetags.py b/tests/admin_views/test_templatetags.py
index 185fe156a6..e8129cce1d 100644
--- a/tests/admin_views/test_templatetags.py
+++ b/tests/admin_views/test_templatetags.py
@@ -1,13 +1,17 @@
import datetime
+import unittest
from django.contrib.admin import ModelAdmin
from django.contrib.admin.templatetags.admin_list import date_hierarchy
from django.contrib.admin.templatetags.admin_modify import submit_row
+from django.contrib.admin.templatetags.base import InclusionAdminNode
from django.contrib.auth import get_permission_codename
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
+from django.template.base import Token, TokenType
from django.test import RequestFactory, TestCase
from django.urls import reverse
+from django.utils.version import PY314
from .admin import ArticleAdmin, site
from .models import Article, Question
@@ -131,6 +135,22 @@ class AdminTemplateTagsTest(AdminViewBasicTestCase):
self.assertContains(response, "override-pagination")
self.assertContains(response, "override-search_form")
+ @unittest.skipUnless(PY314, "Deferred annotations are Python 3.14+ only")
+ def test_inclusion_admin_node_deferred_annotation(self):
+ def action(arg: SomeType = None): # NOQA: F821
+ pass
+
+ # This used to raise TypeError via the underlying call to
+ # inspect.getfullargspec(), which is not ready for deferred
+ # evaluation of annotations.
+ InclusionAdminNode(
+ parser=object(),
+ token=Token(token_type=TokenType.TEXT, contents="a"),
+ func=action,
+ template_name="test.html",
+ takes_context=False,
+ )
+
class DateHierarchyTests(TestCase):
factory = RequestFactory()