From cc1ba56c2819fd542d6d750554505cfacde00025 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Sat, 31 Dec 2016 19:12:39 +0000 Subject: [PATCH] Refactor tests --- Tests/test_image_rotate.py | 45 +++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/Tests/test_image_rotate.py b/Tests/test_image_rotate.py index f2a3c4fa8..865544350 100644 --- a/Tests/test_image_rotate.py +++ b/Tests/test_image_rotate.py @@ -4,36 +4,41 @@ from PIL import Image class TestImageRotate(PillowTestCase): - def test_rotate(self): - def rotate(im, mode, angle, center=None, translate=None): - out = im.rotate(angle, center=center, translate=translate) - self.assertEqual(out.mode, mode) - self.assertEqual(out.size, im.size) # default rotate clips output - out = im.rotate(angle, center=center, translate=translate, expand=1) - self.assertEqual(out.mode, mode) - if angle % 180 == 0: - self.assertEqual(out.size, im.size) - elif im.size == (0, 0): - self.assertEqual(out.size, im.size) - else: - self.assertNotEqual(out.size, im.size) + def rotate(self, im, mode, angle, center=None, translate=None): + out = im.rotate(angle, center=center, translate=translate) + self.assertEqual(out.mode, mode) + self.assertEqual(out.size, im.size) # default rotate clips output + out = im.rotate(angle, center=center, translate=translate, expand=1) + self.assertEqual(out.mode, mode) + if angle % 180 == 0: + self.assertEqual(out.size, im.size) + elif im.size == (0, 0): + self.assertEqual(out.size, im.size) + else: + self.assertNotEqual(out.size, im.size) - + def test_mode(self): for mode in ("1", "P", "L", "RGB", "I", "F"): im = hopper(mode) - rotate(im, mode, 45) + self.rotate(im, mode, 45) + def test_angle(self): for angle in (0, 90, 180, 270): im = Image.open('Tests/images/test-card.png') - rotate(im, im.mode, angle) + self.rotate(im, im.mode, angle) + def test_zero(self): for angle in (0, 45, 90, 180, 270): im = Image.new('RGB',(0,0)) - rotate(im, im.mode, angle) + self.rotate(im, im.mode, angle) - rotate(im, im.mode, 45, center=(0, 0)) - rotate(im, im.mode, 45, translate=(im.size[0]/2, 0)) - rotate(im, im.mode, 45, center=(0, 0), translate=(im.size[0]/2, 0)) + def test_center(self): + im = hopper() + self.rotate(im, im.mode, 45, center=(0, 0)) + self.rotate(im, im.mode, 45, translate=(im.size[0]/2, 0)) + self.rotate(im, im.mode, 45, center=(0, 0), translate=(im.size[0]/2, 0)) + + if __name__ == '__main__':