Merge pull request #4698 from nulano/skips

This commit is contained in:
Hugo van Kemenade 2020-06-27 14:19:49 +03:00 committed by GitHub
commit b4e7202dcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 30 deletions

View File

@ -165,12 +165,6 @@ def assert_tuple_approx_equal(actuals, targets, threshold, msg):
assert value, msg + ": " + repr(actuals) + " != " + repr(targets) 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): def skip_unless_feature(feature):
reason = "%s not available" % feature reason = "%s not available" % feature
return pytest.mark.skipif(not features.check(feature), reason=reason) return pytest.mark.skipif(not features.check(feature), reason=reason)

View File

@ -4,13 +4,7 @@ import subprocess
import pytest import pytest
from PIL import Image from PIL import Image
from .helper import ( from .helper import IMCONVERT, assert_image_equal, hopper, imagemagick_available
IMCONVERT,
assert_image_equal,
hopper,
imagemagick_available,
skip_known_bad_test,
)
_roundtrip = imagemagick_available() _roundtrip = imagemagick_available()
@ -62,13 +56,13 @@ def test_monochrome(tmp_path):
roundtrip(tmp_path, mode) roundtrip(tmp_path, mode)
@pytest.mark.xfail(reason="Palm P image is wrong")
def test_p_mode(tmp_path): def test_p_mode(tmp_path):
# Arrange # Arrange
mode = "P" mode = "P"
# Act / Assert # Act / Assert
helper_save_as_palm(tmp_path, mode) helper_save_as_palm(tmp_path, mode)
skip_known_bad_test("Palm P image is wrong")
roundtrip(tmp_path, mode) roundtrip(tmp_path, mode)

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

@ -218,7 +218,7 @@ class TestImagingCoreResampleAccuracy:
assert_image_equal(im, ref) assert_image_equal(im, ref)
class CoreResampleConsistencyTest: class TestCoreResampleConsistency:
def make_case(self, mode, fill): def make_case(self, mode, fill):
im = Image.new(mode, (512, 9), fill) im = Image.new(mode, (512, 9), fill)
return im.resize((9, 512), Image.LANCZOS), im.load()[0, 0] 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)) self.run_case(self.make_case("F", 1.192093e-07))
class CoreResampleAlphaCorrectTest: class TestCoreResampleAlphaCorrect:
def make_levels_case(self, mode): def make_levels_case(self, mode):
i = Image.new(mode, (256, 16)) i = Image.new(mode, (256, 16))
px = i.load() px = i.load()
@ -274,7 +274,7 @@ class CoreResampleAlphaCorrectTest:
len(used_colors), y 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): def test_levels_rgba(self):
case = self.make_levels_case("RGBA") case = self.make_levels_case("RGBA")
self.run_levels_case(case.resize((512, 32), Image.BOX)) 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.BICUBIC))
self.run_levels_case(case.resize((512, 32), Image.LANCZOS)) 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): def test_levels_la(self):
case = self.make_levels_case("LA") case = self.make_levels_case("LA")
self.run_levels_case(case.resize((512, 32), Image.BOX)) 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,)) self.run_dirty_case(case.resize((20, 20), Image.LANCZOS), (255,))
class CoreResamplePassesTest: class TestCoreResamplePasses:
@contextmanager @contextmanager
def count(self, diff): def count(self, diff):
count = Image.core.get_stats()["new_count"] count = Image.core.get_stats()["new_count"]
@ -372,7 +372,7 @@ class CoreResamplePassesTest:
assert_image_similar(with_box, cropped, 0.1) assert_image_similar(with_box, cropped, 0.1)
class CoreResampleCoefficientsTest: class TestCoreResampleCoefficients:
def test_reduce(self): def test_reduce(self):
test_color = 254 test_color = 254
@ -401,7 +401,7 @@ class CoreResampleCoefficientsTest:
assert histogram[0x100 * 3 + 0xFF] == 0x10000 assert histogram[0x100 * 3 + 0xFF] == 0x10000
class CoreResampleBoxTest: class TestCoreResampleBox:
def test_wrong_arguments(self): def test_wrong_arguments(self):
im = hopper() im = hopper()
for resample in ( for resample in (

View File

@ -455,7 +455,7 @@ class TestImageFont:
with pytest.raises(UnicodeEncodeError): with pytest.raises(UnicodeEncodeError):
font.getsize("") 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): def test_unicode_extended(self):
# issue #3777 # issue #3777
text = "A\u278A\U0001F12B" text = "A\u278A\U0001F12B"

View File

@ -5,7 +5,7 @@ import sys
import pytest import pytest
from PIL import Image, ImageGrab 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: class TestImageGrab:
@ -23,7 +23,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"):
@ -46,7 +46,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")

View File

@ -9,5 +9,5 @@ line_length = 88
multi_line_output = 3 multi_line_output = 3
[tool:pytest] [tool:pytest]
addopts = -rs addopts = -ra
testpaths = Tests testpaths = Tests