Various Flake8 fixes

This commit is contained in:
Andrew Murray 2015-07-03 16:22:56 +10:00
parent a06b59bd52
commit 309ab1fc3d
38 changed files with 144 additions and 53 deletions

View File

@ -31,7 +31,8 @@ class TestImagingLeaks(PillowTestCase):
def test_leak_putdata(self): def test_leak_putdata(self):
im = Image.new('RGB', (25, 25)) im = Image.new('RGB', (25, 25))
self._test_leak(min_iterations, max_iterations, im.putdata, im.getdata()) self._test_leak(min_iterations, max_iterations,
im.putdata, im.getdata())
def test_leak_getlist(self): def test_leak_getlist(self):
im = Image.new('P', (25, 25)) im = Image.new('P', (25, 25))

View File

@ -42,7 +42,8 @@ class TestPngDos(PillowTestCase):
total_len = 0 total_len = 0
for txt in im2.text.values(): for txt in im2.text.values():
total_len += len(txt) total_len += len(txt)
self.assertLess(total_len, 64*1024*1024, "Total text chunks greater than 64M") self.assertLess(total_len, 64*1024*1024,
"Total text chunks greater than 64M")
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -27,7 +27,8 @@ class TestFileBmp(PillowTestCase):
def test_invalid_file(self): def test_invalid_file(self):
with open("Tests/images/flower.jpg", "rb") as fp: with open("Tests/images/flower.jpg", "rb") as fp:
self.assertRaises(SyntaxError, lambda: BmpImagePlugin.BmpImageFile(fp)) self.assertRaises(SyntaxError,
lambda: BmpImagePlugin.BmpImageFile(fp))
def test_save_to_bytes(self): def test_save_to_bytes(self):
output = io.BytesIO() output = io.BytesIO()

View File

