Skip to content

Commit 5b854b2

Browse files
committed
Merge branch 'main' into valgrind-leakcheck
2 parents 6096f33 + 5a04b95 commit 5b854b2

File tree

13 files changed

+47
-37
lines changed

13 files changed

+47
-37
lines changed

.ci/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if [[ $(uname) != CYGWIN* ]]; then
6666
pushd depends && ./install_raqm.sh && popd
6767

6868
# libavif
69-
pushd depends && CMAKE_POLICY_VERSION_MINIMUM=3.5 ./install_libavif.sh && popd
69+
pushd depends && ./install_libavif.sh && popd
7070

7171
# extra test images
7272
pushd depends && ./install_extra_test_images.sh && popd

.github/workflows/wheels-dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ARCHIVE_SDIR=pillow-depends-main
3939
# Package versions for fresh source builds
4040
FREETYPE_VERSION=2.13.3
4141
HARFBUZZ_VERSION=11.2.1
42-
LIBPNG_VERSION=1.6.47
42+
LIBPNG_VERSION=1.6.48
4343
JPEGTURBO_VERSION=3.1.0
4444
OPENJPEG_VERSION=2.5.3
4545
XZ_VERSION=5.8.1

Tests/helper.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ def assert_tuple_approx_equal(
161161
pytest.fail(msg + ": " + repr(actuals) + " != " + repr(targets))
162162

163163

164+
def timeout_unless_slower_valgrind(timeout: float) -> pytest.MarkDecorator:
165+
if "PILLOW_VALGRIND_TEST" in os.environ:
166+
return pytest.mark.pil_noop_mark()
167+
return pytest.mark.timeout(timeout)
168+
169+
164170
def skip_unless_feature(feature: str) -> pytest.MarkDecorator:
165171
reason = f"{feature} not available"
166172
return pytest.mark.skipif(not features.check(feature), reason=reason)

Tests/test_file_eps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
is_win32,
1616
mark_if_feature_version,
1717
skip_unless_feature,
18+
timeout_unless_slower_valgrind,
1819
)
1920

2021
HAS_GHOSTSCRIPT = EpsImagePlugin.has_ghostscript()
@@ -398,7 +399,7 @@ def test_emptyline() -> None:
398399
assert image.format == "EPS"
399400

400401

401-
@pytest.mark.timeout(timeout=5)
402+
@timeout_unless_slower_valgrind(5)
402403
@pytest.mark.parametrize(
403404
"test_file",
404405
["Tests/images/eps/timeout-d675703545fee17acab56e5fec644c19979175de.eps"],

Tests/test_file_fli.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77

88
from PIL import FliImagePlugin, Image, ImageFile
99

10-
from .helper import assert_image_equal, assert_image_equal_tofile, is_pypy
10+
from .helper import (
11+
assert_image_equal,
12+
assert_image_equal_tofile,
13+
is_pypy,
14+
timeout_unless_slower_valgrind,
15+
)
1116

1217
# created as an export of a palette image from Gimp2.6
1318
# save as...-> hopper.fli, default options.
@@ -189,7 +194,7 @@ def test_seek() -> None:
189194
"Tests/images/timeout-bff0a9dc7243a8e6ede2408d2ffa6a9964698b87.fli",
190195
],
191196
)
192-
@pytest.mark.timeout(timeout=3)
197+
@timeout_unless_slower_valgrind(3)
193198
def test_timeouts(test_file: str) -> None:
194199
with open(test_file, "rb") as f:
195200
with Image.open(f) as im:

Tests/test_file_jpeg.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
is_win32,
3333
mark_if_feature_version,
3434
skip_unless_feature,
35+
timeout_unless_slower_valgrind,
3536
)
3637

3738
ElementTree: ModuleType | None
@@ -1033,10 +1034,7 @@ def test_save_xmp(self, tmp_path: Path) -> None:
10331034
with pytest.raises(ValueError):
10341035
im.save(f, xmp=b"1" * 65505)
10351036

1036-
@pytest.mark.timeout(timeout=1)
1037-
@pytest.mark.xfail(
1038-
"PILLOW_VALGRIND_TEST" in os.environ, reason="Valgrind is slower"
1039-
)
1037+
@timeout_unless_slower_valgrind(1)
10401038
def test_eof(self, monkeypatch: pytest.MonkeyPatch) -> None:
10411039
# Even though this decoder never says that it is finished
10421040
# the image should still end when there is no new data

Tests/test_file_pdf.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313

1414
from PIL import Image, PdfParser, features
1515

