Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@gdub gdub authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 tests/regressiontests/model_fields/imagefield.py
View
17 tests/regressiontests/model_fields/imagefield.py
@@ -150,6 +150,23 @@ def test_size_method(self):
_ = 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):
"""

0 comments on commit c78554b

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