From 8dad2b0c63be0a27fcb4bd9745cb6f5ec338a4f9 Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 5 Sep 2014 13:03:56 +0300 Subject: [PATCH] Replace some lena() with hopper(), and temporarily disable fail-fast so we can see all failures --- .travis.yml | 2 + Tests/test_format_hsv.py | 38 ++++++++--------- Tests/test_image_array.py | 4 +- Tests/test_image_convert.py | 20 ++++----- Tests/test_image_copy.py | 4 +- Tests/test_image_crop.py | 4 +- Tests/test_image_draft.py | 4 +- Tests/test_image_filter.py | 4 +- Tests/test_image_frombytes.py | 4 +- Tests/test_image_getbbox.py | 4 +- Tests/test_image_getcolors.py | 6 +-- Tests/test_image_getdata.py | 6 +-- Tests/test_image_getextrema.py | 4 +- Tests/test_image_getim.py | 4 +- Tests/test_image_getpalette.py | 4 +- Tests/test_image_getprojection.py | 4 +- Tests/test_image_histogram.py | 4 +- Tests/test_image_mode.py | 4 +- Tests/test_image_offset.py | 4 +- Tests/test_image_point.py | 10 ++--- Tests/test_image_putdata.py | 10 ++--- Tests/test_image_putpalette.py | 6 +-- Tests/test_image_putpixel.py | 4 +- Tests/test_image_quantize.py | 12 +++--- Tests/test_image_resize.py | 4 +- Tests/test_image_rotate.py | 4 +- Tests/test_image_split.py | 26 ++++++------ Tests/test_image_thumbnail.py | 16 +++---- Tests/test_image_tobitmap.py | 8 ++-- Tests/test_image_tobytes.py | 4 +- Tests/test_image_transform.py | 10 ++--- Tests/test_image_transpose.py | 6 +-- Tests/test_imagefile.py | 6 +-- Tests/test_imagefileio.py | 4 +- Tests/test_imageops.py | 70 +++++++++++++++---------------- Tests/test_imageops_usm.py | 2 +- Tests/test_imageqt.py | 4 +- Tests/test_imagesequence.py | 10 ++--- Tests/test_imagestat.py | 8 ++-- Tests/test_locale.py | 4 +- Tests/test_mode_i16.py | 10 ++--- Tests/test_numpy.py | 6 +-- Tests/test_pickle.py | 10 ++--- Tests/threaded_save.py | 2 +- 44 files changed, 193 insertions(+), 191 deletions(-) diff --git a/.travis.yml b/.travis.yml index 704c0d949..2ce1827e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,8 @@ script: - CFLAGS="-coverage" python setup.py build_ext --inplace - coverage run --append --include=PIL/* selftest.py + # FIXME: re-add -x option to fail fast + # - coverage run --append --include=PIL/* -m nose -vx Tests/test_*.py - coverage run --append --include=PIL/* -m nose -vx Tests/test_*.py after_success: diff --git a/Tests/test_format_hsv.py b/Tests/test_format_hsv.py index 03603aa9b..c571e98ee 100644 --- a/Tests/test_format_hsv.py +++ b/Tests/test_format_hsv.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -15,7 +15,7 @@ class TestFormatHSV(PillowTestCase): def tuple_to_ints(self, tp): x,y,z = tp return (int(x*255.0), int(y*255.0), int(z*255.0)) - + def test_sanity(self): im = Image.new('HSV', (100,100)) @@ -24,7 +24,7 @@ class TestFormatHSV(PillowTestCase): w90 = w.rotate(90) (px, h) = w.size - + r = Image.new('L', (px*3,h)) g = r.copy() b = r.copy() @@ -45,12 +45,12 @@ class TestFormatHSV(PillowTestCase): #print (("%d, %d -> "% (int(.75*px),int(.25*px))) + \ # "(%s, %s, %s)"%img.getpixel((.75*px, .25*px))) return img - + def to_xxx_colorsys(self, im, func, mode): # convert the hard way using the library colorsys routines. - + (r,g,b) = im.split() - + if bytes is str: conv_func = self.str_to_float else: @@ -69,9 +69,9 @@ class TestFormatHSV(PillowTestCase): new_bytes = b''.join(chr(h)+chr(s)+chr(v) for (h,s,v) in converted) else: new_bytes = b''.join(bytes(chr(h)+chr(s)+chr(v), 'latin-1') for (h,s,v) in converted) - + hsv = Image.frombytes(mode,r.size, new_bytes) - + return hsv def to_hsv_colorsys(self, im): @@ -87,7 +87,7 @@ class TestFormatHSV(PillowTestCase): #print (im.getpixel((448, 64))) #print (comparable.getpixel((448, 64))) - + #print(im.split()[0].histogram()) #print(comparable.split()[0].histogram()) @@ -110,25 +110,25 @@ class TestFormatHSV(PillowTestCase): #comparable.split()[0].show() #print (im.getpixel((192, 64))) #print (comparable.getpixel((192, 64))) - + self.assert_image_similar(im.split()[0], comparable.split()[0], 3, "R conversion is wrong") self.assert_image_similar(im.split()[1], comparable.split()[1], 3, "G conversion is wrong") self.assert_image_similar(im.split()[2], comparable.split()[2], 3, "B conversion is wrong") - - + + def test_convert(self): - im = lena('RGB').convert('HSV') - comparable = self.to_hsv_colorsys(lena('RGB')) + im = hopper('RGB').convert('HSV') + comparable = self.to_hsv_colorsys(hopper('RGB')) # print ([ord(x) for x in im.split()[0].tobytes()[:80]]) # print ([ord(x) for x in comparable.split()[0].tobytes()[:80]]) # print(im.split()[0].histogram()) # print(comparable.split()[0].histogram()) - + self.assert_image_similar(im.split()[0], comparable.split()[0], 1, "Hue conversion is wrong") self.assert_image_similar(im.split()[1], comparable.split()[1], @@ -138,10 +138,10 @@ class TestFormatHSV(PillowTestCase): def test_hsv_to_rgb(self): - comparable = self.to_hsv_colorsys(lena('RGB')) + comparable = self.to_hsv_colorsys(hopper('RGB')) converted = comparable.convert('RGB') comparable = self.to_rgb_colorsys(comparable) - + # print(converted.split()[1].histogram()) # print(target.split()[1].histogram()) @@ -156,8 +156,8 @@ class TestFormatHSV(PillowTestCase): self.assert_image_similar(converted.split()[2], comparable.split()[2], 3, "B conversion is wrong") - - + + diff --git a/Tests/test_image_array.py b/Tests/test_image_array.py index c5e49fc39..0899afd02 100644 --- a/Tests/test_image_array.py +++ b/Tests/test_image_array.py @@ -1,8 +1,8 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image -im = lena().resize((128, 100)) +im = hopper().resize((128, 100)) class TestImageArray(PillowTestCase): diff --git a/Tests/test_image_convert.py b/Tests/test_image_convert.py index 01a80732b..8197a66e0 100644 --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -15,13 +15,13 @@ class TestImageConvert(PillowTestCase): modes = "1", "L", "I", "F", "RGB", "RGBA", "RGBX", "CMYK", "YCbCr" for mode in modes: - im = lena(mode) + im = hopper(mode) for mode in modes: convert(im, mode) def test_default(self): - im = lena("P") + im = hopper("P") self.assert_image(im, "P", im.size) im = im.convert() self.assert_image(im, "RGB", im.size) @@ -36,7 +36,7 @@ class TestImageConvert(PillowTestCase): self.assertEqual(orig, converted) def test_8bit(self): - im = Image.open('Tests/images/lena.jpg') + im = Image.open('Tests/images/hopper.jpg') self._test_float_conversion(im.convert('L')) def test_16bit(self): @@ -48,8 +48,8 @@ class TestImageConvert(PillowTestCase): self._test_float_conversion(im.convert('I')) def test_rgba_p(self): - im = lena('RGBA') - im.putalpha(lena('L')) + im = hopper('RGBA') + im.putalpha(hopper('L')) converted = im.convert('P') comparable = converted.convert('RGBA') @@ -57,7 +57,7 @@ class TestImageConvert(PillowTestCase): self.assert_image_similar(im, comparable, 20) def test_trns_p(self): - im = lena('P') + im = hopper('P') im.info['transparency'] = 0 f = self.tempfile('temp.png') @@ -74,7 +74,7 @@ class TestImageConvert(PillowTestCase): def test_trns_p_rgba(self): # Arrange - im = lena('P') + im = hopper('P') im.info['transparency'] = 128 # Act @@ -84,7 +84,7 @@ class TestImageConvert(PillowTestCase): self.assertNotIn('transparency', rgba.info) def test_trns_l(self): - im = lena('L') + im = hopper('L') im.info['transparency'] = 128 f = self.tempfile('temp.png') @@ -104,7 +104,7 @@ class TestImageConvert(PillowTestCase): p.save(f) def test_trns_RGB(self): - im = lena('RGB') + im = hopper('RGB') im.info['transparency'] = im.getpixel((0, 0)) f = self.tempfile('temp.png') diff --git a/Tests/test_image_copy.py b/Tests/test_image_copy.py index a7882db94..4b0905af3 100644 --- a/Tests/test_image_copy.py +++ b/Tests/test_image_copy.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageCopy(PillowTestCase): def test_copy(self): def copy(mode): - im = lena(mode) + im = hopper(mode) out = im.copy() self.assertEqual(out.mode, mode) self.assertEqual(out.size, im.size) diff --git a/Tests/test_image_crop.py b/Tests/test_image_crop.py index da93fe7c8..29ff2bc2a 100644 --- a/Tests/test_image_crop.py +++ b/Tests/test_image_crop.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageCrop(PillowTestCase): def test_crop(self): def crop(mode): - out = lena(mode).crop((50, 50, 100, 100)) + out = hopper(mode).crop((50, 50, 100, 100)) self.assertEqual(out.mode, mode) self.assertEqual(out.size, (50, 50)) for mode in "1", "P", "L", "RGB", "I", "F": diff --git a/Tests/test_image_draft.py b/Tests/test_image_draft.py index a76b8d266..c7cd90e95 100644 --- a/Tests/test_image_draft.py +++ b/Tests/test_image_draft.py @@ -3,8 +3,8 @@ from helper import unittest, PillowTestCase, fromstring, tostring from PIL import Image codecs = dir(Image.core) -filename = "Tests/images/lena.jpg" -data = tostring(Image.open(filename).resize((512, 512)), "JPEG") +fihopperme = "Tests/images/hopper.jpg" +data = tostring(Image.open(fihopperme).resize((512, 512)), "JPEG") def draft(mode, size): diff --git a/Tests/test_image_filter.py b/Tests/test_image_filter.py index 2452479cc..d29fd3dfd 100644 --- a/Tests/test_image_filter.py +++ b/Tests/test_image_filter.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image from PIL import ImageFilter @@ -9,7 +9,7 @@ class TestImageFilter(PillowTestCase): def test_sanity(self): def filter(filter): - im = lena("L") + im = hopper("L") out = im.filter(filter) self.assertEqual(out.mode, im.mode) self.assertEqual(out.size, im.size) diff --git a/Tests/test_image_frombytes.py b/Tests/test_image_frombytes.py index aad8046a1..3f9a2237f 100644 --- a/Tests/test_image_frombytes.py +++ b/Tests/test_image_frombytes.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -6,7 +6,7 @@ from PIL import Image class TestImageFromBytes(PillowTestCase): def test_sanity(self): - im1 = lena() + im1 = hopper() im2 = Image.frombytes(im1.mode, im1.size, im1.tobytes()) self.assert_image_equal(im1, im2) diff --git a/Tests/test_image_getbbox.py b/Tests/test_image_getbbox.py index 8d78195bd..3dc341aeb 100644 --- a/Tests/test_image_getbbox.py +++ b/Tests/test_image_getbbox.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageGetBbox(PillowTestCase): def test_sanity(self): - bbox = lena().getbbox() + bbox = hopper().getbbox() self.assertIsInstance(bbox, tuple) def test_bbox(self): diff --git a/Tests/test_image_getcolors.py b/Tests/test_image_getcolors.py index d3e5a4989..f3586565a 100644 --- a/Tests/test_image_getcolors.py +++ b/Tests/test_image_getcolors.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageGetColors(PillowTestCase): @@ -6,7 +6,7 @@ class TestImageGetColors(PillowTestCase): def test_getcolors(self): def getcolors(mode, limit=None): - im = lena(mode) + im = hopper(mode) if limit: colors = im.getcolors(limit) else: @@ -41,7 +41,7 @@ class TestImageGetColors(PillowTestCase): def test_pack(self): # Pack problems for small tables (@PIL209) - im = lena().quantize(3).convert("RGB") + im = hopper().quantize(3).convert("RGB") expected = [ (3236, (227, 183, 147)), diff --git a/Tests/test_image_getdata.py b/Tests/test_image_getdata.py index ff6659595..bc925420d 100644 --- a/Tests/test_image_getdata.py +++ b/Tests/test_image_getdata.py @@ -1,11 +1,11 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageGetData(PillowTestCase): def test_sanity(self): - data = lena().getdata() + data = hopper().getdata() len(data) list(data) @@ -15,7 +15,7 @@ class TestImageGetData(PillowTestCase): def test_roundtrip(self): def getdata(mode): - im = lena(mode).resize((32, 30)) + im = hopper(mode).resize((32, 30)) data = im.getdata() return data[0], len(data), len(list(data)) diff --git a/Tests/test_image_getextrema.py b/Tests/test_image_getextrema.py index af7f7698a..066d563c4 100644 --- a/Tests/test_image_getextrema.py +++ b/Tests/test_image_getextrema.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageGetExtrema(PillowTestCase): @@ -6,7 +6,7 @@ class TestImageGetExtrema(PillowTestCase): def test_extrema(self): def extrema(mode): - return lena(mode).getextrema() + return hopper(mode).getextrema() self.assertEqual(extrema("1"), (0, 255)) self.assertEqual(extrema("L"), (40, 235)) diff --git a/Tests/test_image_getim.py b/Tests/test_image_getim.py index d498d3923..e83439789 100644 --- a/Tests/test_image_getim.py +++ b/Tests/test_image_getim.py @@ -1,10 +1,10 @@ -from helper import unittest, PillowTestCase, lena, py3 +from helper import unittest, PillowTestCase, hopper, py3 class TestImageGetIm(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() type_repr = repr(type(im.getim())) if py3: diff --git a/Tests/test_image_getpalette.py b/Tests/test_image_getpalette.py index 0c399c432..1a673c73d 100644 --- a/Tests/test_image_getpalette.py +++ b/Tests/test_image_getpalette.py @@ -1,11 +1,11 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageGetPalette(PillowTestCase): def test_palette(self): def palette(mode): - p = lena(mode).getpalette() + p = hopper(mode).getpalette() if p: return p[:10] return None diff --git a/Tests/test_image_getprojection.py b/Tests/test_image_getprojection.py index 262a21d4b..108c75b90 100644 --- a/Tests/test_image_getprojection.py +++ b/Tests/test_image_getprojection.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageGetProjection(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() projection = im.getprojection() diff --git a/Tests/test_image_histogram.py b/Tests/test_image_histogram.py index 70f78a1fb..4bf8d2f80 100644 --- a/Tests/test_image_histogram.py +++ b/Tests/test_image_histogram.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageHistogram(PillowTestCase): @@ -6,7 +6,7 @@ class TestImageHistogram(PillowTestCase): def test_histogram(self): def histogram(mode): - h = lena(mode).histogram() + h = hopper(mode).histogram() return len(h), min(h), max(h) self.assertEqual(histogram("1"), (256, 0, 8872)) diff --git a/Tests/test_image_mode.py b/Tests/test_image_mode.py index 74ed9b7aa..6441c7d1b 100644 --- a/Tests/test_image_mode.py +++ b/Tests/test_image_mode.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageMode(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() im.mode from PIL import ImageMode diff --git a/Tests/test_image_offset.py b/Tests/test_image_offset.py index 09f12266f..e5fe0bf47 100644 --- a/Tests/test_image_offset.py +++ b/Tests/test_image_offset.py @@ -1,11 +1,11 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageOffset(PillowTestCase): def test_offset(self): - im1 = lena() + im1 = hopper() im2 = self.assert_warning(DeprecationWarning, lambda: im1.offset(10)) self.assertEqual(im1.getpixel((0, 0)), im2.getpixel((10, 10))) diff --git a/Tests/test_image_point.py b/Tests/test_image_point.py index 04054fa84..ee0165d09 100644 --- a/Tests/test_image_point.py +++ b/Tests/test_image_point.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper import sys @@ -6,7 +6,7 @@ import sys class TestImagePoint(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() self.assertRaises(ValueError, lambda: im.point(list(range(256)))) im.point(list(range(256))*3) @@ -28,19 +28,19 @@ class TestImagePoint(PillowTestCase): # see https://github.com/python-pillow/Pillow/issues/484 #self.skipKnownBadTest(msg="Too Slow on pypy", interpreter='pypy') - im = lena("I") + im = hopper("I") im.point(list(range(256))*256, 'L') def test_f_lut(self): """ Tests for floating point lut of 8bit gray image """ - im = lena('L') + im = hopper('L') lut = [0.5 * float(x) for x in range(256)] out = im.point(lut, 'F') int_lut = [x//2 for x in range(256)] self.assert_image_equal(out.convert('L'), im.point(int_lut, 'L')) - + if __name__ == '__main__': unittest.main() diff --git a/Tests/test_image_putdata.py b/Tests/test_image_putdata.py index acea0d62a..1535acf35 100644 --- a/Tests/test_image_putdata.py +++ b/Tests/test_image_putdata.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper import sys @@ -9,7 +9,7 @@ class TestImagePutData(PillowTestCase): def test_sanity(self): - im1 = lena() + im1 = hopper() data = list(im1.getdata()) @@ -47,7 +47,7 @@ class TestImagePutData(PillowTestCase): im.putdata(list(range(256))*256) def test_mode_i(self): - src = lena('L') + src = hopper('L') data = list(src.getdata()) im = Image.new('I', src.size, 0) im.putdata(data, 2, 256) @@ -56,7 +56,7 @@ class TestImagePutData(PillowTestCase): self.assertEqual(list(im.getdata()), target) def test_mode_F(self): - src = lena('L') + src = hopper('L') data = list(src.getdata()) im = Image.new('F', src.size, 0) im.putdata(data, 2.0, 256.0) @@ -64,7 +64,7 @@ class TestImagePutData(PillowTestCase): target = [2.0* float(elt) + 256.0 for elt in data] self.assertEqual(list(im.getdata()), target) - + if __name__ == '__main__': unittest.main() diff --git a/Tests/test_image_putpalette.py b/Tests/test_image_putpalette.py index a77c1e565..a1f00c361 100644 --- a/Tests/test_image_putpalette.py +++ b/Tests/test_image_putpalette.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import ImagePalette @@ -7,7 +7,7 @@ class TestImagePutPalette(PillowTestCase): def test_putpalette(self): def palette(mode): - im = lena(mode).copy() + im = hopper(mode).copy() im.putpalette(list(range(256))*3) p = im.getpalette() if p: @@ -23,7 +23,7 @@ class TestImagePutPalette(PillowTestCase): self.assertRaises(ValueError, lambda: palette("YCbCr")) def test_imagepalette(self): - im = lena("P") + im = hopper("P") im.putpalette(ImagePalette.negative()) im.putpalette(ImagePalette.random()) im.putpalette(ImagePalette.sepia()) diff --git a/Tests/test_image_putpixel.py b/Tests/test_image_putpixel.py index a7f5dc2bb..418e9703c 100644 --- a/Tests/test_image_putpixel.py +++ b/Tests/test_image_putpixel.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -9,7 +9,7 @@ class TestImagePutPixel(PillowTestCase): def test_sanity(self): - im1 = lena() + im1 = hopper() im2 = Image.new(im1.mode, im1.size, 0) for y in range(im1.size[1]): diff --git a/Tests/test_image_quantize.py b/Tests/test_image_quantize.py index 2cbdac225..e8183eb48 100644 --- a/Tests/test_image_quantize.py +++ b/Tests/test_image_quantize.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -6,17 +6,17 @@ from PIL import Image class TestImageQuantize(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() im = im.quantize() self.assert_image(im, "P", im.size) - im = lena() - im = im.quantize(palette=lena("P")) + im = hopper() + im = im.quantize(palette=hopper("P")) self.assert_image(im, "P", im.size) def test_octree_quantize(self): - im = lena() + im = hopper() im = im.quantize(100, Image.FASTOCTREE) self.assert_image(im, "P", im.size) @@ -24,7 +24,7 @@ class TestImageQuantize(PillowTestCase): assert len(im.getcolors()) == 100 def test_rgba_quantize(self): - im = lena('RGBA') + im = hopper('RGBA') im.quantize() self.assertRaises(Exception, lambda: im.quantize(method=0)) diff --git a/Tests/test_image_resize.py b/Tests/test_image_resize.py index 6c9932e45..603f598d8 100644 --- a/Tests/test_image_resize.py +++ b/Tests/test_image_resize.py @@ -1,11 +1,11 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageResize(PillowTestCase): def test_resize(self): def resize(mode, size): - out = lena(mode).resize(size) + out = hopper(mode).resize(size) self.assertEqual(out.mode, mode) self.assertEqual(out.size, size) for mode in "1", "P", "L", "RGB", "I", "F": diff --git a/Tests/test_image_rotate.py b/Tests/test_image_rotate.py index 531fdd63f..38391adae 100644 --- a/Tests/test_image_rotate.py +++ b/Tests/test_image_rotate.py @@ -1,11 +1,11 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageRotate(PillowTestCase): def test_rotate(self): def rotate(mode): - im = lena(mode) + im = hopper(mode) out = im.rotate(45) self.assertEqual(out.mode, mode) self.assertEqual(out.size, im.size) # default rotate clips output diff --git a/Tests/test_image_split.py b/Tests/test_image_split.py index 343f4bf8e..0e057523b 100644 --- a/Tests/test_image_split.py +++ b/Tests/test_image_split.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -7,7 +7,7 @@ class TestImageSplit(PillowTestCase): def test_split(self): def split(mode): - layers = lena(mode).split() + layers = hopper(mode).split() return [(i.mode, i.size[0], i.size[1]) for i in layers] self.assertEqual(split("1"), [('1', 128, 128)]) self.assertEqual(split("L"), [('L', 128, 128)]) @@ -30,16 +30,16 @@ class TestImageSplit(PillowTestCase): def test_split_merge(self): def split_merge(mode): - return Image.merge(mode, lena(mode).split()) - self.assert_image_equal(lena("1"), split_merge("1")) - self.assert_image_equal(lena("L"), split_merge("L")) - self.assert_image_equal(lena("I"), split_merge("I")) - self.assert_image_equal(lena("F"), split_merge("F")) - self.assert_image_equal(lena("P"), split_merge("P")) - self.assert_image_equal(lena("RGB"), split_merge("RGB")) - self.assert_image_equal(lena("RGBA"), split_merge("RGBA")) - self.assert_image_equal(lena("CMYK"), split_merge("CMYK")) - self.assert_image_equal(lena("YCbCr"), split_merge("YCbCr")) + return Image.merge(mode, hopper(mode).split()) + self.assert_image_equal(hopper("1"), split_merge("1")) + self.assert_image_equal(hopper("L"), split_merge("L")) + self.assert_image_equal(hopper("I"), split_merge("I")) + self.assert_image_equal(hopper("F"), split_merge("F")) + self.assert_image_equal(hopper("P"), split_merge("P")) + self.assert_image_equal(hopper("RGB"), split_merge("RGB")) + self.assert_image_equal(hopper("RGBA"), split_merge("RGBA")) + self.assert_image_equal(hopper("CMYK"), split_merge("CMYK")) + self.assert_image_equal(hopper("YCbCr"), split_merge("YCbCr")) def test_split_open(self): codecs = dir(Image.core) @@ -50,7 +50,7 @@ class TestImageSplit(PillowTestCase): file = self.tempfile("temp.pcx") def split_open(mode): - lena(mode).save(file) + hopper(mode).save(file) im = Image.open(file) return len(im.split()) self.assertEqual(split_open("1"), 1) diff --git a/Tests/test_image_thumbnail.py b/Tests/test_image_thumbnail.py index ee49be43e..d4c676bbd 100644 --- a/Tests/test_image_thumbnail.py +++ b/Tests/test_image_thumbnail.py @@ -1,38 +1,38 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageThumbnail(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() im.thumbnail((100, 100)) self.assert_image(im, im.mode, (100, 100)) def test_aspect(self): - im = lena() + im = hopper() im.thumbnail((100, 100)) self.assert_image(im, im.mode, (100, 100)) - im = lena().resize((128, 256)) + im = hopper().resize((128, 256)) im.thumbnail((100, 100)) self.assert_image(im, im.mode, (50, 100)) - im = lena().resize((128, 256)) + im = hopper().resize((128, 256)) im.thumbnail((50, 100)) self.assert_image(im, im.mode, (50, 100)) - im = lena().resize((256, 128)) + im = hopper().resize((256, 128)) im.thumbnail((100, 100)) self.assert_image(im, im.mode, (100, 50)) - im = lena().resize((256, 128)) + im = hopper().resize((256, 128)) im.thumbnail((100, 50)) self.assert_image(im, im.mode, (100, 50)) - im = lena().resize((128, 128)) + im = hopper().resize((128, 128)) im.thumbnail((100, 100)) self.assert_image(im, im.mode, (100, 100)) diff --git a/Tests/test_image_tobitmap.py b/Tests/test_image_tobitmap.py index 56b5ef001..e26a225c2 100644 --- a/Tests/test_image_tobitmap.py +++ b/Tests/test_image_tobitmap.py @@ -1,14 +1,14 @@ -from helper import unittest, PillowTestCase, lena, fromstring +from helper import unittest, PillowTestCase, hopper, fromstring class TestImageToBitmap(PillowTestCase): def test_sanity(self): - self.assertRaises(ValueError, lambda: lena().tobitmap()) - lena().convert("1").tobitmap() + self.assertRaises(ValueError, lambda: hopper().tobitmap()) + hopper().convert("1").tobitmap() - im1 = lena().convert("1") + im1 = hopper().convert("1") bitmap = im1.tobitmap() diff --git a/Tests/test_image_tobytes.py b/Tests/test_image_tobytes.py index 6dbf7d6f2..31a7e1722 100644 --- a/Tests/test_image_tobytes.py +++ b/Tests/test_image_tobytes.py @@ -1,10 +1,10 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper class TestImageToBytes(PillowTestCase): def test_sanity(self): - data = lena().tobytes() + data = hopper().tobytes() self.assertTrue(isinstance(data, bytes)) if __name__ == '__main__': diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py index 42a3d78f3..885893bbe 100644 --- a/Tests/test_image_transform.py +++ b/Tests/test_image_transform.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -22,7 +22,7 @@ class TestImageTransform(PillowTestCase): im.transform((100, 100), transform) def test_extent(self): - im = lena('RGB') + im = hopper('RGB') (w, h) = im.size transformed = im.transform(im.size, Image.EXTENT, (0, 0, @@ -36,7 +36,7 @@ class TestImageTransform(PillowTestCase): def test_quad(self): # one simple quad transform, equivalent to scale & crop upper left quad - im = lena('RGB') + im = hopper('RGB') (w, h) = im.size transformed = im.transform(im.size, Image.QUAD, (0, 0, 0, h//2, @@ -49,8 +49,8 @@ class TestImageTransform(PillowTestCase): self.assert_image_equal(transformed, scaled) def test_mesh(self): - # this should be a checkerboard of halfsized lenas in ul, lr - im = lena('RGBA') + # this should be a checkerboard of halfsized hoppers in ul, lr + im = hopper('RGBA') (w, h) = im.size transformed = im.transform(im.size, Image.MESH, [((0, 0, w//2, h//2), # box diff --git a/Tests/test_image_transpose.py b/Tests/test_image_transpose.py index f13e54ee7..3e4257bc0 100644 --- a/Tests/test_image_transpose.py +++ b/Tests/test_image_transpose.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -13,7 +13,7 @@ class TestImageTranspose(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() im.transpose(FLIP_LEFT_RIGHT) im.transpose(FLIP_TOP_BOTTOM) @@ -24,7 +24,7 @@ class TestImageTranspose(PillowTestCase): def test_roundtrip(self): - im = lena() + im = hopper() def transpose(first, second): return im.transpose(first).transpose(second) diff --git a/Tests/test_imagefile.py b/Tests/test_imagefile.py index 78fb3427f..3556661ae 100644 --- a/Tests/test_imagefile.py +++ b/Tests/test_imagefile.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena, fromstring, tostring +from helper import unittest, PillowTestCase, hopper, fromstring, tostring from io import BytesIO @@ -20,7 +20,7 @@ class TestImageFile(PillowTestCase): def roundtrip(format): - im = lena("L").resize((1000, 1000)) + im = hopper("L").resize((1000, 1000)) if format in ("MSP", "XBM"): im = im.convert("1") @@ -73,7 +73,7 @@ class TestImageFile(PillowTestCase): def test_safeblock(self): - im1 = lena() + im1 = hopper() if "zip_encoder" not in codecs: self.skipTest("PNG (zlib) encoder not available") diff --git a/Tests/test_imagefileio.py b/Tests/test_imagefileio.py index 32ee0bc5e..f18474403 100644 --- a/Tests/test_imagefileio.py +++ b/Tests/test_imagefileio.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena, tostring +from helper import unittest, PillowTestCase, hopper, tostring from PIL import Image from PIL import ImageFileIO @@ -19,7 +19,7 @@ class TestImageFileIo(PillowTestCase): def close(self): pass - im1 = lena() + im1 = hopper() io = ImageFileIO.ImageFileIO(DumbFile(tostring(im1, "PPM"))) diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py index a4a94ca4d..0ffb14bfe 100644 --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import ImageOps @@ -14,65 +14,65 @@ class TestImageOps(PillowTestCase): def test_sanity(self): - ImageOps.autocontrast(lena("L")) - ImageOps.autocontrast(lena("RGB")) + ImageOps.autocontrast(hopper("L")) + ImageOps.autocontrast(hopper("RGB")) - ImageOps.autocontrast(lena("L"), cutoff=10) - ImageOps.autocontrast(lena("L"), ignore=[0, 255]) + ImageOps.autocontrast(hopper("L"), cutoff=10) + ImageOps.autocontrast(hopper("L"), ignore=[0, 255]) - ImageOps.colorize(lena("L"), (0, 0, 0), (255, 255, 255)) - ImageOps.colorize(lena("L"), "black", "white") + ImageOps.colorize(hopper("L"), (0, 0, 0), (255, 255, 255)) + ImageOps.colorize(hopper("L"), "black", "white") - ImageOps.crop(lena("L"), 1) - ImageOps.crop(lena("RGB"), 1) + ImageOps.crop(hopper("L"), 1) + ImageOps.crop(hopper("RGB"), 1) - ImageOps.deform(lena("L"), self.deformer) - ImageOps.deform(lena("RGB"), self.deformer) + ImageOps.deform(hopper("L"), self.deformer) + ImageOps.deform(hopper("RGB"), self.deformer) - ImageOps.equalize(lena("L")) - ImageOps.equalize(lena("RGB")) + ImageOps.equalize(hopper("L")) + ImageOps.equalize(hopper("RGB")) - ImageOps.expand(lena("L"), 1) - ImageOps.expand(lena("RGB"), 1) - ImageOps.expand(lena("L"), 2, "blue") - ImageOps.expand(lena("RGB"), 2, "blue") + ImageOps.expand(hopper("L"), 1) + ImageOps.expand(hopper("RGB"), 1) + ImageOps.expand(hopper("L"), 2, "blue") + ImageOps.expand(hopper("RGB"), 2, "blue") - ImageOps.fit(lena("L"), (128, 128)) - ImageOps.fit(lena("RGB"), (128, 128)) + ImageOps.fit(hopper("L"), (128, 128)) + ImageOps.fit(hopper("RGB"), (128, 128)) - ImageOps.flip(lena("L")) - ImageOps.flip(lena("RGB")) + ImageOps.flip(hopper("L")) + ImageOps.flip(hopper("RGB")) - ImageOps.grayscale(lena("L")) - ImageOps.grayscale(lena("RGB")) + ImageOps.grayscale(hopper("L")) + ImageOps.grayscale(hopper("RGB")) - ImageOps.invert(lena("L")) - ImageOps.invert(lena("RGB")) + ImageOps.invert(hopper("L")) + ImageOps.invert(hopper("RGB")) - ImageOps.mirror(lena("L")) - ImageOps.mirror(lena("RGB")) + ImageOps.mirror(hopper("L")) + ImageOps.mirror(hopper("RGB")) - ImageOps.posterize(lena("L"), 4) - ImageOps.posterize(lena("RGB"), 4) + ImageOps.posterize(hopper("L"), 4) + ImageOps.posterize(hopper("RGB"), 4) - ImageOps.solarize(lena("L")) - ImageOps.solarize(lena("RGB")) + ImageOps.solarize(hopper("L")) + ImageOps.solarize(hopper("RGB")) def test_1pxfit(self): # Division by zero in equalize if image is 1 pixel high - newimg = ImageOps.fit(lena("RGB").resize((1, 1)), (35, 35)) + newimg = ImageOps.fit(hopper("RGB").resize((1, 1)), (35, 35)) self.assertEqual(newimg.size, (35, 35)) - newimg = ImageOps.fit(lena("RGB").resize((1, 100)), (35, 35)) + newimg = ImageOps.fit(hopper("RGB").resize((1, 100)), (35, 35)) self.assertEqual(newimg.size, (35, 35)) - newimg = ImageOps.fit(lena("RGB").resize((100, 1)), (35, 35)) + newimg = ImageOps.fit(hopper("RGB").resize((100, 1)), (35, 35)) self.assertEqual(newimg.size, (35, 35)) def test_pil163(self): # Division by zero in equalize if < 255 pixels in image (@PIL163) - i = lena("RGB").resize((15, 16)) + i = hopper("RGB").resize((15, 16)) ImageOps.equalize(i.convert("L")) ImageOps.equalize(i.convert("P")) diff --git a/Tests/test_imageops_usm.py b/Tests/test_imageops_usm.py index be7a669da..ba65f211b 100644 --- a/Tests/test_imageops_usm.py +++ b/Tests/test_imageops_usm.py @@ -4,7 +4,7 @@ from PIL import Image from PIL import ImageOps from PIL import ImageFilter -im = Image.open("Tests/images/lena.ppm") +im = Image.open("Tests/images/hopper.ppm") class TestImageOpsUsm(PillowTestCase): diff --git a/Tests/test_imageqt.py b/Tests/test_imageqt.py index fd50bf320..cd26e0038 100644 --- a/Tests/test_imageqt.py +++ b/Tests/test_imageqt.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper try: from PIL import ImageQt @@ -44,7 +44,7 @@ class TestImageQt(PillowTestCase): def test_image(self): for mode in ('1', 'RGB', 'RGBA', 'L', 'P'): - ImageQt.ImageQt(lena(mode)) + ImageQt.ImageQt(hopper(mode)) if __name__ == '__main__': diff --git a/Tests/test_imagesequence.py b/Tests/test_imagesequence.py index 068290451..62a83cda6 100644 --- a/Tests/test_imagesequence.py +++ b/Tests/test_imagesequence.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image, ImageSequence, TiffImagePlugin @@ -9,7 +9,7 @@ class TestImageSequence(PillowTestCase): file = self.tempfile("temp.im") - im = lena("RGB") + im = hopper("RGB") im.save(file) seq = ImageSequence.Iterator(im) @@ -31,14 +31,14 @@ class TestImageSequence(PillowTestCase): self.assertEqual(index, im.tell()) frame.convert('RGB') Image.DEBUG=False - + def test_tiff(self): #self._test_multipage_tiff(True) self._test_multipage_tiff(False) def test_libtiff(self): codecs = dir(Image.core) - + if "libtiff_encoder" not in codecs or "libtiff_decoder" not in codecs: self.skipTest("tiff support not available") @@ -46,7 +46,7 @@ class TestImageSequence(PillowTestCase): #self._test_multipage_tiff(True) self._test_multipage_tiff(False) TiffImagePlugin.READ_LIBTIFF = False - + if __name__ == '__main__': unittest.main() diff --git a/Tests/test_imagestat.py b/Tests/test_imagestat.py index 4d30ff023..fbb96599a 100644 --- a/Tests/test_imagestat.py +++ b/Tests/test_imagestat.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image from PIL import ImageStat @@ -8,7 +8,7 @@ class TestImageStat(PillowTestCase): def test_sanity(self): - im = lena() + im = hopper() st = ImageStat.Stat(im) st = ImageStat.Stat(im.histogram()) @@ -28,9 +28,9 @@ class TestImageStat(PillowTestCase): self.assertRaises(TypeError, lambda: ImageStat.Stat(1)) - def test_lena(self): + def test_hopper(self): - im = lena() + im = hopper() st = ImageStat.Stat(im) diff --git a/Tests/test_locale.py b/Tests/test_locale.py index 9ef136bf9..e4fab1497 100644 --- a/Tests/test_locale.py +++ b/Tests/test_locale.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -19,7 +19,7 @@ import locale # one of string.whitespace is not freely convertable into ascii. -path = "Tests/images/lena.jpg" +path = "Tests/images/hopper.jpg" class TestLocale(PillowTestCase): diff --git a/Tests/test_mode_i16.py b/Tests/test_mode_i16.py index 0cd5dba0f..4c6c181a8 100644 --- a/Tests/test_mode_i16.py +++ b/Tests/test_mode_i16.py @@ -1,11 +1,11 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image class TestModeI16(PillowTestCase): - original = lena().resize((32,32)).convert('I') + original = hopper().resize((32,32)).convert('I') def verify(self, im1): im2 = self.original.copy() @@ -39,10 +39,10 @@ class TestModeI16(PillowTestCase): imOut = imIn.transform((w, h), Image.EXTENT, (0, 0, w, h)) self.verify(imOut) # transform - filename = self.tempfile("temp.im") - imIn.save(filename) + fihopperme = self.tempfile("temp.im") + imIn.save(fihopperme) - imOut = Image.open(filename) + imOut = Image.open(fihopperme) self.verify(imIn) self.verify(imOut) diff --git a/Tests/test_numpy.py b/Tests/test_numpy.py index 07c3e0c21..b00b8b36b 100644 --- a/Tests/test_numpy.py +++ b/Tests/test_numpy.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image @@ -90,7 +90,7 @@ class TestNumpy(PillowTestCase): def test_to_array(self): def _to_array(mode, dtype): - img = lena(mode) + img = hopper(mode) np_img = numpy.array(img) self._test_img_equals_nparray(img, np_img) self.assertEqual(np_img.dtype, numpy.dtype(dtype)) @@ -117,7 +117,7 @@ class TestNumpy(PillowTestCase): data = list(range(256))*3 lut = numpy.array(data, dtype='uint8') - im = lena() + im = hopper() im.point(lut) diff --git a/Tests/test_pickle.py b/Tests/test_pickle.py index eae5eb671..595141cb7 100644 --- a/Tests/test_pickle.py +++ b/Tests/test_pickle.py @@ -6,20 +6,20 @@ from PIL import Image class TestPickle(PillowTestCase): def helper_pickle_file(self, pickle, protocol=0): - im = Image.open('Tests/images/lena.jpg') - filename = self.tempfile('temp.pkl') + im = Image.open('Tests/images/hopper.jpg') + fihopperme = self.tempfile('temp.pkl') # Act - with open(filename, 'wb') as f: + with open(fihopperme, 'wb') as f: pickle.dump(im, f, protocol) - with open(filename, 'rb') as f: + with open(fihopperme, 'rb') as f: loaded_im = pickle.load(f) # Assert self.assertEqual(im, loaded_im) def helper_pickle_string( - self, pickle, protocol=0, file='Tests/images/lena.jpg'): + self, pickle, protocol=0, file='Tests/images/hopper.jpg'): im = Image.open(file) # Act diff --git a/Tests/threaded_save.py b/Tests/threaded_save.py index 12fcff2cf..14ef42f17 100644 --- a/Tests/threaded_save.py +++ b/Tests/threaded_save.py @@ -9,7 +9,7 @@ try: except: format = "PNG" -im = Image.open("Tests/images/lena.ppm") +im = Image.open("Tests/images/hopper.ppm") im.load() queue = queue.Queue()