Skip to content

Commit

Permalink
Merge pull request #1 from radarhere/autocontrast
Browse files Browse the repository at this point in the history
Parametrized test
  • Loading branch information
elejke committed Mar 23, 2021
2 parents 8913166 + 4a06988 commit d90ab90
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions Tests/test_imageops.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,21 +388,18 @@ def test_autocontrast_preserve_gradient():
assert_image_equal(img, out)


def test_autocontrast_preserve_onecolor():
def _test_one_color(color):
img = Image.new("RGB", (10, 10), color)

# single color images shouldn't change
out = ImageOps.autocontrast(img, cutoff=0, preserve_tone=True)
assert_image_equal(img, out) # single color, no cutoff

# even if there is a cutoff
out = ImageOps.autocontrast(
img, cutoff=0, preserve_tone=True
) # single color 10 cutoff
assert_image_equal(img, out)

_test_one_color((255, 255, 255))
_test_one_color((127, 255, 0))
_test_one_color((127, 127, 127))
_test_one_color((0, 0, 0))
@pytest.mark.parametrize(
"color", ((255, 255, 255), (127, 255, 0), (127, 127, 127), (0, 0, 0))
)
def test_autocontrast_preserve_one_color(color):
img = Image.new("RGB", (10, 10), color)

# single color images shouldn't change
out = ImageOps.autocontrast(img, cutoff=0, preserve_tone=True)
assert_image_equal(img, out) # single color, no cutoff

# even if there is a cutoff
out = ImageOps.autocontrast(
img, cutoff=0, preserve_tone=True
) # single color 10 cutoff
assert_image_equal(img, out)

0 comments on commit d90ab90

Please sign in to comment.