Line too long

This commit is contained in:
Andrew Murray 2018-09-27 20:35:00 +10:00
parent f8fbac68de
commit a8261a2e89
12 changed files with 46 additions and 26 deletions

View File

@ -25,9 +25,8 @@ class TestImagingLeaks(PillowTestCase):
if i < min_iterations:
mem_limit = mem + 1
continue
self.assertLessEqual(mem, mem_limit,
msg='memory usage limit exceeded after %d iterations'
% (i + 1))
msg = 'memory usage limit exceeded after %d iterations' % (i + 1)
self.assertLessEqual(mem, mem_limit, msg)
def test_leak_putdata(self):
im = Image.new('RGB', (25, 25))

View File

@ -272,8 +272,8 @@ class PillowLeakTestCase(PillowTestCase):
for cycle in range(self.iterations):
core()
mem = (self._get_mem_usage() - start_mem)
self.assertLess(mem, self.mem_limit,
msg='memory usage limit exceeded in iteration %d' % cycle)
msg = 'memory usage limit exceeded in iteration %d' % cycle
self.assertLess(mem, self.mem_limit, msg)
# helpers

View File

@ -42,7 +42,8 @@ class TestBmpReference(PillowTestCase):
im = Image.open(f)
im.load()
if os.path.basename(f) not in supported:
print("Please add %s to the partially supported bmp specs." % f)
print("Please add %s to the partially supported"
" bmp specs." % f)
except Exception: # as msg:
if os.path.basename(f) in supported:
raise

View File

@ -58,7 +58,8 @@ class TestFileTiff(PillowTestCase):
self.assertEqual(im.mode, "RGBA")
self.assertEqual(im.size, (52, 53))
self.assertEqual(im.tile, [('raw', (0, 0, 52, 53), 160, ('RGBA', 0, 1))])
self.assertEqual(im.tile,
[('raw', (0, 0, 52, 53), 160, ('RGBA', 0, 1))])
im.load()
def test_set_legacy_api(self):

View File

@ -56,7 +56,8 @@ class TestFileTiffMetadata(PillowTestCase):
loaded = Image.open(f)
self.assertEqual(loaded.tag[ImageJMetaDataByteCounts], (len(bindata),))
self.assertEqual(loaded.tag_v2[ImageJMetaDataByteCounts], (len(bindata),))
self.assertEqual(loaded.tag_v2[ImageJMetaDataByteCounts],
(len(bindata),))
self.assertEqual(loaded.tag[ImageJMetaData], bindata)
self.assertEqual(loaded.tag_v2[ImageJMetaData], bindata)
@ -75,8 +76,10 @@ class TestFileTiffMetadata(PillowTestCase):
img.save(f, tiffinfo=info)
loaded = Image.open(f)
self.assertEqual(loaded.tag[ImageJMetaDataByteCounts], (8, len(bindata) - 8))
self.assertEqual(loaded.tag_v2[ImageJMetaDataByteCounts], (8, len(bindata) - 8))
self.assertEqual(loaded.tag[ImageJMetaDataByteCounts],
(8, len(bindata) - 8))
self.assertEqual(loaded.tag_v2[ImageJMetaDataByteCounts],
(8, len(bindata) - 8))
def test_read_metadata(self):
img = Image.open('Tests/images/hopper_g4.tif')
@ -133,8 +136,8 @@ class TestFileTiffMetadata(PillowTestCase):
if isinstance(v, IFDRational):
original[k] = IFDRational(*_limit_rational(v, 2**31))
if isinstance(v, tuple) and isinstance(v[0], IFDRational):
original[k] = tuple([IFDRational(
*_limit_rational(elt, 2**31)) for elt in v])
original[k] = tuple([IFDRational(*_limit_rational(elt, 2**31))
for elt in v])
ignored = ['StripByteCounts', 'RowsPerStrip',
'PageNumber', 'StripOffsets']
@ -184,7 +187,8 @@ class TestFileTiffMetadata(PillowTestCase):
def test_iccprofile_binary(self):
# https://github.com/python-pillow/Pillow/issues/1526
# We should be able to load this, but probably won't be able to save it.
# We should be able to load this,
# but probably won't be able to save it.
im = Image.open('Tests/images/hopper.iccprofile_binary.tif')
self.assertEqual(im.tag_v2.tagtype[34675], 1)

View File

