Merge pull request #810 from hugovk/verbose_failfast

Tests: Be verbose and fail fast
This commit is contained in:
wiredfool 2014-07-19 21:44:59 -07:00
commit d810e9a018
14 changed files with 55 additions and 106 deletions

View File

@ -33,11 +33,11 @@ script:
# Don't cover PyPy: it fails intermittently and is x5.8 slower (#640) # Don't cover PyPy: it fails intermittently and is x5.8 slower (#640)
- if [ "$TRAVIS_PYTHON_VERSION" == "pypy" ]; then time python selftest.py; fi - if [ "$TRAVIS_PYTHON_VERSION" == "pypy" ]; then time python selftest.py; fi
- if [ "$TRAVIS_PYTHON_VERSION" == "pypy" ]; then time nosetests Tests/test_*.py; fi - if [ "$TRAVIS_PYTHON_VERSION" == "pypy" ]; then time nosetests -vx Tests/test_*.py; fi
# Cover the others # Cover the others
- if [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then time coverage run --append --include=PIL/* selftest.py; fi - if [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then time coverage run --append --include=PIL/* selftest.py; fi
- if [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then time coverage run --append --include=PIL/* -m nose Tests/test_*.py; fi - if [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then time coverage run --append --include=PIL/* -m nose -vx Tests/test_*.py; fi
after_success: after_success:
- coverage report - coverage report

View File

@ -19,6 +19,10 @@ class PillowTestCase(unittest.TestCase):
# holds last result object passed to run method: # holds last result object passed to run method:
self.currentResult = None self.currentResult = None
# Nicer output for --verbose
def __str__(self):
return self.__class__.__name__ + "." + self._testMethodName
def run(self, result=None): def run(self, result=None):
self.currentResult = result # remember result for use later self.currentResult = result # remember result for use later
unittest.TestCase.run(self, result) # call superclass run method unittest.TestCase.run(self, result) # call superclass run method

View File

@ -5,7 +5,7 @@ from PIL import Image
im = lena().resize((128, 100)) im = lena().resize((128, 100))
class TestImageCrop(PillowTestCase): class TestImageArray(PillowTestCase):
def test_toarray(self): def test_toarray(self):
def test(mode): def test(mode):

View File

@ -29,6 +29,10 @@ class TestImageFilter(PillowTestCase):
filter(ImageFilter.MinFilter) filter(ImageFilter.MinFilter)
filter(ImageFilter.ModeFilter) filter(ImageFilter.ModeFilter)
filter(ImageFilter.Kernel((3, 3), list(range(9)))) filter(ImageFilter.Kernel((3, 3), list(range(9))))
filter(ImageFilter.GaussianBlur)
filter(ImageFilter.GaussianBlur(5))
filter(ImageFilter.UnsharpMask)
filter(ImageFilter.UnsharpMask(10))
self.assertRaises(TypeError, lambda: filter("hello")) self.assertRaises(TypeError, lambda: filter("hello"))

View File

@ -10,6 +10,27 @@ class TestImageMode(PillowTestCase):
im = lena() im = lena()
im.mode im.mode
from PIL import ImageMode
ImageMode.getmode("1")
ImageMode.getmode("L")
ImageMode.getmode("P")
ImageMode.getmode("RGB")
ImageMode.getmode("I")
ImageMode.getmode("F")
m = ImageMode.getmode("1")
self.assertEqual(m.mode, "1")
self.assertEqual(m.bands, ("1",))
self.assertEqual(m.basemode, "L")
self.assertEqual(m.basetype, "L")
m = ImageMode.getmode("RGB")
self.assertEqual(m.mode, "RGB")
self.assertEqual(m.bands, ("R", "G", "B"))
self.assertEqual(m.basemode, "RGB")
self.assertEqual(m.basetype, "L")
def test_properties(self): def test_properties(self):
def check(mode, *result): def check(mode, *result):
signature = ( signature = (

View File

@ -1,7 +1,7 @@
from helper import unittest, lena from helper import unittest, PillowTestCase, lena
class TestImageToBytes(unittest.TestCase): class TestImageToBytes(PillowTestCase):
def test_sanity(self): def test_sanity(self):
data = lena().tobytes() data = lena().tobytes()

View File

@ -5,6 +5,22 @@ from PIL import Image
class TestImageTransform(PillowTestCase): class TestImageTransform(PillowTestCase):
def test_sanity(self):
from PIL import ImageTransform
im = Image.new("L", (100, 100))
seq = tuple(range(10))
transform = ImageTransform.AffineTransform(seq[:6])
im.transform((100, 100), transform)
transform = ImageTransform.ExtentTransform(seq[:4])
im.transform((100, 100), transform)
transform = ImageTransform.QuadTransform(seq[:8])
im.transform((100, 100), transform)
transform = ImageTransform.MeshTransform([(seq[:4], seq[:8])])
im.transform((100, 100), transform)
def test_extent(self): def test_extent(self):
im = lena('RGB') im = lena('RGB')
(w, h) = im.size (w, h) = im.size

View File

@ -14,7 +14,7 @@ MAXBLOCK = ImageFile.MAXBLOCK
SAFEBLOCK = ImageFile.SAFEBLOCK SAFEBLOCK = ImageFile.SAFEBLOCK
class TestImagePutData(PillowTestCase): class TestImageFile(PillowTestCase):
def test_parser(self): def test_parser(self):

View File

@ -1,37 +0,0 @@
from helper import unittest, PillowTestCase
from PIL import ImageFilter
class TestImageFilter(PillowTestCase):
def test_sanity(self):
# see test_image_filter for more tests
# Check these run. Exceptions cause failures.
ImageFilter.MaxFilter
ImageFilter.MedianFilter
ImageFilter.MinFilter
ImageFilter.ModeFilter
ImageFilter.Kernel((3, 3), list(range(9)))
ImageFilter.GaussianBlur
ImageFilter.GaussianBlur(5)
ImageFilter.UnsharpMask
ImageFilter.UnsharpMask(10)
ImageFilter.BLUR
ImageFilter.CONTOUR
ImageFilter.DETAIL
ImageFilter.EDGE_ENHANCE
ImageFilter.EDGE_ENHANCE_MORE
ImageFilter.EMBOSS
ImageFilter.FIND_EDGES
ImageFilter.SMOOTH
ImageFilter.SMOOTH_MORE
ImageFilter.SHARPEN
if __name__ == '__main__':
unittest.main()
# End of file

View File

@ -3,7 +3,7 @@ from helper import unittest, PillowTestCase
try: try:
from PIL import ImageGrab from PIL import ImageGrab
class TestImageCopy(PillowTestCase): class TestImageGrab(PillowTestCase):
def test_grab(self): def test_grab(self):
im = ImageGrab.grab() im = ImageGrab.grab()
@ -14,7 +14,7 @@ try:
self.assert_image(im, im.mode, im.size) self.assert_image(im, im.mode, im.size)
except ImportError: except ImportError:
class TestImageCopy(PillowTestCase): class TestImageGrab(PillowTestCase):
def test_skip(self): def test_skip(self):
self.skipTest("ImportError") self.skipTest("ImportError")

View File

@ -1,32 +0,0 @@
from helper import unittest, PillowTestCase
from PIL import ImageMode
class TestImageMode(PillowTestCase):
def test_sanity(self):
ImageMode.getmode("1")
ImageMode.getmode("L")
ImageMode.getmode("P")
ImageMode.getmode("RGB")
ImageMode.getmode("I")
ImageMode.getmode("F")
m = ImageMode.getmode("1")
self.assertEqual(m.mode, "1")
self.assertEqual(m.bands, ("1",))
self.assertEqual(m.basemode, "L")
self.assertEqual(m.basetype, "L")
m = ImageMode.getmode("RGB")
self.assertEqual(m.mode, "RGB")
self.assertEqual(m.bands, ("R", "G", "B"))
self.assertEqual(m.basemode, "RGB")
self.assertEqual(m.basetype, "L")
if __name__ == '__main__':
unittest.main()
# End of file

View File

@ -1,27 +0,0 @@
from helper import unittest, PillowTestCase
from PIL import Image
from PIL import ImageTransform
class TestImageTransform(PillowTestCase):
def test_sanity(self):
im = Image.new("L", (100, 100))
seq = tuple(range(10))
transform = ImageTransform.AffineTransform(seq[:6])
im.transform((100, 100), transform)
transform = ImageTransform.ExtentTransform(seq[:4])
im.transform((100, 100), transform)
transform = ImageTransform.QuadTransform(seq[:8])
im.transform((100, 100), transform)
transform = ImageTransform.MeshTransform([(seq[:4], seq[:8])])
im.transform((100, 100), transform)
if __name__ == '__main__':
unittest.main()
# End of file

View File

@ -3,7 +3,7 @@ from helper import unittest, PillowTestCase
from PIL import Image from PIL import Image
class TestSanity(PillowTestCase): class TestLibImage(PillowTestCase):
def test_setmode(self): def test_setmode(self):

View File

@ -7,7 +7,7 @@ except ImportError:
pass pass
class TestPyroma(unittest.TestCase): class TestPyroma(PillowTestCase):
def setUp(self): def setUp(self):
try: try: