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 import pytest
from PIL import Image
from .helper import assert_image_equal_tofile from .helper import assert_image_equal_tofile

View File

@ -1,4 +1,5 @@
import io import io
import pytest import pytest
from PIL import EpsImagePlugin, Image, features from PIL import EpsImagePlugin, Image, features
@ -268,9 +269,7 @@ def test_emptyline():
@pytest.mark.timeout(timeout=5) @pytest.mark.timeout(timeout=5)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"test_file", "test_file",
[ ["Tests/images/timeout-d675703545fee17acab56e5fec644c19979175de.eps"],
("Tests/images/timeout-d675703545fee17acab56e5fec644c19979175de.eps")
],
) )
def test_timeout(test_file): def test_timeout(test_file):
with open(test_file, "rb") as f: 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"): with Image.open("Tests/images/combined_larger_than_size.psd"):
pass pass
@pytest.mark.parametrize( @pytest.mark.parametrize(
"test_file,raises", "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-c8efc3fded6426986ba867a399791bae544f59bc.psd", OSError),
("Tests/images/timeout-dedc7a4ebd856d79b4359bbcc79e8ef231ce38f6.psd", OSError), ("Tests/images/timeout-dedc7a4ebd856d79b4359bbcc79e8ef231ce38f6.psd", OSError),
], ],

View File

@ -625,12 +625,11 @@ class TestFileTiff:
) )
def test_string_dimension(self): def test_string_dimension(self):
# Assert that an error is raised if one of the dimensions is a string # 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() im.load()
@pytest.mark.skipif(not is_win32(), reason="Windows only") @pytest.mark.skipif(not is_win32(), reason="Windows only")
class TestFileTiffW32: class TestFileTiffW32:
def test_fd_leak(self, tmp_path): def test_fd_leak(self, tmp_path):

View File

@ -569,8 +569,6 @@ def _safe_read(fp, size):
return b"".join(data) return b"".join(data)
class PyCodecState: class PyCodecState:
def __init__(self): def __init__(self):
self.xsize = 0 self.xsize = 0

View File

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

View File

@ -244,7 +244,7 @@ ImagingFliDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t byt
} }
advance = I32(ptr); advance = I32(ptr);
if (advance == 0 ) { 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; state->errcode = IMAGING_CODEC_BROKEN;
return -1; return -1;
} }