mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-25 19:43:45 +03:00
Noise effect: take five pixels, assert not all same
This commit is contained in:
parent
11a2026f12
commit
8adab0ec0d
|
@ -161,6 +161,12 @@ class PillowTestCase(unittest.TestCase):
|
||||||
self.assertTrue(found)
|
self.assertTrue(found)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def assert_all_same(self, items, msg=None):
|
||||||
|
self.assertTrue(items.count(items[0]) == len(items), msg)
|
||||||
|
|
||||||
|
def assert_not_all_same(self, items, msg=None):
|
||||||
|
self.assertFalse(items.count(items[0]) == len(items), msg)
|
||||||
|
|
||||||
def skipKnownBadTest(self, msg=None, platform=None,
|
def skipKnownBadTest(self, msg=None, platform=None,
|
||||||
travis=None, interpreter=None):
|
travis=None, interpreter=None):
|
||||||
# Skip if platform/travis matches, and
|
# Skip if platform/travis matches, and
|
||||||
|
|
|
@ -348,11 +348,8 @@ class TestImage(PillowTestCase):
|
||||||
# Arrange
|
# Arrange
|
||||||
size = (100, 100)
|
size = (100, 100)
|
||||||
sigma = 128
|
sigma = 128
|
||||||
# To reduce chance of randomly having the same value twice
|
|
||||||
attempts = 5
|
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
while attempts > 0:
|
|
||||||
im = Image.effect_noise(size, sigma)
|
im = Image.effect_noise(size, sigma)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
|
@ -360,12 +357,10 @@ class TestImage(PillowTestCase):
|
||||||
self.assertEqual(im.mode, "L")
|
self.assertEqual(im.mode, "L")
|
||||||
p0 = im.getpixel((0, 0))
|
p0 = im.getpixel((0, 0))
|
||||||
p1 = im.getpixel((0, 1))
|
p1 = im.getpixel((0, 1))
|
||||||
if p0 == p1:
|
p2 = im.getpixel((0, 2))
|
||||||
# Let's roll again
|
p3 = im.getpixel((0, 3))
|
||||||
attempts -= 1
|
p4 = im.getpixel((0, 4))
|
||||||
else:
|
self.assert_not_all_same([p0, p1, p2, p3, p4])
|
||||||
break
|
|
||||||
self.assertNotEqual(p0, p1)
|
|
||||||
|
|
||||||
def test_effect_spread(self):
|
def test_effect_spread(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
|
|
Loading…
Reference in New Issue
Block a user