blob: 2cff768d4ae2663828bc40b7810f7452971d8c90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# standard imports
import os
import unittest
# external imports
import PIL.Image
# bsie imports
from bsie.utils import errors
# objects to test
from bsie.reader.image._pillow import PillowImage
## code ##
class TestPillowImage(unittest.TestCase):
def test_call(self):
rdr = PillowImage()
# returns PIL image
img = rdr(os.path.join(os.path.dirname(__file__), 'testimage.jpg'))
self.assertEqual(img.size, (1, 1))
self.assertEqual(img.getdata().getpixel((0, 0)), (0, 0, 0))
img.close()
# raises exception when image cannot be read
self.assertRaises(errors.ReaderError, rdr,
os.path.join(os.path.dirname(__file__), 'invalid.jpg'))
# NOTE: PIL can actually read raw image files (returns the thumbnail)
#self.assertRaises(errors.ReaderError, rdr,
# os.path.join(os.path.dirname(__file__), 'testimage.nef'))
## main ##
if __name__ == '__main__':
unittest.main()
## EOF ##
|