Review, typos and lint

This commit is contained in:
Hugo van Kemenade 2021-04-01 17:41:46 +03:00
parent fea419665b
commit 8febdad8dd
7 changed files with 18 additions and 13 deletions

View File

@ -1,6 +1,7 @@
from PIL import Image
import pytest
from PIL import Image
from .helper import assert_image_equal_tofile

View File

@ -1,4 +1,5 @@
import io
import pytest
from PIL import EpsImagePlugin, Image, features
@ -268,9 +269,7 @@ def test_emptyline():
@pytest.mark.timeout(timeout=5)
@pytest.mark.parametrize(
"test_file",
[
("Tests/images/timeout-d675703545fee17acab56e5fec644c19979175de.eps")
],
["Tests/images/timeout-d675703545fee17acab56e5fec644c19979175de.eps"],
)
def test_timeout(test_file):
with open(test_file, "rb") as f:

View File

@ -131,11 +131,18 @@ def test_combined_larger_than_size():
with Image.open("Tests/images/combined_larger_than_size.psd"):
pass
@pytest.mark.parametrize(
"test_file,raises",
[
("Tests/images/timeout-1ee28a249896e05b83840ae8140622de8e648ba9.psd", Image.UnidentifiedImageError),
("Tests/images/timeout-598843abc37fc080ec36a2699ebbd44f795d3a6f.psd", Image.UnidentifiedImageError),
(
"Tests/images/timeout-1ee28a249896e05b83840ae8140622de8e648ba9.psd",
Image.UnidentifiedImageError,
),
(
"Tests/images/timeout-598843abc37fc080ec36a2699ebbd44f795d3a6f.psd",
Image.UnidentifiedImageError,
),
("Tests/images/timeout-c8efc3fded6426986ba867a399791bae544f59bc.psd", OSError),
("Tests/images/timeout-dedc7a4ebd856d79b4359bbcc79e8ef231ce38f6.psd", OSError),
],

View File

@ -625,12 +625,11 @@ class TestFileTiff:
)
def test_string_dimension(self):
# Assert that an error is raised if one of the dimensions is a string
with pytest.raises(OSError):
with Image.open("Tests/images/string_dimension.tiff") as im:
with Image.open("Tests/images/string_dimension.tiff") as im:
with pytest.raises(OSError):
im.load()
@pytest.mark.skipif(not is_win32(), reason="Windows only")
class TestFileTiffW32:
def test_fd_leak(self, tmp_path):

View File

@ -547,7 +547,7 @@ def _safe_read(fp, size):
:param size: Number of bytes to read.
:returns: A string containing <i>size</i> bytes of data.
Raises an OSError if the file is truncated and the read can not be completed
Raises an OSError if the file is truncated and the read cannot be completed
"""
if size <= 0:
@ -569,8 +569,6 @@ def _safe_read(fp, size):
return b"".join(data)
class PyCodecState:
def __init__(self):
self.xsize = 0

View File

@ -171,6 +171,7 @@ class PsdImageFile(ImageFile.ImageFile):
finally:
self.__fp = None
def _layerinfo(fp, ct_bytes):
# read layerinfo block
layers = []

View File

@ -244,7 +244,7 @@ ImagingFliDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t byt
}
advance = I32(ptr);
if (advance == 0 ) {
// If there's no advance, we're in in infinite loop
// If there's no advance, we're in an infinite loop
state->errcode = IMAGING_CODEC_BROKEN;
return -1;
}