mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
Failing tests to pickle L mode images
This commit is contained in:
parent
8ebdc5b64d
commit
7823197fdd
|
@ -5,10 +5,12 @@ from PIL import Image
|
||||||
|
|
||||||
class TestPickle(PillowTestCase):
|
class TestPickle(PillowTestCase):
|
||||||
|
|
||||||
def helper_pickle_file(self, pickle, protocol=0):
|
def helper_pickle_file(self, pickle, protocol=0, mode=None):
|
||||||
# Arrange
|
# Arrange
|
||||||
im = Image.open('Tests/images/hopper.jpg')
|
im = Image.open('Tests/images/hopper.jpg')
|
||||||
filename = self.tempfile('temp.pkl')
|
filename = self.tempfile('temp.pkl')
|
||||||
|
if mode:
|
||||||
|
im = im.convert(mode)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
with open(filename, 'wb') as f:
|
with open(filename, 'wb') as f:
|
||||||
|
@ -19,9 +21,11 @@ class TestPickle(PillowTestCase):
|
||||||
# Assert
|
# Assert
|
||||||
self.assertEqual(im, loaded_im)
|
self.assertEqual(im, loaded_im)
|
||||||
|
|
||||||
def helper_pickle_string(
|
def helper_pickle_string(self, pickle, protocol=0,
|
||||||
self, pickle, protocol=0, file='Tests/images/hopper.jpg'):
|
file='Tests/images/hopper.jpg', mode=None):
|
||||||
im = Image.open(file)
|
im = Image.open(file)
|
||||||
|
if mode:
|
||||||
|
im = im.convert(mode)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
dumped_string = pickle.dumps(im, protocol)
|
dumped_string = pickle.dumps(im, protocol)
|
||||||
|
@ -67,6 +71,26 @@ class TestPickle(PillowTestCase):
|
||||||
]:
|
]:
|
||||||
self.helper_pickle_string(pickle, file=file)
|
self.helper_pickle_string(pickle, file=file)
|
||||||
|
|
||||||
|
def test_pickle_l_mode(self):
|
||||||
|
# Arrange
|
||||||
|
import pickle
|
||||||
|
|
||||||
|
# Act / Assert
|
||||||
|
for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1):
|
||||||
|
self.helper_pickle_string(pickle, protocol, mode="L")
|
||||||
|
self.helper_pickle_file(pickle, protocol, mode="L")
|
||||||
|
|
||||||
|
def test_cpickle_l_mode(self):
|
||||||
|
# Arrange
|
||||||
|
try:
|
||||||
|
import cPickle
|
||||||
|
except ImportError:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Act / Assert
|
||||||
|
for protocol in range(0, cPickle.HIGHEST_PROTOCOL + 1):
|
||||||
|
self.helper_pickle_string(cPickle, protocol, mode="L")
|
||||||
|
self.helper_pickle_file(cPickle, protocol, mode="L")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user