Skip to content

Commit b4e7202

Browse files
authored
Merge pull request #4698 from nulano/skips
2 parents 92561bd + d641bdc commit b4e7202

7 files changed

Lines changed: 16 additions & 30 deletions

File tree

Tests/helper.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,6 @@ def assert_tuple_approx_equal(actuals, targets, threshold, msg):
165165
assert value, msg + ": " + repr(actuals) + " != " + repr(targets)
166166

167167

168-
def skip_known_bad_test(msg=None):
169-
# Skip if PILLOW_RUN_KNOWN_BAD is not true in the environment.
170-
if not os.environ.get("PILLOW_RUN_KNOWN_BAD", False):
171-
pytest.skip(msg or "Known bad test")
172-
173-
174168
def skip_unless_feature(feature):
175169
reason = "%s not available" % feature
176170
return pytest.mark.skipif(not features.check(feature), reason=reason)

Tests/test_file_palm.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44
import pytest
55
from PIL import Image
66

7-
from .helper import (
8-
IMCONVERT,
9-
assert_image_equal,
10-
hopper,
11-
imagemagick_available,
12-
skip_known_bad_test,
13-
)
7+
from .helper import IMCONVERT, assert_image_equal, hopper, imagemagick_available
148

159
_roundtrip = imagemagick_available()
1610

@@ -62,13 +56,13 @@ def test_monochrome(tmp_path):
6256
roundtrip(tmp_path, mode)
6357

6458

59+
@pytest.mark.xfail(reason="Palm P image is wrong")
6560
def test_p_mode(tmp_path):
6661
# Arrange
6762
mode = "P"
6863

6964
# Act / Assert
7065
helper_save_as_palm(tmp_path, mode)
71-
skip_known_bad_test("Palm P image is wrong")
7266
roundtrip(tmp_path, mode)
7367

7468

Tests/test_image_reduce.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from PIL import Image, ImageMath, ImageMode
33

4-
from .helper import convert_to_comparable
4+
from .helper import convert_to_comparable, skip_unless_feature
55

66
codecs = dir(Image.core)
77

@@ -254,9 +254,7 @@ def test_mode_F():
254254
compare_reduce_with_box(im, factor)
255255

256256

257-
@pytest.mark.skipif(
258-
"jpeg2k_decoder" not in codecs, reason="JPEG 2000 support not available"
259-
)
257+
@skip_unless_feature("jpg_2000")
260258
def test_jpeg2k():
261259
with Image.open("Tests/images/test-card-lossless.jp2") as im:
262260
assert im.reduce(2).size == (320, 240)

Tests/test_image_resample.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def test_box_filter_correct_range(self):
218218
assert_image_equal(im, ref)
219219

220220

221-
class CoreResampleConsistencyTest:
221+
class TestCoreResampleConsistency:
222222
def make_case(self, mode, fill):
223223
im = Image.new(mode, (512, 9), fill)
224224
return im.resize((9, 512), Image.LANCZOS), im.load()[0, 0]
@@ -253,7 +253,7 @@ def test_32f(self):
253253
self.run_case(self.make_case("F", 1.192093e-07))
254254

255255

256-
class CoreResampleAlphaCorrectTest:
256+
class TestCoreResampleAlphaCorrect:
257257
def make_levels_case(self, mode):
258258
i = Image.new(mode, (256, 16))
259259
px = i.load()
@@ -274,7 +274,7 @@ def run_levels_case(self, i):
274274
len(used_colors), y
275275
)
276276

277-
@pytest.mark.skip("Current implementation isn't precise enough")
277+
@pytest.mark.xfail(reason="Current implementation isn't precise enough")
278278
def test_levels_rgba(self):
279279
case = self.make_levels_case("RGBA")
280280
self.run_levels_case(case.resize((512, 32), Image.BOX))
@@ -283,7 +283,7 @@ def test_levels_rgba(self):
283283
self.run_levels_case(case.resize((512, 32), Image.BICUBIC))
284284
self.run_levels_case(case.resize((512, 32), Image.LANCZOS))
285285

286-
@pytest.mark.skip("Current implementation isn't precise enough")
286+
@pytest.mark.xfail(reason="Current implementation isn't precise enough")
287287
def test_levels_la(self):
288288
case = self.make_levels_case("LA")
289289
self.run_levels_case(case.resize((512, 32), Image.BOX))
@@ -329,7 +329,7 @@ def test_dirty_pixels_la(self):
329329
self.run_dirty_case(case.resize((20, 20), Image.LANCZOS), (255,))
330330

331331

332-
class CoreResamplePassesTest:
332+
class TestCoreResamplePasses:
333333
@contextmanager
334334
def count(self, diff):
335335
count = Image.core.get_stats()["new_count"]
@@ -372,7 +372,7 @@ def test_box_vertical(self):
372372
assert_image_similar(with_box, cropped, 0.1)
373373

374374

375-
class CoreResampleCoefficientsTest:
375+
class TestCoreResampleCoefficients:
376376
def test_reduce(self):
377377
test_color = 254
378378

@@ -401,7 +401,7 @@ def test_nonzero_coefficients(self):
401401
assert histogram[0x100 * 3 + 0xFF] == 0x10000
402402

403403

404-
class CoreResampleBoxTest:
404+
class TestCoreResampleBox:
405405
def test_wrong_arguments(self):
406406
im = hopper()
407407
for resample in (

Tests/test_imagefont.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def test_unicode_pilfont(self):
455455
with pytest.raises(UnicodeEncodeError):
456456
font.getsize("’")
457457

458-
@pytest.mark.skipif(is_pypy(), reason="failing on PyPy")
458+
@pytest.mark.xfail(is_pypy(), reason="failing on PyPy with Raqm")
459459
def test_unicode_extended(self):
460460
# issue #3777
461461
text = "A\u278A\U0001F12B"

Tests/test_imagegrab.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66
from PIL import Image, ImageGrab
77

8-
from .helper import assert_image, assert_image_equal_tofile
8+
from .helper import assert_image, assert_image_equal_tofile, skip_unless_feature
99

1010

1111
class TestImageGrab:
@@ -23,7 +23,7 @@ def test_grab(self):
2323
im = ImageGrab.grab(bbox=(10, 20, 50, 80))
2424
assert_image(im, im.mode, (40, 60))
2525

26-
@pytest.mark.skipif(not Image.core.HAVE_XCB, reason="requires XCB")
26+
@skip_unless_feature("xcb")
2727
def test_grab_x11(self):
2828
try:
2929
if sys.platform not in ("win32", "darwin"):
@@ -46,7 +46,7 @@ def test_grab_no_xcb(self):
4646
ImageGrab.grab(xdisplay="")
4747
assert str(e.value).startswith("Pillow was built without XCB support")
4848

49-
@pytest.mark.skipif(not Image.core.HAVE_XCB, reason="requires XCB")
49+
@skip_unless_feature("xcb")
5050
def test_grab_invalid_xdisplay(self):
5151
with pytest.raises(OSError) as e:
5252
ImageGrab.grab(xdisplay="error.test:0.0")

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ line_length = 88
99
multi_line_output = 3
1010

1111
[tool:pytest]
12-
addopts = -rs
12+
addopts = -ra
1313
testpaths = Tests

0 commit comments

Comments
 (0)