Pillow/Tests/test_image_rotate.py

25 lines
771 B
Python
Raw Normal View History

from helper import unittest, PillowTestCase, hopper
from PIL import Image
2014-06-10 13:10:47 +04:00
class TestImageRotate(PillowTestCase):
def test_rotate(self):
def rotate(im, mode, angle):
out = im.rotate(angle)
2014-06-10 13:10:47 +04:00
self.assertEqual(out.mode, mode)
self.assertEqual(out.size, im.size) # default rotate clips output
out = im.rotate(angle, expand=1)
2014-06-10 13:10:47 +04:00
self.assertEqual(out.mode, mode)
self.assertNotEqual(out.size, im.size)
for mode in "1", "P", "L", "RGB", "I", "F":
im = hopper(mode)
rotate(im, mode, 45)
for angle in 90, 270:
im = Image.open('Tests/images/test-card.png')
rotate(im, im.mode, angle)
2014-06-10 13:10:47 +04:00
if __name__ == '__main__':
unittest.main()