File: test_inheritance_iterable.py

package info (click to toggle)
django-model-utils 4.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 552 kB
  • sloc: python: 3,438; makefile: 181
file content (16 lines) | stat: -rw-r--r-- 539 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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)