mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
4de5477b61
With the introduction and use of pytest, it is simple and easy to execute specific tests in isolation through documented command line arguments. Either by specifying the module path or through the `-k EXPRESSION` argument. There is no longer any need to provide the boilerplate: if __name__ == '__main__': unittest.main() To every test file. It is simply noise. The pattern remains in test files that aren't named with `test_*` as those files are not discovered and executed by pytest by default.
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
from .helper import PillowTestCase
|
|
|
|
from PIL import Image, TarIO
|
|
|
|
codecs = dir(Image.core)
|
|
|
|
# Sample tar archive
|
|
TEST_TAR_FILE = "Tests/images/hopper.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 available")
|
|
|
|
def test_sanity(self):
|
|
for codec, test_path, format in [
|
|
['zip_decoder', 'hopper.png', 'PNG'],
|
|
['jpeg_decoder', 'hopper.jpg', 'JPEG']
|
|
]:
|
|
if codec in codecs:
|
|
tar = TarIO.TarIO(TEST_TAR_FILE, test_path)
|
|
im = Image.open(tar)
|
|
im.load()
|
|
self.assertEqual(im.mode, "RGB")
|
|
self.assertEqual(im.size, (128, 128))
|
|
self.assertEqual(im.format, format)
|
|
|
|
def test_close(self):
|
|
tar = TarIO.TarIO(TEST_TAR_FILE, 'hopper.jpg')
|
|
tar.close()
|
|
|
|
def test_contextmanager(self):
|
|
with TarIO.TarIO(TEST_TAR_FILE, 'hopper.jpg'):
|
|
pass
|