File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
+ from io import BytesIO
4
+
3
5
from PIL import WalImageFile
4
6
5
7
from .helper import assert_image_equal_tofile
@@ -13,12 +15,22 @@ def test_open() -> None:
13
15
assert im .format_description == "Quake2 Texture"
14
16
assert im .mode == "P"
15
17
assert im .size == (128 , 128 )
18
+ assert "next_name" not in im .info
16
19
17
20
assert isinstance (im , WalImageFile .WalImageFile )
18
21
19
22
assert_image_equal_tofile (im , "Tests/images/hopper_wal.png" )
20
23
21
24
25
+ def test_next_name () -> None :
26
+ with open (TEST_FILE , "rb" ) as fp :
27
+ data = bytearray (fp .read ())
28
+ data [56 :60 ] = b"Test"
29
+ f = BytesIO (data )
30
+ with WalImageFile .open (f ) as im :
31
+ assert im .info ["next_name" ] == b"Test"
32
+
33
+
22
34
def test_load () -> None :
23
35
with WalImageFile .open (TEST_FILE ) as im :
24
36
px = im .load ()
Original file line number Diff line number Diff line change @@ -49,8 +49,7 @@ def _open(self) -> None:
49
49
50
50
# strings are null-terminated
51
51
self .info ["name" ] = header [:32 ].split (b"\0 " , 1 )[0 ]
52
- next_name = header [56 : 56 + 32 ].split (b"\0 " , 1 )[0 ]
53
- if next_name :
52
+ if next_name := header [56 : 56 + 32 ].split (b"\0 " , 1 )[0 ]:
54
53
self .info ["next_name" ] = next_name
55
54
56
55
def load (self ) -> Image .core .PixelAccess | None :
You can’t perform that action at this time.
0 commit comments