mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-25 00:34:14 +03:00
Merge pull request #4698 from nulano/skips
This commit is contained in:
commit
b4e7202dcb
|
@ -165,12 +165,6 @@ def assert_tuple_approx_equal(actuals, targets, threshold, msg):
|
|||
assert value, msg + ": " + repr(actuals) + " != " + repr(targets)
|
||||
|
||||
|
||||
def skip_known_bad_test(msg=None):
|
||||
# Skip if PILLOW_RUN_KNOWN_BAD is not true in the environment.
|
||||
if not os.environ.get("PILLOW_RUN_KNOWN_BAD", False):
|
||||
pytest.skip(msg or "Known bad test")
|
||||
|
||||
|
||||
def skip_unless_feature(feature):
|
||||
reason = "%s not available" % feature
|
||||
return pytest.mark.skipif(not features.check(feature), reason=reason)
|
||||
|
|
|
@ -4,13 +4,7 @@ import subprocess
|
|||
import pytest
|
||||
from PIL import Image
|
||||
|
||||
from .helper import (
|
||||
IMCONVERT,
|
||||
assert_image_equal,
|
||||
hopper,
|
||||
imagemagick_available,
|
||||
skip_known_bad_test,
|
||||
)
|
||||
from .helper import IMCONVERT, assert_image_equal, hopper, imagemagick_available
|
||||
|
||||
_roundtrip = imagemagick_available()
|
||||
|
||||
|
@ -62,13 +56,13 @@ def test_monochrome(tmp_path):
|
|||
roundtrip(tmp_path, mode)
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="Palm P image is wrong")
|
||||
def test_p_mode(tmp_path):
|
||||
# Arrange
|
||||
mode = "P"
|
||||
|
||||
# Act / Assert
|
||||
helper_save_as_palm(tmp_path, mode)
|
||||
skip_known_bad_test("Palm P image is wrong")
|
||||
roundtrip(tmp_path, mode)
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -218,7 +218,7 @@ class TestImagingCoreResampleAccuracy:
|
|||
assert_image_equal(im, ref)
|
||||
|
||||
|
||||
class CoreResampleConsistencyTest:
|
||||
class TestCoreResampleConsistency:
|
||||
def make_case(self, mode, fill):
|
||||
im = Image.new(mode, (512, 9), fill)
|
||||
return im.resize((9, 512), Image.LANCZOS), im.load()[0, 0]
|
||||
|
@ -253,7 +253,7 @@ class CoreResampleConsistencyTest:
|
|||
self.run_case(self.make_case("F", 1.192093e-07))
|
||||
|
||||
|
||||
class CoreResampleAlphaCorrectTest:
|
||||
class TestCoreResampleAlphaCorrect:
|
||||
def make_levels_case(self, mode):
|
||||
i = Image.new(mode, (256, 16))
|
||||
px = i.load()
|
||||
|
@ -274,7 +274,7 @@ class CoreResampleAlphaCorrectTest:
|
|||
len(used_colors), y
|
||||
)
|
||||
|
||||
@pytest.mark.skip("Current implementation isn't precise enough")
|
||||
@pytest.mark.xfail(reason="Current implementation isn't precise enough")
|
||||
def test_levels_rgba(self):
|
||||
case = self.make_levels_case("RGBA")
|
||||
self.run_levels_case(case.resize((512, 32), Image.BOX))
|
||||
|
@ -283,7 +283,7 @@ class CoreResampleAlphaCorrectTest:
|
|||
self.run_levels_case(case.resize((512, 32), Image.BICUBIC))
|
||||
self.run_levels_case(case.resize((512, 32), Image.LANCZOS))
|
||||
|
||||
@pytest.mark.skip("Current implementation isn't precise enough")
|
||||
@pytest.mark.xfail(reason="Current implementation isn't precise enough")
|
||||
def test_levels_la(self):
|
||||
case = self.make_levels_case("LA")
|
||||
self.run_levels_case(case.resize((512, 32), Image.BOX))
|
||||
|
@ -329,7 +329,7 @@ class CoreResampleAlphaCorrectTest:
|
|||
self.run_dirty_case(case.resize((20, 20), Image.LANCZOS), (255,))
|
||||
|
||||
|
||||
class CoreResamplePassesTest:
|
||||
class TestCoreResamplePasses:
|
||||
@contextmanager
|
||||
def count(self, diff):
|
||||
count = Image.core.get_stats()["new_count"]
|
||||
|
@ -372,7 +372,7 @@ class CoreResamplePassesTest:
|
|||
assert_image_similar(with_box, cropped, 0.1)
|
||||
|
||||
|
||||
class CoreResampleCoefficientsTest:
|
||||
class TestCoreResampleCoefficients:
|
||||
def test_reduce(self):
|
||||
test_color = 254
|
||||
|
||||
|
@ -401,7 +401,7 @@ class CoreResampleCoefficientsTest:
|
|||
assert histogram[0x100 * 3 + 0xFF] == 0x10000
|
||||
|
||||
|
||||
class CoreResampleBoxTest:
|
||||
class TestCoreResampleBox:
|
||||
def test_wrong_arguments(self):
|
||||
im = hopper()
|
||||
for resample in (
|
||||
|
|
|
@ -455,7 +455,7 @@ class TestImageFont:
|
|||
with pytest.raises(UnicodeEncodeError):
|
||||
font.getsize("’")
|
||||
|
||||
@pytest.mark.skipif(is_pypy(), reason="failing on PyPy")
|
||||
@pytest.mark.xfail(is_pypy(), reason="failing on PyPy with Raqm")
|
||||
def test_unicode_extended(self):
|
||||
# issue #3777
|
||||
text = "A\u278A\U0001F12B"
|
||||
|
|
|
@ -5,7 +5,7 @@ import sys
|
|||
import pytest
|
||||
from PIL import Image, ImageGrab
|
||||
|
||||
from .helper import assert_image, assert_image_equal_tofile
|
||||
from .helper import assert_image, assert_image_equal_tofile, skip_unless_feature
|
||||
|
||||
|
||||
class TestImageGrab:
|
||||
|
@ -23,7 +23,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"):
|
||||
|
@ -46,7 +46,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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user