summaryrefslogtreecommitdiff
path: root/tests/regressiontests/queryset_pickle
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-03-27 15:54:31 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-03-27 15:54:31 +0000
commitad5afd6ed220ed50a2b48d7ccf9786ac0e52f807 (patch)
tree14caa228c595f66afdaa130c1d2fe2db238ee312 /tests/regressiontests/queryset_pickle
parentb31b2d4da3772463d007c9d986c4bdd1392b09e7 (diff)
Fixed #12769, #12924 -- Corrected the pickling of curried and lazy objects, which was preventing queries with translated or related fields from being pickled. And lo, Alex Gaynor didst slayeth the dragon.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12866 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/queryset_pickle')
-rw-r--r--tests/regressiontests/queryset_pickle/__init__.py0
-rw-r--r--tests/regressiontests/queryset_pickle/models.py8
-rw-r--r--tests/regressiontests/queryset_pickle/tests.py14
3 files changed, 22 insertions, 0 deletions
diff --git a/tests/regressiontests/queryset_pickle/__init__.py b/tests/regressiontests/queryset_pickle/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/regressiontests/queryset_pickle/__init__.py
diff --git a/tests/regressiontests/queryset_pickle/models.py b/tests/regressiontests/queryset_pickle/models.py
new file mode 100644
index 0000000000..ec4bbed096
--- /dev/null
+++ b/tests/regressiontests/queryset_pickle/models.py
@@ -0,0 +1,8 @@
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+
+class Group(models.Model):
+ name = models.CharField(_('name'), max_length=100)
+
+class Event(models.Model):
+ group = models.ForeignKey(Group)
diff --git a/tests/regressiontests/queryset_pickle/tests.py b/tests/regressiontests/queryset_pickle/tests.py
new file mode 100644
index 0000000000..8191403be7
--- /dev/null
+++ b/tests/regressiontests/queryset_pickle/tests.py
@@ -0,0 +1,14 @@
+import pickle
+
+from django.test import TestCase
+
+from models import Group, Event
+
+
+class PickleabilityTestCase(TestCase):
+ def assert_pickles(self, qs):
+ self.assertEqual(list(pickle.loads(pickle.dumps(qs))), list(qs))
+
+ def test_related_field(self):
+ g = Group.objects.create(name="Ponies Who Own Maybachs")
+ self.assert_pickles(Event.objects.filter(group=g.id))