Pillow/Tests/test_file_tar.py

37 lines
1.0 KiB
Python
Raw Normal View History

2014-07-07 21:03:50 +04:00
from helper import unittest, PillowTestCase
from PIL import Image, TarIO
codecs = dir(Image.core)
2014-09-04 13:21:19 +04:00
# Sample tar archive
TEST_TAR_FILE = "Tests/images/hopper.tar"
2014-06-10 13:10:47 +04:00
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:
2014-09-04 13:21:19 +04:00
tar = TarIO.TarIO(TEST_TAR_FILE, 'hopper.png')
2014-06-10 13:10:47 +04:00
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:
2014-09-04 13:21:19 +04:00
tar = TarIO.TarIO(TEST_TAR_FILE, 'hopper.jpg')
2014-06-10 13:10:47 +04:00
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()