Skip tests that require libtiff if it is not installed, fixes #1866

This commit is contained in:
wiredfool 2016-05-06 09:07:00 -07:00
parent 8a061218ee
commit be2100be7b
2 changed files with 20 additions and 1 deletions

View File

@ -489,6 +489,21 @@ class TestFileLibTiff(LibTiffTestCase):
im.save(out, format='TIFF')
TiffImagePlugin.WRITE_LIBTIFF = False
def test_page_number_x_0(self):
# Issue 973
# Test TIFF with tag 297 (Page Number) having value of 0 0.
# The first number is the current page number.
# The second is the total number of pages, zero means not available.
outfile = self.tempfile("temp.tif")
# Created by printing a page in Chrome to PDF, then:
# /usr/bin/gs -q -sDEVICE=tiffg3 -sOutputFile=total-pages-zero.tif
# -dNOPAUSE /tmp/test.pdf -c quit
infile = "Tests/images/total-pages-zero.tif"
im = Image.open(infile)
# Should not divide by zero
im.save(outfile)
if __name__ == '__main__':
unittest.main()

View File

@ -45,7 +45,11 @@ class Test_IFDRational(PillowTestCase):
self.assertTrue(xres and yres)
def test_ifd_rational_save(self):
for libtiff in (True, False):
methods = (True, False)
if 'libtiff_encoder' not in dir(Image.core):
methods = (False)
for libtiff in methods:
TiffImagePlugin.WRITE_LIBTIFF = libtiff
im = hopper()