[1.6.x] Added tests for double-pickling a QuerySet

Refs #21102.

Backpatch of 74b91b3888
This commit is contained in:
Anssi Kääriäinen 2013-09-14 10:33:12 +03:00
parent 097fb98f81
commit 4c4954a3c1
1 changed files with 12 additions and 0 deletions

View File

@ -90,3 +90,15 @@ class PickleabilityTestCase(TestCase):
reloaded = pickle.loads(dumped) reloaded = pickle.loads(dumped)
self.assertEqual(original, reloaded) self.assertEqual(original, reloaded)
self.assertIs(reloaded.__class__, dynclass) self.assertIs(reloaded.__class__, dynclass)
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)