aboutsummaryrefslogtreecommitdiffstats
path: root/test/reader/image/test_pillow.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/reader/image/test_pillow.py')
-rw-r--r--test/reader/image/test_pillow.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/reader/image/test_pillow.py b/test/reader/image/test_pillow.py
new file mode 100644
index 0000000..2cff768
--- /dev/null
+++ b/test/reader/image/test_pillow.py
@@ -0,0 +1,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 ##