Pillow/Tests/test_file_gbr.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
918 B
Python
Raw Normal View History

from __future__ import annotations
2024-01-20 14:23:03 +03:00
2020-02-12 19:29:19 +03:00
import pytest
from PIL import GbrImagePlugin, Image
2015-07-03 08:03:25 +03:00
from .helper import assert_image_equal_tofile
2015-07-03 08:03:25 +03:00
2024-01-27 07:19:43 +03:00
def test_gbr_file() -> None:
2020-02-12 19:29:19 +03:00
with Image.open("Tests/images/gbr.gbr") as im:
assert_image_equal_tofile(im, "Tests/images/gbr.png")
2024-01-27 07:19:43 +03:00
def test_load() -> None:
with Image.open("Tests/images/gbr.gbr") as im:
2024-09-09 15:34:46 +03:00
px = im.load()
assert px is not None
assert px[0, 0] == (0, 0, 0, 0)
# Test again now that it has already been loaded once
2024-09-09 15:34:46 +03:00
assert px[0, 0] == (0, 0, 0, 0)
2024-01-27 07:19:43 +03:00
def test_multiple_load_operations() -> None:
with Image.open("Tests/images/gbr.gbr") as im:
2020-05-17 04:04:02 +03:00
im.load()
im.load()
assert_image_equal_tofile(im, "Tests/images/gbr.png")
2024-01-27 07:19:43 +03:00
def test_invalid_file() -> None:
invalid_file = "Tests/images/flower.jpg"
with pytest.raises(SyntaxError):
GbrImagePlugin.GbrImageFile(invalid_file)