aboutsummaryrefslogtreecommitdiffstats
path: root/test/reader/image/test_pillow.py
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-01-16 21:37:09 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-01-16 21:37:09 +0100
commit05a841215c82ef40d4679dfc4d2c26572bd4d349 (patch)
tree9888ae0bd2345816d1ab479dd34b4c6b902c158a /test/reader/image/test_pillow.py
parent057e09d6537bf5c39815661a75819081e3e5fda7 (diff)
parent58aaa864f9747d27c065739256d4c6635ca9b751 (diff)
downloadbsie-05a841215c82ef40d4679dfc4d2c26572bd4d349.tar.gz
bsie-05a841215c82ef40d4679dfc4d2c26572bd4d349.tar.bz2
bsie-05a841215c82ef40d4679dfc4d2c26572bd4d349.zip
Merge branch 'mb/feature' into develop
Diffstat (limited to 'test/reader/image/test_pillow.py')
-rw-r--r--test/reader/image/test_pillow.py44
1 files changed, 44 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..8abf5c1
--- /dev/null
+++ b/test/reader/image/test_pillow.py
@@ -0,0 +1,44 @@
+"""
+
+Part of the bsie test suite.
+A copy of the license is provided with the project.
+Author: Matthias Baumgartner, 2022
+"""
+# 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 ##