use skip_unless_feature in more tests

This commit is contained in:
nulano 2020-06-14 20:16:00 +02:00
parent fc92f56382
commit dc41a4ec21
2 changed files with 5 additions and 7 deletions

View File

@ -1,7 +1,7 @@
import pytest import pytest
from PIL import Image, ImageMath, ImageMode from PIL import Image, ImageMath, ImageMode
from .helper import convert_to_comparable from .helper import convert_to_comparable, skip_unless_feature
codecs = dir(Image.core) codecs = dir(Image.core)
@ -254,9 +254,7 @@ def test_mode_F():
compare_reduce_with_box(im, factor) compare_reduce_with_box(im, factor)
@pytest.mark.skipif( @skip_unless_feature("jpg_2000")
"jpeg2k_decoder" not in codecs, reason="JPEG 2000 support not available"
)
def test_jpeg2k(): def test_jpeg2k():
with Image.open("Tests/images/test-card-lossless.jp2") as im: with Image.open("Tests/images/test-card-lossless.jp2") as im:
assert im.reduce(2).size == (320, 240) assert im.reduce(2).size == (320, 240)

View File

@ -4,7 +4,7 @@ import sys
import pytest import pytest
from PIL import Image, ImageGrab from PIL import Image, ImageGrab
from .helper import assert_image from .helper import assert_image, skip_unless_feature
class TestImageGrab: class TestImageGrab:
@ -22,7 +22,7 @@ class TestImageGrab:
im = ImageGrab.grab(bbox=(10, 20, 50, 80)) im = ImageGrab.grab(bbox=(10, 20, 50, 80))
assert_image(im, im.mode, (40, 60)) assert_image(im, im.mode, (40, 60))
@pytest.mark.skipif(not Image.core.HAVE_XCB, reason="requires XCB") @skip_unless_feature("xcb")
def test_grab_x11(self): def test_grab_x11(self):
try: try:
if sys.platform not in ("win32", "darwin"): if sys.platform not in ("win32", "darwin"):
@ -45,7 +45,7 @@ class TestImageGrab:
ImageGrab.grab(xdisplay="") ImageGrab.grab(xdisplay="")
assert str(e.value).startswith("Pillow was built without XCB support") assert str(e.value).startswith("Pillow was built without XCB support")
@pytest.mark.skipif(not Image.core.HAVE_XCB, reason="requires XCB") @skip_unless_feature("xcb")
def test_grab_invalid_xdisplay(self): def test_grab_invalid_xdisplay(self):
with pytest.raises(OSError) as e: with pytest.raises(OSError) as e:
ImageGrab.grab(xdisplay="error.test:0.0") ImageGrab.grab(xdisplay="error.test:0.0")