django-model-utils/tests/test_inheritance_iterable.py
Adam Dobrawy ffa1a85dc7 Modernize Python syntax, add Python 3.8 (#398)
* 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
2019-11-14 22:50:04 +06:00

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)