diff --git a/Tests/test_image.py b/Tests/test_image.py index e2859d237..58ea468e7 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -347,14 +347,24 @@ class TestImage(PillowTestCase): # Arrange size = (100, 100) sigma = 128 + # To reduce chance of randomly having the same value twice + attempts = 5 # Act - im = Image.effect_noise(size, sigma) + while attempts > 0: + im = Image.effect_noise(size, sigma) - # Assert - self.assertEqual(im.size, (100, 100)) - self.assertEqual(im.mode, "L") - self.assertNotEqual(im.getpixel((0, 0)), im.getpixel((0, 1))) + # Assert + self.assertEqual(im.size, (100, 100)) + self.assertEqual(im.mode, "L") + p0 = im.getpixel((0, 0)) + p1 = im.getpixel((0, 1)) + if p0 == p1: + # Let's roll again + attempts -= 1 + else: + break + self.assertNotEqual(p0, p1) def test_effect_spread(self): # Arrange