Permalink
Browse files
tests: Avoid spurious failures with Pillow 3.4.0 - 3.4.2
- Loading branch information...
Showing
with
15 additions
and
2 deletions.
-
+10
−0
tests/__init__.py
-
+2
−1
tests/test_imageslide.py
-
+3
−1
tests/test_openslide.py
|
|
@@ -19,6 +19,7 @@ |
|
|
|
|
|
from functools import wraps
|
|
|
import os
|
|
|
+from PIL import Image
|
|
|
import unittest
|
|
|
|
|
|
try:
|
|
|
@@ -28,6 +29,15 @@ |
|
|
have_optimizations = False
|
|
|
|
|
|
|
|
|
+# PIL.Image cannot have zero width or height on Pillow 3.4.0 - 3.4.2
|
|
|
+# https://github.com/python-pillow/Pillow/issues/2259
|
|
|
+try:
|
|
|
+ Image.new('RGBA', (1, 0))
|
|
|
+ image_dimensions_cannot_be_zero = False
|
|
|
+except ValueError:
|
|
|
+ image_dimensions_cannot_be_zero = True
|
|
|
+
|
|
|
+
|
|
|
def file_path(name):
|
|
|
return os.path.join(os.path.dirname(__file__), name)
|
|
|
|
|
|
|
|
|
@@ -22,7 +22,7 @@ |
|
|
from PIL import Image
|
|
|
import unittest
|
|
|
|
|
|
-from . import file_path
|
|
|
+from . import file_path, image_dimensions_cannot_be_zero, skip_if
|
|
|
|
|
|
# Tests should be written to be compatible with Python 2.6 unittest.
|
|
|
|
|
|
@@ -104,6 +104,7 @@ def test_read_region(self): |
|
|
self.assertEqual(self.osr.read_region((-10, -10), 0, (400, 400)).size,
|
|
|
(400, 400))
|
|
|
|
|
|
+ @skip_if(image_dimensions_cannot_be_zero, 'Pillow issue #2259')
|
|
|
def test_read_region_size_dimension_zero(self):
|
|
|
self.assertEqual(self.osr.read_region((0, 0), 0, (400, 0)).size,
|
|
|
(400, 0))
|
|
|
|
|
|
@@ -25,7 +25,8 @@ |
|
|
import sys
|
|
|
import unittest
|
|
|
|
|
|
-from . import file_path, have_optimizations, skip_if
|
|
|
+from . import (file_path, have_optimizations, image_dimensions_cannot_be_zero,
|
|
|
+ skip_if)
|
|
|
|
|
|
# Tests should be written to be compatible with Python 2.6 unittest.
|
|
|
|
|
|
@@ -110,6 +111,7 @@ def test_read_region(self): |
|
|
self.assertEqual(self.osr.read_region((-10, -10), 1, (400, 400)).size,
|
|
|
(400, 400))
|
|
|
|
|
|
+ @skip_if(image_dimensions_cannot_be_zero, 'Pillow issue #2259')
|
|
|
def test_read_region_size_dimension_zero(self):
|
|
|
self.assertEqual(self.osr.read_region((0, 0), 1, (400, 0)).size,
|
|
|
(400, 0))
|
|
|
|
0 comments on commit
4ea9211