|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +import sys |
3 | 4 | from io import BytesIO |
4 | 5 |
|
5 | 6 | import pytest |
6 | 7 |
|
7 | | -from .helper import hopper, is_win32 |
| 8 | +from PIL import Image |
8 | 9 |
|
9 | 10 | iterations = 5000 |
10 | 11 |
|
|
18 | 19 | """ |
19 | 20 |
|
20 | 21 |
|
21 | | -pytestmark = pytest.mark.skipif(is_win32(), reason="requires Unix or macOS") |
| 22 | +pytestmark = pytest.mark.skipif( |
| 23 | + sys.platform.startswith("win32"), reason="requires Unix or macOS" |
| 24 | +) |
22 | 25 |
|
23 | 26 | """ |
24 | 27 | pre patch: |
|
112 | 115 | ), |
113 | 116 | ) |
114 | 117 | def test_qtables_leak(qtables: tuple[tuple[int, ...]] | list[tuple[int, ...]]) -> None: |
115 | | - im = hopper("RGB") |
116 | | - for _ in range(iterations): |
117 | | - test_output = BytesIO() |
118 | | - im.save(test_output, "JPEG", qtables=qtables) |
| 118 | + with Image.open("Tests/images/hopper.ppm") as im: |
| 119 | + for _ in range(iterations): |
| 120 | + test_output = BytesIO() |
| 121 | + im.save(test_output, "JPEG", qtables=qtables) |
119 | 122 |
|
120 | 123 |
|
121 | 124 | def test_exif_leak() -> None: |
@@ -173,12 +176,12 @@ def test_exif_leak() -> None: |
173 | 176 | 0 +----------------------------------------------------------------------->Gi |
174 | 177 | 0 11.33 |
175 | 178 | """ |
176 | | - im = hopper("RGB") |
177 | 179 | exif = b"12345678" * 4096 |
178 | 180 |
|
179 | | - for _ in range(iterations): |
180 | | - test_output = BytesIO() |
181 | | - im.save(test_output, "JPEG", exif=exif) |
| 181 | + with Image.open("Tests/images/hopper.ppm") as im: |
| 182 | + for _ in range(iterations): |
| 183 | + test_output = BytesIO() |
| 184 | + im.save(test_output, "JPEG", exif=exif) |
182 | 185 |
|
183 | 186 |
|
184 | 187 | def test_base_save() -> None: |
@@ -207,8 +210,7 @@ def test_base_save() -> None: |
207 | 210 | | :@ @@ @ # : : :: :: @:: :::: :::: :::: : : : : : : :::::::::::: :::@::: |
208 | 211 | 0 +----------------------------------------------------------------------->Gi |
209 | 212 | 0 7.882""" |
210 | | - im = hopper("RGB") |
211 | | - |
212 | | - for _ in range(iterations): |
213 | | - test_output = BytesIO() |
214 | | - im.save(test_output, "JPEG") |
| 213 | + with Image.open("Tests/images/hopper.ppm") as im: |
| 214 | + for _ in range(iterations): |
| 215 | + test_output = BytesIO() |
| 216 | + im.save(test_output, "JPEG") |
0 commit comments