Added warning test for image with last truncated tile, #77

This commit is contained in:
John Evans 2013-07-23 06:36:36 -04:00
commit 83b53c5f9b

View file

@ -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()