diff --git a/glymur/jp2box.py b/glymur/jp2box.py index 6dbec1d..122d5c4 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -2230,7 +2230,7 @@ class UUIDBox(Jp2kBox): def __repr__(self): msg = "glymur.jp2box.UUIDBox(the_uuid={0}, " msg += "raw_data=)" - return msg.format(repr(self.uuid), len(self.data)) + return msg.format(repr(self.uuid), len(self.raw_data)) def __str__(self): msg = '{0}\n UUID: {1}'.format(Jp2kBox.__str__(self), self.uuid) diff --git a/glymur/test/test_jp2box.py b/glymur/test/test_jp2box.py index f731ff7..a40a5c6 100644 --- a/glymur/test/test_jp2box.py +++ b/glymur/test/test_jp2box.py @@ -919,7 +919,7 @@ class TestRepr(unittest.TestCase): self.assertEqual(box.vendor_mask, newbox.vendor_mask) @unittest.skipIf(sys.hexversion < 0x02070000, "Requires 2.7+") - def test_uuid_box(self): + def test_uuid_box_generic(self): """Verify uuid repr method.""" uuid_instance = uuid.UUID('00000000-0000-0000-0000-000000000000') data = b'0123456789' @@ -936,6 +936,24 @@ 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() + j = Jp2k(jp2file) + box = j.box[3] + + # Since the raw_data parameter is a sequence of bytes which could be + # quite long, don't bother trying to make it conform to eval(repr()). + regexp = r"""glymur.jp2box.UUIDBox\(""" + regexp += """the_uuid=UUID\('be7acfcb-97a9-42e8-9c71-999491e3afac'\),\s""" + regexp += """raw_data=\)""" + + if sys.hexversion < 0x03000000: + self.assertRegexpMatches(repr(box), regexp) + else: + self.assertRegex(repr(box), regexp) + @unittest.skipIf(sys.hexversion < 0x02070000, "Requires 2.7+") def test_contiguous_codestream_box(self): """Verify contiguous codestream box repr method."""