Skip to content

Commit

Permalink
Added test for pickling of a model with an ImageField, refs #11103.
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10860 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
gdub committed May 29, 2009
1 parent 44bf371 commit c78554b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/regressiontests/model_fields/imagefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit c78554b

Please sign in to comment.