From 94239540db0921c46257a17e65433555eb509551 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Mon, 13 May 2013 22:21:52 -0700 Subject: [PATCH] fixing deferring the rgba tests, whitespace --- Tests/test_file_webp.py | 41 ++++++++++++++++++++++------------------- _webp.c | 4 ++-- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Tests/test_file_webp.py b/Tests/test_file_webp.py index d81abb85c..30fd94d58 100644 --- a/Tests/test_file_webp.py +++ b/Tests/test_file_webp.py @@ -9,11 +9,11 @@ except: def test_version(): - assert_no_exception(lambda: _webp.WebPDecoderVersion()) + assert_no_exception(lambda: _webp.WebPDecoderVersion()) def test_good_alpha(): - assert_equal(_webp.WebPDecoderBuggyAlpha(), 0) - + assert_equal(_webp.WebPDecoderBuggyAlpha(), 0) + def test_read_rgb(): @@ -77,7 +77,10 @@ def test_write_rgba(): pil_image = Image.new("RGBA", (10, 10), (255, 0, 0, 20)) pil_image.save(temp_file) - + + if _webp.WebPDecoderBuggyAlpha(): + return + image = Image.open(temp_file) image.load() @@ -90,21 +93,21 @@ def test_write_rgba(): assert_image_similar(image, pil_image, 1.0) if _webp.WebPDecoderBuggyAlpha(): - skip("Buggy early version of webp installed, not testing transparency") + skip("Buggy early version of webp installed, not testing transparency") def test_read_rgba(): - # Generated with `cwebp transparent.png -o transparent.webp` - file_path = "Images/transparent.webp" - image = Image.open(file_path) - - assert_equal(image.mode, "RGBA") - assert_equal(image.size, (200, 150)) - assert_equal(image.format, "WEBP") - assert_no_exception(lambda: image.load()) - assert_no_exception(lambda: image.getdata()) - - orig_bytes = image.tobytes() - - target = Image.open('Images/transparent.png') - assert_image_similar(image, target, 20.0) + # Generated with `cwebp transparent.png -o transparent.webp` + file_path = "Images/transparent.webp" + image = Image.open(file_path) + + assert_equal(image.mode, "RGBA") + assert_equal(image.size, (200, 150)) + assert_equal(image.format, "WEBP") + assert_no_exception(lambda: image.load()) + assert_no_exception(lambda: image.getdata()) + + orig_bytes = image.tobytes() + + target = Image.open('Images/transparent.png') + assert_image_similar(image, target, 20.0) diff --git a/_webp.c b/_webp.c index 34da4d5ee..ec46fe317 100644 --- a/_webp.c +++ b/_webp.c @@ -162,11 +162,11 @@ PyObject* WebPDecoderVersion_wrapper(PyObject* self, PyObject* args){ } /* - * The version of webp that ships with (0.1.2) Ubuntu 12.04 doesn't handle alpha well. + * The version of webp that ships with (0.1.3) Ubuntu 12.04 doesn't handle alpha well. * Files that are valid with 0.3 are reported as being invalid. */ PyObject* WebPDecoderBuggyAlpha_wrapper(PyObject* self, PyObject* args){ - return Py_BuildValue("i", WebPGetDecoderVersion()==0x0102); + return Py_BuildValue("i", WebPGetDecoderVersion()==0x0103); } static PyMethodDef webpMethods[] =