Ticket #31943: test-31943.diff

File test-31943.diff, 1.3 KB (added by Mariusz Felisiak, 4 years ago)

Tests.

  • tests/queryset_pickle/tests.py

    diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py
    index a58e45caed..16884d550d 100644
    a b from .models import Container, Event, Group, Happening, M2MModel, MyEvent  
    1111class PickleabilityTestCase(TestCase):
    1212    @classmethod
    1313    def setUpTestData(cls):
    14         Happening.objects.create()  # make sure the defaults are working (#20158)
     14        cls.happening = Happening.objects.create()  # make sure the defaults are working (#20158)
    1515
    1616    def assert_pickles(self, qs):
    1717        self.assertEqual(list(pickle.loads(pickle.dumps(qs))), list(qs))
    class PickleabilityTestCase(TestCase):  
    224224        qs = Happening.objects.annotate(latest_time=models.Max('when'))
    225225        self.assert_pickles(qs)
    226226
     227    def test_annotation_values(self):
     228        qs = Happening.objects.values('name').annotate(latest_time=models.Max('when'))
     229        restored_qs = Happening.objects.all()
     230        restored_qs.query = pickle.loads(pickle.dumps(qs.query))
     231        self.assertEqual(
     232            restored_qs.first(),
     233            {'name': 'test', 'latest_time': self.happening.when},
     234        )
     235
    227236    def test_filter_deferred(self):
    228237        qs = Happening.objects.all()
    229238        qs._defer_next_filter = True
Back to Top