django.utils.six.moves.cPickle.dump

Here are the examples of the python api django.utils.six.moves.cPickle.dump taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

Example 1

Project: django-versatileimagefield
Source File: tests.py
View license
    def test_VersatileImageField_picklability(self):
        """Ensure VersatileImageField instances can be pickled/unpickled."""
        cPickle.dump(
            self.jpg,
            open("pickletest.p", "wb")
        )
        jpg_unpickled = cPickle.load(
            open("pickletest.p", "rb")
        )
        jpg_instance = jpg_unpickled
        self.assertEqual(
            jpg_instance.image.thumbnail['100x100'].url,
            '/media/__sized__/python-logo-thumbnail-100x100-70.jpg'
        )
        pickled_state = self.jpg.image.__getstate__()
        self.assertEqual(
            pickled_state,
            {
                '_create_on_demand': False,
                '_committed': True,
                '_file': None,
                'name': 'python-logo.jpg',
                'closed': False
            }
        )