diff --git a/glymur/_uuid_io.py b/glymur/_uuid_io.py index f64baa6..bf9960a 100644 --- a/glymur/_uuid_io.py +++ b/glymur/_uuid_io.py @@ -101,8 +101,12 @@ class _Ifd(object): def parse_tag(self, dtype, count, offset_buf): """Interpret an Exif image tag data payload. """ - fmt = self.datatype2fmt[dtype][0] * count - payload_size = self.datatype2fmt[dtype][1] * count + try: + fmt = self.datatype2fmt[dtype][0] * count + payload_size = self.datatype2fmt[dtype][1] * count + except KeyError: + msg = 'Invalid TIFF tag datatype ({0}).'.format(dtype) + raise IOError(msg) if payload_size <= 4: # Interpret the payload from the 4 bytes in the tag entry. diff --git a/glymur/test/test_jp2box.py b/glymur/test/test_jp2box.py index cef0d41..da5fea1 100644 --- a/glymur/test/test_jp2box.py +++ b/glymur/test/test_jp2box.py @@ -1332,7 +1332,6 @@ class TestRepr(unittest.TestCase): else: self.assertRegex(repr(box), regexp) - @unittest.skipIf(sys.hexversion < 0x02070000, "Requires 2.7+") def test_uuid_box_xmp(self): """Verify uuid repr method for XMP UUID box.""" jp2file = glymur.data.nemo() diff --git a/glymur/test/test_jp2box_uuid.py b/glymur/test/test_jp2box_uuid.py index f24aafe..e346ade 100644 --- a/glymur/test/test_jp2box_uuid.py +++ b/glymur/test/test_jp2box_uuid.py @@ -138,6 +138,8 @@ class TestUUIDExif(unittest.TestCase): warnings.simplefilter('always') j = glymur.Jp2k(tfile.name) self.assertTrue(issubclass(w[0].category, UserWarning)) + msg = 'Invalid TIFF tag' + self.assertTrue(msg in str(w[0].message)) self.assertEqual(j.box[-1].box_id, 'uuid') diff --git a/glymur/test/test_jp2box_xml.py b/glymur/test/test_jp2box_xml.py index 7841154..f8e2878 100644 --- a/glymur/test/test_jp2box_xml.py +++ b/glymur/test/test_jp2box_xml.py @@ -207,15 +207,14 @@ class TestJp2kBadXmlFile(unittest.TestCase): def tearDown(self): pass - def test_invalid_xml_box_warning(self): - """Should warn in case of bad XML""" - Jp2k(self._bad_xml_file) - def test_invalid_xml_box(self): """Should be able to recover info from xml box with bad xml.""" - with warnings.catch_warnings(): - warnings.simplefilter("ignore") + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") jp2k = Jp2k(self._bad_xml_file) + self.assertTrue(issubclass(w[0].category, UserWarning)) + msg = 'No XML was retrieved' + self.assertTrue(msg in str(w[0].message)) self.assertEqual(jp2k.box[3].box_id, 'xml ') self.assertEqual(jp2k.box[3].offset, 77) diff --git a/glymur/test/test_opj_suite_write.py b/glymur/test/test_opj_suite_write.py index 861b31b..77ef262 100644 --- a/glymur/test/test_opj_suite_write.py +++ b/glymur/test/test_opj_suite_write.py @@ -1020,7 +1020,6 @@ class TestSuiteWrite(unittest.TestCase): glymur.core.WAVELET_XFORM_5X3_REVERSIBLE) self.assertEqual(len(codestream.segment[2].spcod), 9) - #@unittest.skip("Known failure in openjpeg test suite.") def test_NR_ENC_random_issue_0005_tif_12_encode(self): """NR-ENC-random-issue-0005.tif-12-encode""" # opj_decompress has trouble reading it, but that is not an issue here. diff --git a/glymur/test/test_printing.py b/glymur/test/test_printing.py index 6734d01..efd1ccf 100644 --- a/glymur/test/test_printing.py +++ b/glymur/test/test_printing.py @@ -725,6 +725,8 @@ class TestPrintingOpjDataRoot(unittest.TestCase): # Reset printoptions for every test. glymur.set_printoptions(short=False, xml=True, codestream=True) + warnings.resetwarnings() + def tearDown(self): pass