Ticket #31190: test-31190.diff

File test-31190.diff, 1.0 KB (added by Mariusz Felisiak, 5 years ago)

Regression test.

  • tests/generic_relations/tests.py

    diff --git a/tests/generic_relations/tests.py b/tests/generic_relations/tests.py
    index 7c0db95908..683efaddfb 100644
    a b class GenericRelationsTests(TestCase):  
    564564        for tag in tags:
    565565            self.assertSequenceEqual(tag.content_object.tags.all(), [tag])
    566566
     567    def test_prefetch_related_custom_object_id(self):
     568        tiger = Animal.objects.create(common_name='tiger')
     569        cheetah = Animal.objects.create(common_name='cheetah')
     570        Comparison.objects.create(
     571            first_obj=cheetah, other_obj=tiger, comparative='faster',
     572        )
     573        Comparison.objects.create(
     574            first_obj=tiger, other_obj=cheetah, comparative='cooler',
     575        )
     576        qs = Comparison.objects.prefetch_related('first_obj__comparisons')
     577        for comparison in qs:
     578            self.assertSequenceEqual(comparison.first_obj.comparisons.all(), [comparison])
     579
    567580
    568581class ProxyRelatedModelTest(TestCase):
    569582    def test_default_behavior(self):
Back to Top