mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-04-05 12:40:57 +00:00
23 lines
725 B
Python
23 lines
725 B
Python
|
|
from __future__ import unicode_literals
|
||
|
|
|
||
|
|
from unittest import skipIf
|
||
|
|
|
||
|
|
import django
|
||
|
|
from django.test import TestCase
|
||
|
|
from django.db.models import Prefetch
|
||
|
|
|
||
|
|
from tests.models import InheritanceManagerTestParent, InheritanceManagerTestChild1
|
||
|
|
|
||
|
|
|
||
|
|
class InheritanceIterableTest(TestCase):
|
||
|
|
@skipIf(django.VERSION[:2] == (1, 10), "Django 1.10 expects ModelIterable not a subclass of it")
|
||
|
|
def test_prefetch(self):
|
||
|
|
qs = InheritanceManagerTestChild1.objects.all().prefetch_related(
|
||
|
|
Prefetch(
|
||
|
|
'normal_field',
|
||
|
|
queryset=InheritanceManagerTestParent.objects.all(),
|
||
|
|
to_attr='normal_field_prefetched'
|
||
|
|
)
|
||
|
|
)
|
||
|
|
self.assertEquals(qs.count(), 0)
|