16-
from .helper import hopper, mark_if_feature_version, skip_unless_feature
16+
from .helper import (
17+
hopper,
18+
mark_if_feature_version,
19+
skip_unless_feature,
20+
timeout_unless_slower_valgrind,
21+
)
1722

1823

1924
def helper_save_as_pdf(tmp_path: Path, mode: str, **kwargs: Any) -> str:
@@ -339,8 +344,7 @@ def test_pdf_append_to_bytesio() -> None:
339344
assert len(f.getvalue()) > initial_size
340345

341346

342-
@pytest.mark.timeout(1)
343-
@pytest.mark.skipif("PILLOW_VALGRIND_TEST" in os.environ, reason="Valgrind is slower")
347+
@timeout_unless_slower_valgrind(1)
344348
@pytest.mark.parametrize("newline", (b"\r", b"\n"))
345349
def test_redos(newline: bytes) -> None:
346350
malicious = b" trailer<<>>" + newline * 3456

Tests/test_file_tiff.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
hopper,
2727
is_pypy,
2828
is_win32,
29+
timeout_unless_slower_valgrind,
2930
)
3031

3132
ElementTree: ModuleType | None
@@ -988,11 +989,8 @@ def test_string_dimension(self) -> None:
988989
with pytest.raises(OSError):
989990
im.load()
990991

991-
@pytest.mark.timeout(6)
992+
@timeout_unless_slower_valgrind(6)
992993
@pytest.mark.filterwarnings("ignore:Truncated File Read")
993-
@pytest.mark.xfail(
994-
"PILLOW_VALGRIND_TEST" in os.environ, reason="Valgrind is slower"
995-
)
996994
def test_timeout(self, monkeypatch: pytest.MonkeyPatch) -> None:
997995
with Image.open("Tests/images/timeout-6646305047838720") as im:
998996
monkeypatch.setattr(ImageFile, "LOAD_TRUNCATED_IMAGES", True)
@@ -1004,10 +1002,7 @@ def test_timeout(self, monkeypatch: pytest.MonkeyPatch) -> None:
10041002
"Tests/images/oom-225817ca0f8c663be7ab4b9e717b02c661e66834.tif",
10051003
],
10061004
)
1007-
@pytest.mark.timeout(2)
1008-
@pytest.mark.xfail(
1009-
"PILLOW_VALGRIND_TEST" in os.environ, reason="Valgrind is slower"
1010-
)
1005+
@timeout_unless_slower_valgrind(2)
10111006
def test_oom(self, test_file: str) -> None:
10121007
with pytest.raises(UnidentifiedImageError):
10131008
with pytest.warns(UserWarning):

Tests/test_image.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
is_win32,
3535
mark_if_feature_version,
3636
skip_unless_feature,
37+
timeout_unless_slower_valgrind,
3738
)
3839

3940
ElementTree: ModuleType | None
@@ -572,10 +573,7 @@ def test_check_size(self) -> None:
572573
i = Image.new("RGB", [1, 1])
573574
assert isinstance(i.size, tuple)
574575

575-
@pytest.mark.timeout(0.75)
576-
@pytest.mark.skipif(
577-
"PILLOW_VALGRIND_TEST" in os.environ, reason="Valgrind is slower"
578-
)
576+
@timeout_unless_slower_valgrind(0.75)
579577
@pytest.mark.parametrize("size", ((0, 100000000), (100000000, 0)))
580578
def test_empty_image(self, size: tuple[int, int]) -> None:
581579
Image.new("RGB", size)

Tests/test_imagefontpil.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from __future__ import annotations
22

3-
import os
43
import struct
54
from io import BytesIO
65

76
import pytest
87

98
from PIL import Image, ImageDraw, ImageFont, _util, features
109

11-
from .helper import assert_image_equal_tofile
10+
from .helper import assert_image_equal_tofile, timeout_unless_slower_valgrind
1211

1312
fonts = [ImageFont.load_default_imagefont()]
1413
if not features.check_module("freetype2"):
@@ -73,8 +72,7 @@ def test_decompression_bomb() -> None:
7372
font.getmask("A" * 1_000_000)
7473

7574

76-
@pytest.mark.timeout(4)
77-
@pytest.mark.xfail("PILLOW_VALGRIND_TEST" in os.environ, reason="Valgrind is slower")
75+
@timeout_unless_slower_valgrind(4)
7876
def test_oom() -> None:
7977
glyph = struct.pack(
8078
">hhhhhhhhhh", 1, 0, -32767, -32767, 32767, 32767, -32767, -32767, 32767, 32767

0 commit comments

Comments
 (0)