Skip to content

Commit d90ab90

Browse files
author
German Novikov
authored
Merge pull request #1 from radarhere/autocontrast
Parametrized test
2 parents 8913166 + 4a06988 commit d90ab90

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

Tests/test_imageops.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -388,21 +388,18 @@ def test_autocontrast_preserve_gradient():
388388
assert_image_equal(img, out)
389389

390390

391-
def test_autocontrast_preserve_onecolor():
392-
def _test_one_color(color):
393-
img = Image.new("RGB", (10, 10), color)
394-
395-
# single color images shouldn't change
396-
out = ImageOps.autocontrast(img, cutoff=0, preserve_tone=True)
397-
assert_image_equal(img, out) # single color, no cutoff
398-
399-
# even if there is a cutoff
400-
out = ImageOps.autocontrast(
401-
img, cutoff=0, preserve_tone=True
402-
) # single color 10 cutoff
403-
assert_image_equal(img, out)
404-
405-
_test_one_color((255, 255, 255))
406-
_test_one_color((127, 255, 0))
407-
_test_one_color((127, 127, 127))
408-
_test_one_color((0, 0, 0))
391+
@pytest.mark.parametrize(
392+
"color", ((255, 255, 255), (127, 255, 0), (127, 127, 127), (0, 0, 0))
393+
)
394+
def test_autocontrast_preserve_one_color(color):
395+
img = Image.new("RGB", (10, 10), color)
396+
397+
# single color images shouldn't change
398+
out = ImageOps.autocontrast(img, cutoff=0, preserve_tone=True)
399+
assert_image_equal(img, out) # single color, no cutoff
400+
401+
# even if there is a cutoff
402+
out = ImageOps.autocontrast(
403+
img, cutoff=0, preserve_tone=True
404+
) # single color 10 cutoff
405+
assert_image_equal(img, out)

0 commit comments

Comments
 (0)