mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-04 21:50:54 +03:00
Cache hopper to reduce FS reads and speed up tests
This commit is contained in:
parent
8b7a989018
commit
fb788b85a9
|
@ -185,10 +185,10 @@ def tostring(im, format, **options):
|
||||||
def hopper(mode="RGB", cache={}):
|
def hopper(mode="RGB", cache={}):
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
im = None
|
im = None
|
||||||
# FIXME: Implement caching to reduce reading from disk but so an original
|
# Use caching to reduce reading from disk but so an original copy is
|
||||||
# copy is returned each time and the cached image isn't modified by tests
|
# returned each time and the cached image isn't modified by tests
|
||||||
# (for fast, isolated, repeatable tests).
|
# (for fast, isolated, repeatable tests).
|
||||||
# im = cache.get(mode)
|
im = cache.get(mode)
|
||||||
if im is None:
|
if im is None:
|
||||||
if mode == "RGB":
|
if mode == "RGB":
|
||||||
im = Image.open("Tests/images/hopper.ppm")
|
im = Image.open("Tests/images/hopper.ppm")
|
||||||
|
@ -198,8 +198,8 @@ def hopper(mode="RGB", cache={}):
|
||||||
im = hopper("I").convert(mode)
|
im = hopper("I").convert(mode)
|
||||||
else:
|
else:
|
||||||
im = hopper("RGB").convert(mode)
|
im = hopper("RGB").convert(mode)
|
||||||
# cache[mode] = im
|
cache[mode] = im
|
||||||
return im
|
return im.copy()
|
||||||
|
|
||||||
|
|
||||||
def command_succeeds(cmd):
|
def command_succeeds(cmd):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user