mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
33dabf986f
The unittest in helper.py has not offered an interesting abstraction
since dbe9f85c7d
so import from the more
typical stdlib location.
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
import unittest
|
|
|
|
from PIL import Image
|
|
|
|
from .helper import PillowTestCase
|
|
|
|
|
|
class TestLibImage(PillowTestCase):
|
|
def test_setmode(self):
|
|
|
|
im = Image.new("L", (1, 1), 255)
|
|
im.im.setmode("1")
|
|
self.assertEqual(im.im.getpixel((0, 0)), 255)
|
|
im.im.setmode("L")
|
|
self.assertEqual(im.im.getpixel((0, 0)), 255)
|
|
|
|
im = Image.new("1", (1, 1), 1)
|
|
im.im.setmode("L")
|
|
self.assertEqual(im.im.getpixel((0, 0)), 255)
|
|
im.im.setmode("1")
|
|
self.assertEqual(im.im.getpixel((0, 0)), 255)
|
|
|
|
im = Image.new("RGB", (1, 1), (1, 2, 3))
|
|
im.im.setmode("RGB")
|
|
self.assertEqual(im.im.getpixel((0, 0)), (1, 2, 3))
|
|
im.im.setmode("RGBA")
|
|
self.assertEqual(im.im.getpixel((0, 0)), (1, 2, 3, 255))
|
|
im.im.setmode("RGBX")
|
|
self.assertEqual(im.im.getpixel((0, 0)), (1, 2, 3, 255))
|
|
im.im.setmode("RGB")
|
|
self.assertEqual(im.im.getpixel((0, 0)), (1, 2, 3))
|
|
|
|
self.assertRaises(ValueError, im.im.setmode, "L")
|
|
self.assertRaises(ValueError, im.im.setmode, "RGBABCDE")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|