mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-09-09 22:02:27 +03:00
Improve WalImageFile test coverage (#9189)
This commit is contained in:
commit
c0004726d6
|
@ -1,5 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
from PIL import WalImageFile
|
||||
|
||||
from .helper import assert_image_equal_tofile
|
||||
|
@ -13,12 +15,22 @@ def test_open() -> None:
|
|||
assert im.format_description == "Quake2 Texture"
|
||||
assert im.mode == "P"
|
||||
assert im.size == (128, 128)
|
||||
assert "next_name" not in im.info
|
||||
|
||||
assert isinstance(im, WalImageFile.WalImageFile)
|
||||
|
||||
assert_image_equal_tofile(im, "Tests/images/hopper_wal.png")
|
||||
|
||||
|
||||
def test_next_name() -> None:
|
||||
with open(TEST_FILE, "rb") as fp:
|
||||
data = bytearray(fp.read())
|
||||
data[56:60] = b"Test"
|
||||
f = BytesIO(data)
|
||||
with WalImageFile.open(f) as im:
|
||||
assert im.info["next_name"] == b"Test"
|
||||
|
||||
|
||||
def test_load() -> None:
|
||||
with WalImageFile.open(TEST_FILE) as im:
|
||||
px = im.load()
|
||||
|
|
|
@ -49,8 +49,7 @@ class WalImageFile(ImageFile.ImageFile):
|
|||
|
||||
# strings are null-terminated
|
||||
self.info["name"] = header[:32].split(b"\0", 1)[0]
|
||||
next_name = header[56 : 56 + 32].split(b"\0", 1)[0]
|
||||
if next_name:
|
||||
if next_name := header[56 : 56 + 32].split(b"\0", 1)[0]:
|
||||
self.info["next_name"] = next_name
|
||||
|
||||
def load(self) -> Image.core.PixelAccess | None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user