mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-17 04:10:24 +00:00
* Modernize Python syntax, add Python 3.8 * Update Python version & dist in TravisCI * Add postgresql as addon * Switch to psycopg2-binary * Drop django.utils.six
20 lines
684 B
Python
20 lines
684 B
Python
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)
|