From 1141e636d9af3b2310fb9d70f872dac53cd0a957 Mon Sep 17 00:00:00 2001 From: hugovk Date: Thu, 10 Jul 2014 02:00:26 +0300 Subject: [PATCH] More tests for Image.py --- Tests/test_image.py | 49 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/Tests/test_image.py b/Tests/test_image.py index 174964ce7..c1c2c3d86 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -1,4 +1,4 @@ -from helper import unittest, PillowTestCase +from helper import unittest, PillowTestCase, lena from PIL import Image @@ -55,6 +55,53 @@ class TestImage(PillowTestCase): self.assertFalse(item == None) self.assertFalse(item == num) + def test_expand_x(self): + # Arrange + im = lena() + orig_size = im.size + xmargin = 5 + + # Act + im = im._expand(xmargin) + + # Assert + self.assertEqual(im.size[0], orig_size[0] + 2*xmargin) + self.assertEqual(im.size[1], orig_size[1] + 2*xmargin) + + def test_expand_xy(self): + # Arrange + im = lena() + orig_size = im.size + xmargin = 5 + ymargin = 3 + + # Act + im = im._expand(xmargin, ymargin) + + # Assert + self.assertEqual(im.size[0], orig_size[0] + 2*xmargin) + self.assertEqual(im.size[1], orig_size[1] + 2*ymargin) + + def test_getbands(self): + # Arrange + im = lena() + + # Act + bands = im.getbands() + + # Assert + self.assertEqual(bands, ('R', 'G', 'B')) + + def test_getbbox(self): + # Arrange + im = lena() + + # Act + bbox = im.getbbox() + + # Assert + self.assertEqual(bbox, (0, 0, 128, 128)) + if __name__ == '__main__': unittest.main()