From 7bb0605a8c4adb4247a179276036f138ae859ac9 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Thu, 8 Jul 2021 13:13:40 +0200 Subject: [PATCH] Fixed isolation of GenericRelationTests.test_filter_targets_related_pk(). --- tests/generic_relations_regress/tests.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/generic_relations_regress/tests.py b/tests/generic_relations_regress/tests.py index 0c62283f01..1d89b6cd16 100644 --- a/tests/generic_relations_regress/tests.py +++ b/tests/generic_relations_regress/tests.py @@ -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])