django-model-utils/tests/test_inheritance_iterable.py
Maarten ter Huurne aeeb69a9dd Enable postponed evaluation of annotations for all test modules
This allows using the latest annotation syntax supported by the type
checker regardless of the runtime Python version.
2024-06-13 12:02:05 +02:00

18 lines
575 B
Python

from __future__ import annotations
from django.db.models import Prefetch
from django.test import TestCase
from tests.models import InheritanceManagerTestChild1, InheritanceManagerTestParent
class InheritanceIterableTest(TestCase):
def test_prefetch(self):
qs = InheritanceManagerTestChild1.objects.all().prefetch_related(
Prefetch(
'normal_field',
queryset=InheritanceManagerTestParent.objects.all(),
to_attr='normal_field_prefetched'
)
)
self.assertEqual(qs.count(), 0)