2014-07-17 00:45:18 +04:00
|
|
|
from helper import unittest, PillowTestCase
|
|
|
|
|
|
|
|
from PIL import Image, CurImagePlugin
|
|
|
|
|
2015-11-26 11:56:41 +03:00
|
|
|
TEST_FILE = "Tests/images/deerstalker.cur"
|
|
|
|
|
2014-07-17 00:45:18 +04:00
|
|
|
|
|
|
|
class TestFileCur(PillowTestCase):
|
|
|
|
|
|
|
|
def test_sanity(self):
|
2015-11-26 11:56:41 +03:00
|
|
|
im = Image.open(TEST_FILE)
|
2014-07-17 00:45:18 +04:00
|
|
|
|
|
|
|
self.assertEqual(im.size, (32, 32))
|
|
|
|
self.assertIsInstance(im, CurImagePlugin.CurImageFile)
|
2014-07-17 11:42:43 +04:00
|
|
|
# Check some pixel colors to ensure image is loaded properly
|
2015-03-05 12:55:32 +03:00
|
|
|
self.assertEqual(im.getpixel((10, 1)), (0, 0, 0, 0))
|
|
|
|
self.assertEqual(im.getpixel((11, 1)), (253, 254, 254, 1))
|
|
|
|
self.assertEqual(im.getpixel((16, 16)), (84, 87, 86, 255))
|
2014-07-17 00:45:18 +04:00
|
|
|
|
2015-07-03 08:03:25 +03:00
|
|
|
def test_invalid_file(self):
|
2015-07-03 09:22:56 +03:00
|
|
|
invalid_file = "Tests/images/flower.jpg"
|
|
|
|
|
|
|
|
self.assertRaises(SyntaxError,
|
|
|
|
lambda: CurImagePlugin.CurImageFile(invalid_file))
|
2015-07-03 08:03:25 +03:00
|
|
|
|
2015-11-26 11:56:41 +03:00
|
|
|
no_cursors_file = "Tests/images/no_cursors.cur"
|
|
|
|
|
|
|
|
cur = CurImagePlugin.CurImageFile(TEST_FILE)
|
|
|
|
cur.fp = open(no_cursors_file, "rb")
|
|
|
|
self.assertRaises(TypeError, cur._open)
|
|
|
|
|
2014-07-17 00:45:18 +04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|