Skip to content

Commit 9c9aa99

Browse files
committed
Skip tests unless JPEG 2000 is available
1 parent 489d6f3 commit 9c9aa99

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

Tests/test_file_icns.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44

55
import pytest
66

7-
from PIL import IcnsImagePlugin, Image, _binary, features
7+
from PIL import IcnsImagePlugin, Image, _binary
88

9-
from .helper import assert_image_equal, assert_image_similar_tofile
9+
from .helper import assert_image_equal, assert_image_similar_tofile, skip_unless_feature
1010

1111
# sample icon file
1212
TEST_FILE = "Tests/images/pillow.icns"
1313

14-
ENABLE_JPEG2K = features.check_codec("jpg_2000")
15-
1614

1715
def test_sanity():
1816
# Loading this icon by default should result in the largest size
@@ -111,14 +109,12 @@ def test_older_icon():
111109
assert im2.size == (wr, hr)
112110

113111

112+
@skip_unless_feature("jpg_2000")
114113
def test_jp2_icon():
115114
# This icon uses JPEG 2000 images instead of the PNG images.
116115
# The advantage of doing this is that OS X 10.5 supports JPEG 2000
117116
# but not PNG; some commercial software therefore does just this.
118117

119-
if not ENABLE_JPEG2K:
120-
return
121-
122118
with Image.open("Tests/images/pillow3.icns") as im:
123119
for w, h, r in im.info["sizes"]:
124120
wr = w * r
@@ -149,6 +145,7 @@ def test_not_an_icns_file():
149145
IcnsImagePlugin.IcnsFile(fp)
150146

151147

148+
@skip_unless_feature("jpg_2000")
152149
def test_icns_decompression_bomb():
153150
with Image.open(
154151
"Tests/images/oom-8ed3316a4109213ca96fb8a256a0bfefdece1461.icns"

Tests/test_image.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import pytest
99

10-
from PIL import Image, ImageDraw, ImagePalette, UnidentifiedImageError
10+
from PIL import Image, ImageDraw, ImagePalette, UnidentifiedImageError, features
1111

1212
from .helper import (
1313
assert_image_equal,
@@ -161,6 +161,8 @@ def test_pathlib(self, tmp_path):
161161
assert im.size == (128, 128)
162162

163163
for ext in (".jpg", ".jp2"):
164+
if ext == ".jp2" and not features.check_codec("jpg_2000"):
165+
pytest.skip("jpg_2000 not available")
164166
temp_file = str(tmp_path / ("temp." + ext))
165167
if os.path.exists(temp_file):
166168
os.remove(temp_file)

0 commit comments

Comments
 (0)