Author: gwilson
Date: 2009-05-28 23:06:09 -0500 (Thu, 28 May 2009)
New Revision: 10860

Modified:
   django/trunk/tests/regressiontests/model_fields/imagefield.py
Log:
Added test for pickling of a model with an `ImageField`, refs #11103.


Modified: django/trunk/tests/regressiontests/model_fields/imagefield.py
===================================================================
--- django/trunk/tests/regressiontests/model_fields/imagefield.py       
2009-05-28 16:03:28 UTC (rev 10859)
+++ django/trunk/tests/regressiontests/model_fields/imagefield.py       
2009-05-29 04:06:09 UTC (rev 10860)
@@ -150,7 +150,24 @@
             _ = p.mugshot.size
             self.assertEqual(p.mugshot.closed, True)
 
+        def test_pickle(self):
+            """
+            Tests that ImageField can be pickled, unpickled, and that the
+            image of the unpickled version is the same as the original.
+            """
+            import pickle
 
+            p = Person(name="Joe")
+            p.mugshot.save("mug", self.file1)
+            dump = pickle.dumps(p)
+
+            p2 = Person(name="Bob")
+            p2.mugshot = self.file1
+
+            loaded_p = pickle.loads(dump)
+            self.assertEqual(p.mugshot, loaded_p.mugshot)
+
+
     class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase):
         """
         Tests behavior of an ImageField and its dimensions fields.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to