Debian Codegraph @

src/polymorphic/tests/other/test_cross_apps.py

raw
1 from django.test import TestCase
2 from django.core.exceptions import FieldError
3
4
5 class TestCrossAppSubclasses(TestCase):
6 def test_samename_different_app_subclasses(self):
7 from polymorphic.tests.other.models import UserProfile as OtherUserProfile
8 from polymorphic.tests.models import Participant, UserProfile
9
10 p1 = Participant.objects.create()
11 p2 = UserProfile.objects.create(name="userprofile1")
12 p3 = OtherUserProfile.objects.create(name="otheruserprofile1")
13
14 assert set(Participant.objects.all()) == {p1, p2, p3}
15
16 with self.assertRaises(FieldError):
17 Participant.objects.filter(UserProfile___name="otheruserprofile1")
18
19 assert set(Participant.objects.filter(other__UserProfile___name="otheruserprofile1")) == {
20 p3
21 }