mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
39 lines
1022 B
Python
39 lines
1022 B
Python
from helper import unittest, PillowTestCase
|
|
|
|
from PIL import Image, TarIO
|
|
|
|
codecs = dir(Image.core)
|
|
|
|
# sample ppm stream
|
|
tarfile = "Tests/images/lena.tar"
|
|
|
|
|
|
class TestFileTar(PillowTestCase):
|
|
|
|
def setUp(self):
|
|
if "zip_decoder" not in codecs and "jpeg_decoder" not in codecs:
|
|
self.skipTest("neither jpeg nor zip support not available")
|
|
|
|
def test_sanity(self):
|
|
if "zip_decoder" in codecs:
|
|
tar = TarIO.TarIO(tarfile, 'lena.png')
|
|
im = Image.open(tar)
|
|
im.load()
|
|
self.assertEqual(im.mode, "RGB")
|
|
self.assertEqual(im.size, (128, 128))
|
|
self.assertEqual(im.format, "PNG")
|
|
|
|
if "jpeg_decoder" in codecs:
|
|
tar = TarIO.TarIO(tarfile, 'lena.jpg')
|
|
im = Image.open(tar)
|
|
im.load()
|
|
self.assertEqual(im.mode, "RGB")
|
|
self.assertEqual(im.size, (128, 128))
|
|
self.assertEqual(im.format, "JPEG")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|
|
|
|
# End of file
|