2023-12-21 14:13:31 +03:00
|
|
|
from __future__ import annotations
|
2024-01-20 14:23:03 +03:00
|
|
|
|
2020-02-12 19:29:19 +03:00
|
|
|
import pytest
|
2020-08-07 13:28:33 +03:00
|
|
|
|
2019-07-06 23:40:53 +03:00
|
|
|
from PIL import GbrImagePlugin, Image
|
2015-07-03 08:03:25 +03:00
|
|
|
|
2021-02-21 14:15:56 +03:00
|
|
|
from .helper import assert_image_equal_tofile
|
2015-07-03 08:03:25 +03:00
|
|
|
|
|
|
|
|
2020-02-12 19:29:19 +03:00
|
|
|
def test_gbr_file():
|
|
|
|
with Image.open("Tests/images/gbr.gbr") as im:
|
2021-02-21 14:15:56 +03:00
|
|
|
assert_image_equal_tofile(im, "Tests/images/gbr.png")
|
2020-05-11 18:38:42 +03:00
|
|
|
|
|
|
|
|
2022-02-02 03:49:31 +03:00
|
|
|
def test_load():
|
|
|
|
with Image.open("Tests/images/gbr.gbr") as im:
|
|
|
|
assert im.load()[0, 0] == (0, 0, 0, 0)
|
|
|
|
|
|
|
|
# Test again now that it has already been loaded once
|
|
|
|
assert im.load()[0, 0] == (0, 0, 0, 0)
|
|
|
|
|
|
|
|
|
2020-05-17 04:04:02 +03:00
|
|
|
def test_multiple_load_operations():
|
2020-05-11 18:38:42 +03:00
|
|
|
with Image.open("Tests/images/gbr.gbr") as im:
|
2020-05-17 04:04:02 +03:00
|
|
|
im.load()
|
|
|
|
im.load()
|
2021-02-21 14:15:56 +03:00
|
|
|
assert_image_equal_tofile(im, "Tests/images/gbr.png")
|
2022-02-02 03:49:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
def test_invalid_file():
|
|
|
|
invalid_file = "Tests/images/flower.jpg"
|
|
|
|
|
|
|
|
with pytest.raises(SyntaxError):
|
|
|
|
GbrImagePlugin.GbrImageFile(invalid_file)
|