diff options
Diffstat (limited to 'tests/expressions/tests.py')
| -rw-r--r-- | tests/expressions/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 981d84e9e8..c058c6e275 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -5,6 +5,7 @@ import uuid from collections import namedtuple from copy import deepcopy from decimal import Decimal +from typing import TYPE_CHECKING from unittest import mock from django.core.exceptions import FieldError @@ -77,6 +78,7 @@ from django.test.utils import ( register_lookup, ) from django.utils.functional import SimpleLazyObject +from django.utils.version import PY314 from .models import ( UUID, @@ -94,6 +96,9 @@ from .models import ( Time, ) +if TYPE_CHECKING: + type AnnotatedKwarg = str + class BasicExpressionsTests(TestCase): @classmethod @@ -1589,6 +1594,14 @@ class SimpleExpressionTests(SimpleTestCase): replaced = expression.replace_expressions({"replacement": Expression()}) self.assertEqual(replaced.get_source_expressions(), [falsey]) + @unittest.skipUnless(PY314, "Deferred annotations are Python 3.14+ only") + def test_expression_signature_uses_deferred_annotations(self): + class AnnotatedExpression(Expression): + def __init__(self, *args, my_kw: AnnotatedKwarg, **kwargs): + super().__init__(*args, **kwargs) + + self.assertEqual(AnnotatedExpression(my_kw=""), AnnotatedExpression(my_kw="")) + class ExpressionsNumericTests(TestCase): @classmethod |
