Skip to content

Commit b0137ee

Browse files
committed
Updated test image to avoid converting
1 parent 0466df0 commit b0137ee

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

Tests/images/vtf_dxt1.png

920 Bytes
Loading

Tests/test_file_vtf.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ def test_get_texture_size(
8989
],
9090
)
9191
def test_vtf_read(file_path: str, expected_mode: str, epsilon: int) -> None:
92-
with Image.open(file_path) as f:
93-
assert f.mode == expected_mode
94-
with Image.open(file_path.replace(".vtf", ".png")) as e:
95-
converted_e = e.convert(expected_mode)
96-
if epsilon:
97-
assert_image_similar(f, converted_e, epsilon)
98-
else:
99-
assert_image_equal(f, converted_e)
92+
with Image.open(file_path) as im:
93+
assert im.mode == expected_mode
94+
with Image.open(file_path.replace(".vtf", ".png")) as expected:
95+
if epsilon:
96+
assert_image_similar(im, expected, epsilon)
97+
else:
98+
assert_image_equal(im, expected)
10099

101100

102101
def test_invalid_file() -> None:
@@ -146,14 +145,12 @@ def test_vtf_save(
146145
with Image.open(file_path) as im:
147146
out = tmp_path / "tmp.vtf"
148147
im.save(out, pixel_format=pixel_format, version=version)
149-
if pixel_format == VtfPF.DXT1:
150-
im = im.convert("RGBA")
151-
with Image.open(out) as expected:
152-
assert expected.mode == expected_mode
148+
with Image.open(out) as reloaded:
149+
assert reloaded.mode == expected_mode
153150
if epsilon:
154-
assert_image_similar(im, expected, epsilon)
151+
assert_image_similar(im, reloaded, epsilon)
155152
else:
156-
assert_image_equal(im, expected)
153+
assert_image_equal(im, reloaded)
157154

158155

159156
def test_vtf_save_unsupported_mode(tmp_path: Path) -> None:

0 commit comments

Comments
 (0)