diff --git a/Tests/helper.py b/Tests/helper.py index 3f7913b11..637e77f9c 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -180,6 +180,26 @@ def tostring(im, format, **options): return out.getvalue() +def hopper(mode="RGB", cache={}): + from PIL import Image + im = None + # FIXME: Implement caching to reduce reading from disk but so an original + # copy is returned each time and the cached image isn't modified by tests + # (for fast, isolated, repeatable tests). + # im = cache.get(mode) + if im is None: + if mode == "RGB": + im = Image.open("Tests/images/hopper.ppm") + elif mode == "F": + im = lena("L").convert(mode) + elif mode[:4] == "I;16": + im = lena("I").convert(mode) + else: + im = lena("RGB").convert(mode) + # cache[mode] = im + return im + + def lena(mode="RGB", cache={}): from PIL import Image im = None diff --git a/Tests/test_image.py b/Tests/test_image.py index 46669db4b..1c60cca17 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image import sys @@ -58,7 +58,7 @@ class TestImage(PillowTestCase): def test_expand_x(self): # Arrange - im = lena() + im = hopper() orig_size = im.size xmargin = 5 @@ -71,7 +71,7 @@ class TestImage(PillowTestCase): def test_expand_xy(self): # Arrange - im = lena() + im = hopper() orig_size = im.size xmargin = 5 ymargin = 3 @@ -85,7 +85,7 @@ class TestImage(PillowTestCase): def test_getbands(self): # Arrange - im = lena() + im = hopper() # Act bands = im.getbands() @@ -95,7 +95,7 @@ class TestImage(PillowTestCase): def test_getbbox(self): # Arrange - im = lena() + im = hopper() # Act bbox = im.getbbox() @@ -185,7 +185,7 @@ class TestImage(PillowTestCase): def test_effect_spread(self): # Arrange - im = lena() + im = hopper() distance = 10 # Act