@ -6,7 +6,11 @@ from PIL import BufrStubImagePlugin
class TestFileBufrStub(PillowTestCase): class TestFileBufrStub(PillowTestCase):
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: BufrStubImagePlugin.BufrStubImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda:
BufrStubImagePlugin.BufrStubImageFile(invalid_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -21,7 +21,10 @@ class TestFileCur(PillowTestCase):
self.assertEqual(im.getpixel((16, 16)), (84, 87, 86, 255)) self.assertEqual(im.getpixel((16, 16)), (84, 87, 86, 255))
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: CurImagePlugin.CurImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: CurImagePlugin.CurImageFile(invalid_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -22,7 +22,8 @@ class TestFileDcx(PillowTestCase):
def test_invalid_file(self): def test_invalid_file(self):
with open("Tests/images/flower.jpg", "rb") as fp: with open("Tests/images/flower.jpg", "rb") as fp:
self.assertRaises(SyntaxError, lambda: DcxImagePlugin.DcxImageFile(fp)) self.assertRaises(SyntaxError,
lambda: DcxImagePlugin.DcxImageFile(fp))
def test_tell(self): def test_tell(self):
# Arrange # Arrange

View File

@ -52,7 +52,10 @@ class TestFileEps(PillowTestCase):
self.assertEqual(image2_scale2.format, "EPS") self.assertEqual(image2_scale2.format, "EPS")
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: EpsImagePlugin.EpsImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: EpsImagePlugin.EpsImageFile(invalid_file))
def test_file_object(self): def test_file_object(self):
# issue 479 # issue 479
@ -152,7 +155,9 @@ class TestFileEps(PillowTestCase):
Image.open(file3) Image.open(file3)
def _test_readline(self, t, ending): def _test_readline(self, t, ending):
ending = "Failure with line ending: %s" % ("".join("%s" % ord(s) for s in ending)) ending = "Failure with line ending: %s" % ("".join(
"%s" % ord(s)
for s in ending))
self.assertEqual(t.readline().strip('\r\n'), 'something', ending) self.assertEqual(t.readline().strip('\r\n'), 'something', ending)
self.assertEqual(t.readline().strip('\r\n'), 'else', ending) self.assertEqual(t.readline().strip('\r\n'), 'else', ending)
self.assertEqual(t.readline().strip('\r\n'), 'baz', ending) self.assertEqual(t.readline().strip('\r\n'), 'baz', ending)

View File

@ -6,7 +6,11 @@ from PIL import FitsStubImagePlugin
class TestFileFitsStub(PillowTestCase): class TestFileFitsStub(PillowTestCase):
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: FitsStubImagePlugin.FITSStubImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda:
FitsStubImagePlugin.FITSStubImageFile(invalid_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -19,7 +19,10 @@ class TestFileFli(PillowTestCase):
self.assertEqual(im.format, "FLI") self.assertEqual(im.format, "FLI")
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: FliImagePlugin.FliImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: FliImagePlugin.FliImageFile(invalid_file))
def test_n_frames(self): def test_n_frames(self):
im = Image.open(test_file) im = Image.open(test_file)

View File

@ -6,7 +6,10 @@ from PIL import FpxImagePlugin
class TestFileFpx(PillowTestCase): class TestFileFpx(PillowTestCase):
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: FpxImagePlugin.FpxImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: FpxImagePlugin.FpxImageFile(invalid_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -6,7 +6,10 @@ from PIL import GbrImagePlugin
class TestFileGbr(PillowTestCase): class TestFileGbr(PillowTestCase):
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: GbrImagePlugin.GbrImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: GbrImagePlugin.GbrImageFile(invalid_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -26,7 +26,10 @@ class TestFileGif(PillowTestCase):
self.assertEqual(im.format, "GIF") self.assertEqual(im.format, "GIF")
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: GifImagePlugin.GifImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: GifImagePlugin.GifImageFile(invalid_file))
def test_optimize(self): def test_optimize(self):
from io import BytesIO from io import BytesIO

View File

@ -6,7 +6,11 @@ from PIL import GribStubImagePlugin
class TestFileGribStub(PillowTestCase): class TestFileGribStub(PillowTestCase):
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: GribStubImagePlugin.GribStubImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda:
GribStubImagePlugin.GribStubImageFile(invalid_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -6,7 +6,11 @@ from PIL import Hdf5StubImagePlugin
class TestFileHdf5Stub(PillowTestCase): class TestFileHdf5Stub(PillowTestCase):
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: Hdf5StubImagePlugin.HDF5StubImageFile("Tests/images/flower.jpg")) test_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda:
Hdf5StubImagePlugin.HDF5StubImageFile(test_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -19,7 +19,8 @@ class TestFileIco(PillowTestCase):
def test_invalid_file(self): def test_invalid_file(self):
with open("Tests/images/flower.jpg", "rb") as fp: with open("Tests/images/flower.jpg", "rb") as fp:
self.assertRaises(SyntaxError, lambda: IcoImagePlugin.IcoImageFile(fp)) self.assertRaises(SyntaxError,
lambda: IcoImagePlugin.IcoImageFile(fp))
def test_save_to_bytes(self): def test_save_to_bytes(self):
output = io.BytesIO() output = io.BytesIO()
@ -34,7 +35,8 @@ class TestFileIco(PillowTestCase):
self.assertEqual(im.mode, reloaded.mode) self.assertEqual(im.mode, reloaded.mode)
self.assertEqual((64, 64), reloaded.size) self.assertEqual((64, 64), reloaded.size)
self.assertEqual(reloaded.format, "ICO") self.assertEqual(reloaded.format, "ICO")
self.assert_image_equal(reloaded, hopper().resize((64, 64), Image.LANCZOS)) self.assert_image_equal(reloaded,
hopper().resize((64, 64), Image.LANCZOS))
# the other one # the other one
output.seek(0) output.seek(0)
@ -44,7 +46,8 @@ class TestFileIco(PillowTestCase):
self.assertEqual(im.mode, reloaded.mode) self.assertEqual(im.mode, reloaded.mode)
self.assertEqual((32, 32), reloaded.size) self.assertEqual((32, 32), reloaded.size)
self.assertEqual(reloaded.format, "ICO") self.assertEqual(reloaded.format, "ICO")
self.assert_image_equal(reloaded, hopper().resize((32, 32), Image.LANCZOS)) self.assert_image_equal(reloaded,
hopper().resize((32, 32), Image.LANCZOS))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -41,7 +41,10 @@ class TestFileIm(PillowTestCase):
self.assert_image_equal(reread, im) self.assert_image_equal(reread, im)
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: ImImagePlugin.ImImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: ImImagePlugin.ImImageFile(invalid_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -291,22 +291,24 @@ class TestFileJpeg(PillowTestCase):
# dict of qtable lists # dict of qtable lists
self.assert_image_similar(im, self.assert_image_similar(im,
self.roundtrip(im, self.roundtrip(im, qtables={
qtables={0: standard_l_qtable, 0: standard_l_qtable,
1: standard_chrominance_qtable}), 1: standard_chrominance_qtable
30) }), 30)
# not a sequence # not a sequence
self.assertRaises(Exception, lambda: self.roundtrip(im, qtables='a')) self.assertRaises(Exception, lambda: self.roundtrip(im, qtables='a'))
# sequence wrong length # sequence wrong length
self.assertRaises(Exception, lambda: self.roundtrip(im, qtables=[])) self.assertRaises(Exception, lambda: self.roundtrip(im, qtables=[]))
# sequence wrong length # sequence wrong length
self.assertRaises(Exception, lambda: self.roundtrip(im, qtables=[1, 2, 3, 4, 5])) self.assertRaises(Exception,
lambda: self.roundtrip(im, qtables=[1, 2, 3, 4, 5]))
# qtable entry not a sequence # qtable entry not a sequence
self.assertRaises(Exception, lambda: self.roundtrip(im, qtables=[1])) self.assertRaises(Exception, lambda: self.roundtrip(im, qtables=[1]))
# qtable entry has wrong number of items # qtable entry has wrong number of items
self.assertRaises(Exception, lambda: self.roundtrip(im, qtables=[[1, 2, 3, 4]])) self.assertRaises(Exception,
lambda: self.roundtrip(im, qtables=[[1, 2, 3, 4]]))
@unittest.skipUnless(djpeg_available(), "djpeg not available") @unittest.skipUnless(djpeg_available(), "djpeg not available")
def test_load_djpeg(self): def test_load_djpeg(self):
@ -337,7 +339,8 @@ class TestFileJpeg(PillowTestCase):
""" Generates a very hard to compress file """ Generates a very hard to compress file
:param size: tuple :param size: tuple
""" """
return Image.frombytes('RGB', size, os.urandom(size[0]*size[1] * 3)) return Image.frombytes('RGB',
size, os.urandom(size[0]*size[1] * 3))
im = gen_random_image((512, 512)) im = gen_random_image((512, 512))
f = self.tempfile("temp.jpeg") f = self.tempfile("temp.jpeg")

View File

@ -40,7 +40,11 @@ class TestFileJpeg2k(PillowTestCase):
self.assertEqual(im.format, 'JPEG2000') self.assertEqual(im.format, 'JPEG2000')
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: Jpeg2KImagePlugin.Jpeg2KImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda:
Jpeg2KImagePlugin.Jpeg2KImageFile(invalid_file))
def test_bytesio(self): def test_bytesio(self):
with open('Tests/images/test-card-lossless.jp2', 'rb') as f: with open('Tests/images/test-card-lossless.jp2', 'rb') as f:

View File

@ -6,7 +6,11 @@ from PIL import McIdasImagePlugin
class TestFileMcIdas(PillowTestCase): class TestFileMcIdas(PillowTestCase):
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: McIdasImagePlugin.McIdasImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda:
McIdasImagePlugin.McIdasImageFile(invalid_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -6,7 +6,10 @@ from PIL import MicImagePlugin
class TestFileMic(PillowTestCase): class TestFileMic(PillowTestCase):
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: MicImagePlugin.MicImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: MicImagePlugin.MicImageFile(invalid_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -19,7 +19,10 @@ class TestFileMsp(PillowTestCase):
self.assertEqual(im.format, "MSP") self.assertEqual(im.format, "MSP")
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: MspImagePlugin.MspImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: MspImagePlugin.MspImageFile(invalid_file))
def test_open(self): def test_open(self):
# Arrange # Arrange

View File

@ -20,7 +20,10 @@ class TestFilePcx(PillowTestCase):
self._roundtrip(hopper(mode)) self._roundtrip(hopper(mode))
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: PcxImagePlugin.PcxImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: PcxImagePlugin.PcxImageFile(invalid_file))
def test_odd(self): def test_odd(self):
# see issue #523, odd sized images should have a stride that's even. # see issue #523, odd sized images should have a stride that's even.

View File

@ -82,7 +82,10 @@ class TestFilePng(PillowTestCase):
im = Image.open(test_file) im = Image.open(test_file)
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: PngImagePlugin.PngImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: PngImagePlugin.PngImageFile(invalid_file))
def test_broken(self): def test_broken(self):
# Check reading of totally broken files. In this case, the test # Check reading of totally broken files. In this case, the test

View File

@ -17,7 +17,10 @@ class TestImagePsd(PillowTestCase):
self.assertEqual(im.format, "PSD") self.assertEqual(im.format, "PSD")
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: PsdImagePlugin.PsdImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: PsdImagePlugin.PsdImageFile(invalid_file))
def test_n_frames(self): def test_n_frames(self):
im = Image.open("Tests/images/hopper_merged.psd") im = Image.open("Tests/images/hopper_merged.psd")

View File

@ -33,7 +33,11 @@ class TestFileSgi(PillowTestCase):
self.assertRaises(ValueError, lambda: Image.open(test_file)) self.assertRaises(ValueError, lambda: Image.open(test_file))
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(ValueError, lambda: SgiImagePlugin.SgiImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(ValueError,
lambda:
SgiImagePlugin.SgiImageFile(invalid_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -16,7 +16,9 @@ class TestFileSun(PillowTestCase):
# Assert # Assert
self.assertEqual(im.size, (128, 128)) self.assertEqual(im.size, (128, 128))
self.assertRaises(SyntaxError, lambda: SunImagePlugin.SunImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: SunImagePlugin.SunImageFile(invalid_file))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -86,7 +86,8 @@ class TestFileTiff(PillowTestCase):
try: try:
Image.open('Tests/images/hopper_bad_exif.jpg')._getexif() Image.open('Tests/images/hopper_bad_exif.jpg')._getexif()
except struct.error: except struct.error:
self.fail("Bad EXIF data should not pass incorrect values to _binary unpack") self.fail(
"Bad EXIF data passed incorrect values to _binary unpack")
def test_little_endian(self): def test_little_endian(self):
im = Image.open('Tests/images/16bit.cropped.tif') im = Image.open('Tests/images/16bit.cropped.tif')

View File

@ -83,7 +83,8 @@ class TestFileWebpAlpha(PillowTestCase):
image.load() image.load()
image.getdata() image.getdata()
# early versions of webp are known to produce higher deviations: deal with it # early versions of webp are known to produce higher deviations:
# deal with it
if _webp.WebPDecoderVersion(self) <= 0x201: if _webp.WebPDecoderVersion(self) <= 0x201:
self.assert_image_similar(image, pil_image, 3.0) self.assert_image_similar(image, pil_image, 3.0)
else: else:

View File

@ -19,7 +19,10 @@ class TestFileXpm(PillowTestCase):
self.assert_image_similar(im.convert('RGB'), hopper('RGB'), 60) self.assert_image_similar(im.convert('RGB'), hopper('RGB'), 60)
def test_invalid_file(self): def test_invalid_file(self):
self.assertRaises(SyntaxError, lambda: XpmImagePlugin.XpmImageFile("Tests/images/flower.jpg")) invalid_file = "Tests/images/flower.jpg"
self.assertRaises(SyntaxError,
lambda: XpmImagePlugin.XpmImageFile(invalid_file))
def test_load_read(self): def test_load_read(self):
# Arrange # Arrange

View File

@ -18,7 +18,8 @@ class TestImageColor(PillowTestCase):
(255, 0, 0, 0), ImageColor.getrgb("rgba(255, 0, 0, 0)")) (255, 0, 0, 0), ImageColor.getrgb("rgba(255, 0, 0, 0)"))
self.assertEqual((255, 0, 0), ImageColor.getrgb("red")) self.assertEqual((255, 0, 0), ImageColor.getrgb("red"))
self.assertRaises(ValueError, lambda: ImageColor.getrgb("invalid color")) self.assertRaises(ValueError,
lambda: ImageColor.getrgb("invalid color"))
# look for rounding errors (based on code by Tim Hatch) # look for rounding errors (based on code by Tim Hatch)
def test_rounding_errors(self): def test_rounding_errors(self):
@ -45,8 +46,8 @@ class TestImageColor(PillowTestCase):
self.assertEqual(0, ImageColor.getcolor("black", "L")) self.assertEqual(0, ImageColor.getcolor("black", "L"))
self.assertEqual(255, ImageColor.getcolor("white", "L")) self.assertEqual(255, ImageColor.getcolor("white", "L"))
self.assertEqual( self.assertEqual(162,
162, ImageColor.getcolor("rgba(0, 255, 115, 33)", "L")) ImageColor.getcolor("rgba(0, 255, 115, 33)", "L"))
Image.new("L", (1, 1), "white") Image.new("L", (1, 1), "white")
self.assertEqual(0, ImageColor.getcolor("black", "1")) self.assertEqual(0, ImageColor.getcolor("black", "1"))

View File

@ -55,7 +55,8 @@ class TestImageDraw(PillowTestCase):
def test_mode_mismatch(self): def test_mode_mismatch(self):
im = hopper("RGB").copy() im = hopper("RGB").copy()
self.assertRaises(ValueError, lambda: ImageDraw.ImageDraw(im, mode="L")) self.assertRaises(ValueError,
lambda: ImageDraw.ImageDraw(im, mode="L"))
def helper_arc(self, bbox): def helper_arc(self, bbox):
# Arrange # Arrange

View File

@ -5,16 +5,19 @@ from PIL import Image, ImageFont, ImageDraw
class TestImageFontBitmap(PillowTestCase): class TestImageFontBitmap(PillowTestCase):
def test_similar(self): def test_similar(self):
text = 'EmbeddedBitmap' text = 'EmbeddedBitmap'
font_outline = ImageFont.truetype(font='Tests/fonts/DejaVuSans.ttf', size=24) font_outline = ImageFont.truetype(
font_bitmap = ImageFont.truetype(font='Tests/fonts/DejaVuSans-bitmap.ttf', size=24) font='Tests/fonts/DejaVuSans.ttf', size=24)
font_bitmap = ImageFont.truetype(
font='Tests/fonts/DejaVuSans-bitmap.ttf', size=24)
size_outline, size_bitmap = font_outline.getsize(text), font_bitmap.getsize(text) size_outline, size_bitmap = font_outline.getsize(text), font_bitmap.getsize(text)
size_final = max(size_outline[0], size_bitmap[0]), max(size_outline[1], size_bitmap[1]) size_final = max(size_outline[0], size_bitmap[0]), max(size_outline[1], size_bitmap[1])
im_bitmap = Image.new('RGB', size_final, (255, 255, 255)) im_bitmap = Image.new('RGB', size_final, (255, 255, 255))
im_outline = im_bitmap.copy() im_outline = im_bitmap.copy()
draw_bitmap, draw_outline = ImageDraw.Draw(im_bitmap), ImageDraw.Draw(im_outline) draw_bitmap, draw_outline = ImageDraw.Draw(im_bitmap), ImageDraw.Draw(im_outline)
# Metrics are different on the bitmap and ttf fonts, more so on some platforms # Metrics are different on the bitmap and ttf fonts,
# and versions of freetype than others. Mac has a 1px difference, linux doesn't. # more so on some platforms and versions of freetype than others.
# Mac has a 1px difference, linux doesn't.
draw_bitmap.text((0, size_final[1] - size_bitmap[1]), draw_bitmap.text((0, size_final[1] - size_bitmap[1]),
text, fill=(0, 0, 0), font=font_bitmap) text, fill=(0, 0, 0), font=font_bitmap)
draw_outline.text((0, size_final[1] - size_outline[1]), draw_outline.text((0, size_final[1] - size_outline[1]),

View File

@ -75,7 +75,9 @@ class TestImageOpsUsm(PillowTestCase):
(4, 3, 2), (4, 2, 2)]: (4, 3, 2), (4, 2, 2)]:
self.assertGreaterEqual(i.im.getpixel((x, y))[c], 250) self.assertGreaterEqual(i.im.getpixel((x, y))[c], 250)
# Fuzzy match. # Fuzzy match.
gp = lambda x, y: i.im.getpixel((x, y))
def gp(x, y):
return i.im.getpixel((x, y))
self.assertTrue(236 <= gp(7, 4)[0] <= 239) self.assertTrue(236 <= gp(7, 4)[0] <= 239)
self.assertTrue(236 <= gp(7, 5)[2] <= 239) self.assertTrue(236 <= gp(7, 5)[2] <= 239)
self.assertTrue(236 <= gp(7, 6)[2] <= 239) self.assertTrue(236 <= gp(7, 6)[2] <= 239)

View File

@ -115,7 +115,8 @@ class TestImageWinDib(PillowTestCase):
# Act/Assert # Act/Assert
self.assert_warning(DeprecationWarning, dib.tostring) self.assert_warning(DeprecationWarning, dib.tostring)
self.assert_warning(DeprecationWarning, lambda: dib.fromstring(test_buffer)) self.assert_warning(DeprecationWarning,
lambda: dib.fromstring(test_buffer))
if __name__ == '__main__': if __name__ == '__main__':