From 83b53c5f9be71139ad2320edab53ee26d8110639 Mon Sep 17 00:00:00 2001 From: John Evans Date: Tue, 23 Jul 2013 06:36:36 -0400 Subject: [PATCH] Added warning test for image with last truncated tile, #77 --- glymur/test/test_format_corpus.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/glymur/test/test_format_corpus.py b/glymur/test/test_format_corpus.py index 14c0830..28e1d4d 100644 --- a/glymur/test/test_format_corpus.py +++ b/glymur/test/test_format_corpus.py @@ -66,5 +66,20 @@ class TestSuite(unittest.TestCase): with self.assertRaises(OSError): j2k.read(rlevel=-1) + def test_balloon_trunc3(self): + # Most of last tile is missing. + jfile = os.path.join(data_root, + 'jp2k-test/byteCorruption/balloon_trunc3.jp2') + j2k = Jp2k(jfile) + with self.assertWarns(UserWarning): + c = j2k.get_codestream(header_only=False) + + # The last segment is truncated, so there should not be an EOC marker. + self.assertNotEqual(c.segment[-1].marker_id, 'EOC') + + # Should error out, it does not. + #with self.assertRaises(OSError): + # j2k.read(rlevel=-1) + if __name__ == "__main__": unittest.main()