@ -38,7 +38,8 @@ class TestFileWebp(PillowTestCase):
# generated with:
# dwebp -ppm ../../Tests/images/hopper.webp -o hopper_webp_bits.ppm
self.assert_image_similar_tofile(image, 'Tests/images/hopper_webp_bits.ppm', 1.0)
self.assert_image_similar_tofile(
image, 'Tests/images/hopper_webp_bits.ppm', 1.0)
def test_write_rgb(self):
"""
@ -58,7 +59,8 @@ class TestFileWebp(PillowTestCase):
image.getdata()
# generated with: dwebp -ppm temp.webp -o hopper_webp_write.ppm
self.assert_image_similar_tofile(image, 'Tests/images/hopper_webp_write.ppm', 12.0)
self.assert_image_similar_tofile(
image, 'Tests/images/hopper_webp_write.ppm', 12.0)
# This test asserts that the images are similar. If the average pixel
# difference between the two images is less than the epsilon value,

View File

@ -204,7 +204,8 @@ class TestImageConvert(PillowTestCase):
target = Image.open('Tests/images/hopper-XYZ.png')
if converted_im.mode == 'RGB':
self.assert_image_similar(converted_im, target, 3)
self.assertEqual(converted_im.info['transparency'], (105, 54, 4))
self.assertEqual(converted_im.info['transparency'],
(105, 54, 4))
else:
self.assert_image_similar(converted_im,
target.getchannel(0), 1)

View File

@ -221,7 +221,8 @@ class TestLibUnpack(PillowTestCase):
data_len = data * len(pixels)
data = bytes(bytearray(range(1, data_len + 1)))
im = Image.frombytes(mode, (len(pixels), 1), data, "raw", rawmode, 0, 1)
im = Image.frombytes(mode, (len(pixels), 1), data,
"raw", rawmode, 0, 1)
for x, pixel in enumerate(pixels):
self.assertEqual(pixel, im.getpixel((x, 0)))
@ -265,9 +266,11 @@ class TestLibUnpack(PillowTestCase):
def test_P(self):
self.assert_unpack("P", "P;1", b'\xe4', 1, 1, 1, 0, 0, 1, 0, 0)
self.assert_unpack("P", "P;2", b'\xe4', 3, 2, 1, 0)
# self.assert_unpack("P", "P;2L", b'\xe4', 1, 1, 1, 0) # erroneous?
# erroneous?
# self.assert_unpack("P", "P;2L", b'\xe4', 1, 1, 1, 0)
self.assert_unpack("P", "P;4", b'\x02\xef', 0, 2, 14, 15)
# self.assert_unpack("P", "P;4L", b'\x02\xef', 2, 10, 10, 0) # erroneous?
# erroneous?
# self.assert_unpack("P", "P;4L", b'\x02\xef', 2, 10, 10, 0)
self.assert_unpack("P", "P", 1, 1, 2, 3, 4)
self.assert_unpack("P", "P;R", 1, 128, 64, 192, 32)
@ -373,7 +376,8 @@ class TestLibUnpack(PillowTestCase):
self.assert_unpack(
"RGBA", "YCCA;P",
b']bE\x04\xdd\xbej\xed57T\xce\xac\xce:\x11', # random data
(0, 161, 0, 4), (255, 255, 255, 237), (27, 158, 0, 206), (0, 118, 0, 17))
(0, 161, 0, 4), (255, 255, 255, 237),
(27, 158, 0, 206), (0, 118, 0, 17))
self.assert_unpack(
"RGBA", "R", 1, (1, 0, 0, 0), (2, 0, 0, 0), (3, 0, 0, 0))
self.assert_unpack(
@ -425,7 +429,8 @@ class TestLibUnpack(PillowTestCase):
self.assert_unpack(
"RGBX", "YCC;P",
b'D]\x9c\x82\x1a\x91\xfaOC\xe7J\x12', # random data
(127, 102, 0, X), (192, 227, 0, X), (213, 255, 170, X), (98, 255, 133, X))
(127, 102, 0, X), (192, 227, 0, X),
(213, 255, 170, X), (98, 255, 133, X))
self.assert_unpack("RGBX", "R", 1,
(1, 0, 0, 0), (2, 0, 0, 0), (3, 0, 0, 0))
self.assert_unpack("RGBX", "G", 1,

View File

@ -26,7 +26,9 @@ class TestPdfParser(PillowTestCase):
def test_parsing(self):
self.assertEqual(PdfParser.interpret_name(b"Name#23Hash"),
b"Name#Hash")
self.assertEqual(PdfParser.interpret_name(b"Name#23Hash", as_text=True), "Name#Hash")
self.assertEqual(PdfParser.interpret_name(
b"Name#23Hash", as_text=True
), "Name#Hash")
self.assertEqual(PdfParser.get_value(b"1 2 R ", 0),
(IndirectReference(1, 2), 5))
self.assertEqual(PdfParser.get_value(b"true[", 0), (True, 4))
@ -72,7 +74,9 @@ class TestPdfParser(PillowTestCase):
self.assertIsInstance(a, list)
self.assertEqual(len(a), 4)
self.assertEqual(a[0], PdfName("Name"))
s = PdfParser.get_value(b"<</Name (value) /Length 5>>\nstream\nabcde\nendstream<<...", 0)[0]
s = PdfParser.get_value(
b"<</Name (value) /Length 5>>\nstream\nabcde\nendstream<<...", 0
)[0]
self.assertIsInstance(s, PdfStream)
self.assertEqual(s.dictionary.Name, "value")
self.assertEqual(s.decode(), b"abcde")

View File

@ -61,7 +61,8 @@ class GdImageFile(ImageFile.ImageFile):
self.palette = ImagePalette.raw("XBGR", s[7+trueColorOffset+4:7+trueColorOffset+4+256*4])
self.tile = [("raw", (0, 0)+self.size, 7+trueColorOffset+4+256*4, ("L", 0, 1))]
self.tile = [("raw", (0, 0)+self.size, 7+trueColorOffset+4+256*4,
("L", 0, 1))]
def open(fp, mode="r"):

View File

@ -162,7 +162,8 @@ class FreeTypeFont(object):
size, offset = self.font.getsize(text, direction, features)
return (size[0] + offset[0], size[1] + offset[1])
def getsize_multiline(self, text, direction=None, spacing=4, features=None):
def getsize_multiline(self, text, direction=None,
spacing=4, features=None):
max_width = 0
lines = self._multiline_split(text)
line_spacing = self.getsize('A')[1] + spacing

View File

@ -28,7 +28,8 @@ qt_versions = [
['side', 'PySide']
]
# If a version has already been imported, attempt it first
qt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, reverse=True)
qt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules,
reverse=True)
for qt_version, qt_module in qt_versions:
try:
if qt_module == 'PyQt5':