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
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)
@ -254,9 +254,7 @@ def test_mode_F():
compare_reduce_with_box(im, factor)
@pytest.mark.skipif(
"jpeg2k_decoder" not in codecs, reason="JPEG 2000 support not available"
)
@skip_unless_feature("jpg_2000")
def test_jpeg2k():
with Image.open("Tests/images/test-card-lossless.jp2") as im:
assert im.reduce(2).size == (320, 240)

View File

@ -4,7 +4,7 @@ import sys
import pytest
from PIL import Image, ImageGrab
from .helper import assert_image
from .helper import assert_image, skip_unless_feature
class TestImageGrab:
@ -22,7 +22,7 @@ class TestImageGrab:
im = ImageGrab.grab(bbox=(10, 20, 50, 80))
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):
try:
if sys.platform not in ("win32", "darwin"):
@ -45,7 +45,7 @@ class TestImageGrab:
ImageGrab.grab(xdisplay="")
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):
with pytest.raises(OSError) as e:
ImageGrab.grab(xdisplay="error.test:0.0")