From 134295bfd40c33c16f06fb06d6bd91f8b25e963f Mon Sep 17 00:00:00 2001 From: hugovk Date: Thu, 8 May 2014 11:43:04 +0300 Subject: [PATCH] Resize tests for https://github.com/python-imaging/Pillow/pull/619 (plus flake8) --- Tests/test_file_eps.py | 48 ++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py index 0041824b1..9b524e70d 100644 --- a/Tests/test_file_eps.py +++ b/Tests/test_file_eps.py @@ -1,25 +1,25 @@ from tester import * from PIL import Image, EpsImagePlugin -import sys import io if not EpsImagePlugin.has_ghostscript(): skip() -#Our two EPS test files (they are identical except for their bounding boxes) +# Our two EPS test files (they are identical except for their bounding boxes) file1 = "Tests/images/zero_bb.eps" file2 = "Tests/images/non_zero_bb.eps" -#Due to palletization, we'll need to convert these to RGB after load +# Due to palletization, we'll need to convert these to RGB after load file1_compare = "Tests/images/zero_bb.png" file1_compare_scale2 = "Tests/images/zero_bb_scale2.png" file2_compare = "Tests/images/non_zero_bb.png" file2_compare_scale2 = "Tests/images/non_zero_bb_scale2.png" + def test_sanity(): - #Regular scale + # Regular scale image1 = Image.open(file1) image1.load() assert_equal(image1.mode, "RGB") @@ -32,7 +32,7 @@ def test_sanity(): assert_equal(image2.size, (360, 252)) assert_equal(image2.format, "EPS") - #Double scale + # Double scale image1_scale2 = Image.open(file1) image1_scale2.load(scale=2) assert_equal(image1_scale2.mode, "RGB") @@ -45,54 +45,76 @@ def test_sanity(): assert_equal(image2_scale2.size, (720, 504)) assert_equal(image2_scale2.format, "EPS") + def test_file_object(): - #issue 479 + # issue 479 image1 = Image.open(file1) with open(tempfile('temp_file.eps'), 'wb') as fh: image1.save(fh, 'EPS') + def test_iobase_object(): - #issue 479 + # issue 479 image1 = Image.open(file1) with io.open(tempfile('temp_iobase.eps'), 'wb') as fh: image1.save(fh, 'EPS') + def test_render_scale1(): - #We need png support for these render test + # We need png support for these render test codecs = dir(Image.core) if "zip_encoder" not in codecs or "zip_decoder" not in codecs: skip("zip/deflate support not available") - #Zero bounding box + # Zero bounding box image1_scale1 = Image.open(file1) image1_scale1.load() image1_scale1_compare = Image.open(file1_compare).convert("RGB") image1_scale1_compare.load() assert_image_similar(image1_scale1, image1_scale1_compare, 5) - #Non-Zero bounding box + # Non-Zero bounding box image2_scale1 = Image.open(file2) image2_scale1.load() image2_scale1_compare = Image.open(file2_compare).convert("RGB") image2_scale1_compare.load() assert_image_similar(image2_scale1, image2_scale1_compare, 10) + def test_render_scale2(): - #We need png support for these render test + # We need png support for these render test codecs = dir(Image.core) if "zip_encoder" not in codecs or "zip_decoder" not in codecs: skip("zip/deflate support not available") - #Zero bounding box + # Zero bounding box image1_scale2 = Image.open(file1) image1_scale2.load(scale=2) image1_scale2_compare = Image.open(file1_compare_scale2).convert("RGB") image1_scale2_compare.load() assert_image_similar(image1_scale2, image1_scale2_compare, 5) - #Non-Zero bounding box + # Non-Zero bounding box image2_scale2 = Image.open(file2) image2_scale2.load(scale=2) image2_scale2_compare = Image.open(file2_compare_scale2).convert("RGB") image2_scale2_compare.load() assert_image_similar(image2_scale2, image2_scale2_compare, 10) + + +def test_resize(): + # Arrange + image1 = Image.open(file1) + image2 = Image.open(file2) + new_size = (100, 100) + + # Act + image1 = image1.resize(new_size) + image2 = image1.resize(new_size) + + # Assert + assert_equal(image1.size, new_size) + assert_equal(image2.size, new_size) + + +# End of file