From aa247dbb60ffb0689c2500e24686636d073c2562 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Sat, 3 Dec 2016 13:37:31 +0000 Subject: [PATCH] Moving tests requiring libtiff to test_file_libtiff --- Tests/test_file_libtiff.py | 45 ++++++++++++++++++++++++++++++++++++++ Tests/test_file_tiff.py | 44 ------------------------------------- 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index 3a8c0b1c2..95a4d27c2 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -532,5 +532,50 @@ class TestFileLibTiff(LibTiffTestCase): TiffImagePlugin.READ_LIBTIFF = False self.assertEqual(icc, icc_libtiff) + def test_multipage_compression(self): + im = Image.open('Tests/images/compression.tif') + + im.seek(0) + self.assertEqual(im._compression, 'tiff_ccitt') + self.assertEqual(im.size, (10, 10)) + + im.seek(1) + self.assertEqual(im._compression, 'packbits') + self.assertEqual(im.size, (10, 10)) + im.load() + + im.seek(0) + self.assertEqual(im._compression, 'tiff_ccitt') + self.assertEqual(im.size, (10, 10)) + im.load() + + def test_save_tiff_with_jpegtables(self): + # Arrange + outfile = self.tempfile("temp.tif") + + # Created with ImageMagick: convert hopper.jpg hopper_jpg.tif + # Contains JPEGTables (347) tag + infile = "Tests/images/hopper_jpg.tif" + im = Image.open(infile) + + # Act / Assert + # Should not raise UnicodeDecodeError or anything else + im.save(outfile) + + 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() diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 76fe8f930..bf19947a1 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -382,20 +382,6 @@ class TestFileTiff(PillowTestCase): self.assertEqual(im2.mode, "L") self.assert_image_equal(im, im2) - 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) - def test_with_underscores(self): kwargs = {'resolution_unit': 'inch', 'x_resolution': 72, @@ -432,36 +418,6 @@ class TestFileTiff(PillowTestCase): self.assertEqual(im.tag_v2[X_RESOLUTION], 36) self.assertEqual(im.tag_v2[Y_RESOLUTION], 72) - def test_multipage_compression(self): - im = Image.open('Tests/images/compression.tif') - - im.seek(0) - self.assertEqual(im._compression, 'tiff_ccitt') - self.assertEqual(im.size, (10, 10)) - - im.seek(1) - self.assertEqual(im._compression, 'packbits') - self.assertEqual(im.size, (10, 10)) - im.load() - - im.seek(0) - self.assertEqual(im._compression, 'tiff_ccitt') - self.assertEqual(im.size, (10, 10)) - im.load() - - def test_save_tiff_with_jpegtables(self): - # Arrange - outfile = self.tempfile("temp.tif") - - # Created with ImageMagick: convert hopper.jpg hopper_jpg.tif - # Contains JPEGTables (347) tag - infile = "Tests/images/hopper_jpg.tif" - im = Image.open(infile) - - # Act / Assert - # Should not raise UnicodeDecodeError or anything else - im.save(outfile) - def test_lzw(self): # Act im = Image.open("Tests/images/hopper_lzw.tif")