2023-12-21 14:13:31 +03:00
|
|
|
from __future__ import annotations
|
2024-01-20 14:23:03 +03:00
|
|
|
|
2015-02-23 12:24:33 +03:00
|
|
|
from io import BytesIO
|
|
|
|
|
2020-02-18 01:03:32 +03:00
|
|
|
from PIL import Image
|
2019-07-06 23:40:53 +03:00
|
|
|
|
2020-02-18 01:03:32 +03:00
|
|
|
from .helper import PillowLeakTestCase, skip_unless_feature
|
2019-07-06 23:40:53 +03:00
|
|
|
|
2015-02-23 12:24:33 +03:00
|
|
|
test_file = "Tests/images/hopper.webp"
|
|
|
|
|
2018-03-03 12:54:00 +03:00
|
|
|
|
2020-02-18 01:03:32 +03:00
|
|
|
@skip_unless_feature("webp")
|
2018-01-24 17:02:33 +03:00
|
|
|
class TestWebPLeaks(PillowLeakTestCase):
|
2018-03-04 06:24:36 +03:00
|
|
|
mem_limit = 3 * 1024 # kb
|
2018-01-24 17:02:33 +03:00
|
|
|
iterations = 100
|
2015-02-23 12:24:33 +03:00
|
|
|
|
2024-01-27 07:19:43 +03:00
|
|
|
def test_leak_load(self) -> None:
|
2019-06-13 18:54:46 +03:00
|
|
|
with open(test_file, "rb") as f:
|
2015-02-23 12:24:33 +03:00
|
|
|
im_data = f.read()
|
2018-01-24 17:02:33 +03:00
|
|
|
|
2024-01-27 07:19:43 +03:00
|
|
|
def core() -> None:
|
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)
|