2023-12-21 14:13:31 +03:00
|
|
|
from __future__ import annotations
|
2024-01-20 14:23:03 +03:00
|
|
|
|
2018-01-29 18:18:06 +03:00
|
|
|
from PIL import WalImageFile
|
|
|
|
|
2021-07-18 05:35:27 +03:00
|
|
|
from .helper import assert_image_equal_tofile
|
|
|
|
|
2022-02-02 03:49:31 +03:00
|
|
|
TEST_FILE = "Tests/images/hopper.wal"
|
2019-07-06 23:40:53 +03:00
|
|
|
|
2018-01-29 18:18:06 +03:00
|
|
|
|
2024-01-27 07:19:43 +03:00
|
|
|
def test_open() -> None:
|
2021-07-18 05:35:27 +03:00
|
|
|
with WalImageFile.open(TEST_FILE) as im:
|
|
|
|
assert im.format == "WAL"
|
|
|
|
assert im.format_description == "Quake2 Texture"
|
|
|
|
assert im.mode == "P"
|
|
|
|
assert im.size == (128, 128)
|
|
|
|
|
|
|
|
assert isinstance(im, WalImageFile.WalImageFile)
|
2018-01-29 18:18:06 +03:00
|
|
|
|
2021-07-18 05:35:27 +03:00
|
|
|
assert_image_equal_tofile(im, "Tests/images/hopper_wal.png")
|
2022-02-02 03:49:31 +03:00
|
|
|
|
|
|
|
|
2024-01-27 07:19:43 +03:00
|
|
|
def test_load() -> None:
|
2022-02-02 03:49:31 +03:00
|
|
|
with WalImageFile.open(TEST_FILE) as im:
|
2024-09-09 15:34:46 +03:00
|
|
|
px = im.load()
|
|
|
|
assert px is not None
|
|
|
|
assert px[0, 0] == 122
|
2022-02-02 03:49:31 +03:00
|
|
|
|
|
|
|
# Test again now that it has already been loaded once
|
2024-09-09 15:34:46 +03:00
|
|
|
assert px[0, 0] == 122
|