Pillow/Tests/test_webp_leaks.py

26 lines
590 B
Python
Raw Normal View History

2018-01-24 17:02:33 +03:00
from helper import unittest, PillowLeakTestCase
from PIL import Image, features
2015-02-23 12:24:33 +03:00
from io import BytesIO
test_file = "Tests/images/hopper.webp"
2018-01-24 17:02:33 +03:00
@unittest.skipUnless(features.check('webp'), "WebP is not installed")
class TestWebPLeaks(PillowLeakTestCase):
2015-02-23 12:24:33 +03:00
2018-01-24 17:02:33 +03:00
mem_limit = 3 * 1024 # kb
iterations = 100
2015-02-23 12:24:33 +03:00
def test_leak_load(self):
with open(test_file, 'rb') as f:
im_data = f.read()
2018-01-24 17:02:33 +03:00
def core():
2015-02-23 12:24:33 +03:00
with Image.open(BytesIO(im_data)) as im:
im.load()
2018-01-24 17:02:33 +03:00
self._test_leak(core)
2015-02-23 12:24:33 +03:00
if __name__ == '__main__':
unittest.main()