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

Added tests for double-pickling a QuerySet

Refs #21102.
This commit is contained in:
Anssi Kääriäinen 2013-09-14 10:33:12 +03:00
parent c89d80e2cc
commit 74b91b3888

View File

@ -94,3 +94,15 @@ class PickleabilityTestCase(TestCase):
def test_specialized_queryset(self):
self.assert_pickles(Happening.objects.values('name'))
self.assert_pickles(Happening.objects.values('name').dates('when', 'year'))
def test_pickle_prefetch_related_idempotence(self):
g = Group.objects.create(name='foo')
groups = Group.objects.prefetch_related('event_set')
# First pickling
groups = pickle.loads(pickle.dumps(groups))
self.assertQuerysetEqual(groups, [g], lambda x: x)
# Second pickling
groups = pickle.loads(pickle.dumps(groups))
self.assertQuerysetEqual(groups, [g], lambda x: x)