Fixed warnings. #229

This commit is contained in:
jevans 2014-05-10 18:35:19 -04:00
commit 61192b73d3
6 changed files with 15 additions and 10 deletions

View file

@ -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.

View file

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

View file

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

View file

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

View file

@ -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.

View file

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