2020-01-27 14:46:52 +03:00
|
|
|
import pytest
|
2020-08-07 13:28:33 +03:00
|
|
|
|
2019-07-06 23:40:53 +03:00
|
|
|
from PIL import CurImagePlugin, Image
|
2014-07-17 00:45:18 +04:00
|
|
|
|
2015-11-26 11:56:41 +03:00
|
|
|
|
2022-09-23 04:06:07 +03:00
|
|
|
def test_deerstalker():
|
|
|
|
with Image.open("Tests/images/cur/deerstalker.cur") as im:
|
2020-01-27 14:46:52 +03:00
|
|
|
assert im.size == (32, 32)
|
|
|
|
assert isinstance(im, CurImagePlugin.CurImageFile)
|
|
|
|
# Check some pixel colors to ensure image is loaded properly
|
|
|
|
assert im.getpixel((10, 1)) == (0, 0, 0, 0)
|
|
|
|
assert im.getpixel((11, 1)) == (253, 254, 254, 1)
|
|
|
|
assert im.getpixel((16, 16)) == (84, 87, 86, 255)
|
|
|
|
|
2014-07-17 00:45:18 +04:00
|
|
|
|
2022-09-23 04:06:07 +03:00
|
|
|
def test_posy_link():
|
|
|
|
with Image.open("Tests/images/cur/posy_link.cur") as im:
|
|
|
|
assert im.size == (128, 128)
|
|
|
|
assert im.getpixel((0, 0)) == (0, 0, 0, 0)
|
|
|
|
assert im.getpixel((20, 20)) == (0, 0, 0, 255)
|
|
|
|
assert im.getpixel((40,40)) == (255, 255, 255, 255)
|
|
|
|
|
|
|
|
|
2020-01-27 14:46:52 +03:00
|
|
|
def test_invalid_file():
|
2022-09-23 04:06:07 +03:00
|
|
|
invalid_file = "Tests/images/cur/posy_link.png"
|
2015-07-03 09:22:56 +03:00
|
|
|
|
2020-01-27 14:46:52 +03:00
|
|
|
with pytest.raises(SyntaxError):
|
|
|
|
CurImagePlugin.CurImageFile(invalid_file)
|
2015-07-03 08:03:25 +03:00
|
|
|
|
2022-09-23 04:06:07 +03:00
|
|
|
no_cursors_file = "Tests/images/cur/no_cursors.cur"
|
2015-11-26 11:56:41 +03:00
|
|
|
|
2020-01-27 14:46:52 +03:00
|
|
|
cur = CurImagePlugin.CurImageFile(TEST_FILE)
|
|
|
|
cur.fp.close()
|
|
|
|
with open(no_cursors_file, "rb") as cur.fp:
|
|
|
|
with pytest.raises(TypeError):
|
|
|
|
cur._open()
|