From fb788b85a9f09273314b4118272f130477d45393 Mon Sep 17 00:00:00 2001 From: hugovk Date: Wed, 29 Oct 2014 21:28:29 +0200 Subject: [PATCH] Cache hopper to reduce FS reads and speed up tests --- Tests/helper.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/helper.py b/Tests/helper.py index 9ee5a8259..c7d947414 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -185,10 +185,10 @@ def tostring(im, format, **options): 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 + # Use 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) + im = cache.get(mode) if im is None: if mode == "RGB": im = Image.open("Tests/images/hopper.ppm") @@ -198,8 +198,8 @@ def hopper(mode="RGB", cache={}): im = hopper("I").convert(mode) else: im = hopper("RGB").convert(mode) - # cache[mode] = im - return im + cache[mode] = im + return im.copy() def command_succeeds(cmd):