From 40e5265c3b223a8173b362c1ae7c1966c3ce3f35 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Tue, 26 Aug 2014 20:15:03 -0700 Subject: [PATCH] Debugging on tests --- PIL/TiffImagePlugin.py | 9 +++++++++ Tests/test_file_libtiff.py | 4 +++- Tests/test_imagesequence.py | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index 78ba7861d..abf9db7e3 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -448,7 +448,11 @@ class ImageFileDirectory(collections.MutableMapping): # Get and expand tag value if size > 4: here = fp.tell() + if Image.DEBUG: + print ("Tag Location: %s" %here) fp.seek(i32(ifd, 8)) + if Image.DEBUG: + print ("Data Location: %s" %fp.tell()) data = ImageFile._safe_read(fp, size) fp.seek(here) else: @@ -654,7 +658,12 @@ class TiffImageFile(ImageFile.ImageFile): while self.__frame < frame: if not self.__next: raise EOFError("no more images in TIFF file") + if Image.DEBUG: + print("Seeking to frame %s, on frame %s, __next %s, location: %s"% + (frame, self.__frame, self.__next, self.fp.tell())) self.fp.seek(self.__next) + if Image.DEBUG: + print("Loading tags, location: %s"%self.fp.tell()) self.tag.load(self.fp) self.__next = self.tag.next self.__frame += 1 diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index c784ac55d..a6b22d810 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -314,6 +314,7 @@ class TestFileLibTiff(PillowTestCase): def test_multipage(self): # issue #862 TiffImagePlugin.READ_LIBTIFF = True + Image.DEBUG=True im = Image.open('Tests/images/multipage.tiff') # file is a multipage tiff, 10x10 green, 10x10 red, 20x20 blue @@ -331,7 +332,8 @@ class TestFileLibTiff(PillowTestCase): self.assertFalse(im.tag.next) self.assertEqual(im.size, (20,20)) self.assertEqual(im.convert('RGB').getpixel((0,0)), (0,0,255)) - + Image.DEBUG=False + TiffImagePlugin.READ_LIBTIFF = False def test__next(self): diff --git a/Tests/test_imagesequence.py b/Tests/test_imagesequence.py index 2470bc732..4a8c4133b 100644 --- a/Tests/test_imagesequence.py +++ b/Tests/test_imagesequence.py @@ -23,11 +23,13 @@ class TestImageSequence(PillowTestCase): self.assertEqual(index, 1) def _test_multipage_tiff(self): + Image.DEBUG=True im = Image.open('Tests/images/multipage.tiff') for index, frame in enumerate(ImageSequence.Iterator(im)): frame.load() self.assertEqual(index, im.tell()) frame.convert('RGB') + Image.DEBUG=False def test_tiff(self): return self._test_multipage_tiff()