coverage tool done?

This commit is contained in:
sofijazolotarev 2024-06-24 01:11:50 +02:00
parent eb5244c795
commit 0496f0b1bc
3 changed files with 17 additions and 0 deletions

View File

@ -8,6 +8,8 @@ from PIL import SpiderImagePlugin
from PIL import MpegImagePlugin
from PIL import ImageCms
from PIL import McIdasImagePlugin
from PIL import BlpImagePlugin
from PIL import IcnsImagePlugin
pytest_plugins = ["Tests.helper"]
@ -20,6 +22,8 @@ def calculate_coverage(test_name):
"branches4": MpegImagePlugin.BitStream.branches,
"branches5": ImageCms.ImageCmsProfile.branches,
"branches6": McIdasImagePlugin.McIdasImageFile.branches,
"branches7": BlpImagePlugin._BLPBaseDecoder.branches,
"branches8": IcnsImagePlugin.branches,
# Add more
}

View File

@ -40,6 +40,10 @@ from typing import IO
from . import Image, ImageFile
branches = {
"1": False,
"2": False,
}
class Format(IntEnum):
JPEG = 0
@ -281,9 +285,11 @@ class _BLPBaseDecoder(ImageFile.PyDecoder):
def decode(self, buffer: bytes) -> tuple[int, int]:
try:
branches["1"] = True;
self._read_blp_header()
self._load()
except struct.error as e:
branches["2"] = True;
msg = "Truncated BLP file"
raise OSError(msg) from e
return -1, 0

View File

@ -33,6 +33,10 @@ if enable_jpeg2k:
MAGIC = b"icns"
HEADERSIZE = 8
branches = {
"1": False,
"2": False,
}
def nextheader(fobj):
return struct.unpack(">4sI", fobj.read(HEADERSIZE))
@ -44,8 +48,11 @@ def read_32t(fobj, start_length, size):
fobj.seek(start)
sig = fobj.read(4)
if sig != b"\x00\x00\x00\x00":
branches["1"] = True;
msg = "Unknown signature, expecting 0x00000000"
raise SyntaxError(msg)
else:
branches["2"] = True;
return read_32(fobj, (start + 4, length - 4), size)