1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed isolation of GenericRelationTests.test_filter_targets_related_pk().

This commit is contained in:
Mariusz Felisiak 2021-07-08 13:13:40 +02:00 committed by GitHub
parent 90ba716bf0
commit 7bb0605a8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -228,9 +228,11 @@ class GenericRelationTests(TestCase):
self.assertEqual(qs.filter(links__sum__isnull=False).count(), 0)
def test_filter_targets_related_pk(self):
HasLinkThing.objects.create()
hs2 = HasLinkThing.objects.create()
link = Link.objects.create(content_object=hs2)
# Use hardcoded PKs to ensure different PKs for "link" and "hs2"
# objects.
HasLinkThing.objects.create(pk=1)
hs2 = HasLinkThing.objects.create(pk=2)
link = Link.objects.create(content_object=hs2, pk=1)
self.assertNotEqual(link.object_id, link.pk)
self.assertSequenceEqual(HasLinkThing.objects.filter(links=link.pk), [hs2])