Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added test for pickling of a model with an `ImageField`, refs #11103.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10860 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c78554b2164b9b09fa30f93371fa6d89cf6b5e89 1 parent 44bf371
Gary Wilson Jr. authored May 29, 2009
17  tests/regressiontests/model_fields/imagefield.py
@@ -150,6 +150,23 @@ def test_size_method(self):
150 150
             _ = p.mugshot.size
151 151
             self.assertEqual(p.mugshot.closed, True)
152 152
 
  153
+        def test_pickle(self):
  154
+            """
  155
+            Tests that ImageField can be pickled, unpickled, and that the
  156
+            image of the unpickled version is the same as the original.
  157
+            """
  158
+            import pickle
  159
+
  160
+            p = Person(name="Joe")
  161
+            p.mugshot.save("mug", self.file1)
  162
+            dump = pickle.dumps(p)
  163
+
  164
+            p2 = Person(name="Bob")
  165
+            p2.mugshot = self.file1
  166
+
  167
+            loaded_p = pickle.loads(dump)
  168
+            self.assertEqual(p.mugshot, loaded_p.mugshot)
  169
+
153 170
 
154 171
     class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase):
155 172
         """

0 notes on commit c78554b

Please sign in to comment.
Something went wrong with that request. Please try again.