Debian Codegraph @

tests/test_inheritance_iterable.py

raw
1 from __future__ import annotations
2
3 from django.db.models import Prefetch
4 from django.test import TestCase
5
6 from tests.models import InheritanceManagerTestChild1, InheritanceManagerTestParent
7
8
9 class InheritanceIterableTest(TestCase):
10 def test_prefetch(self) -> None:
11 qs = InheritanceManagerTestChild1.objects.all().prefetch_related(
12 Prefetch(
13 'normal_field',
14 queryset=InheritanceManagerTestParent.objects.all(),
15 to_attr='normal_field_prefetched'
16 )
17 )
18 self.assertEqual(qs.count(), 0)