Skip to content

Commit

Permalink
Added tests for double-pickling a QuerySet
Browse files Browse the repository at this point in the history
Refs #21102.
  • Loading branch information
akaariai committed Sep 14, 2013
1 parent c89d80e commit 74b91b3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/queryset_pickle/tests.py
Expand Up @@ -94,3 +94,15 @@ class Meta:
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)

0 comments on commit 74b91b3

Please sign in to comment.