Added proper repr support for association box. #133

This commit is contained in:
John Evans 2013-10-24 09:29:45 -04:00
commit c8fe9ed776
2 changed files with 13 additions and 2 deletions

View file

@ -1061,11 +1061,15 @@ class AssociationBox(Jp2kBox):
box : list
List of boxes contained in this superbox.
"""
def __init__(self, length=0, offset=-1):
def __init__(self, box=[], length=0, offset=-1):
Jp2kBox.__init__(self, box_id='asoc', longname='Association')
self.length = length
self.offset = offset
self.box = []
self.box = box
def __repr__(self):
msg = "glymur.jp2box.AssociationBox(box={0})".format(self.box)
return msg
def __str__(self):
msg = Jp2kBox.__str__(self)

View file

@ -780,6 +780,13 @@ class TestRepr(unittest.TestCase):
self.assertFalse(newbox.colorspace_unknown)
self.assertFalse(newbox.ip_provided)
def test_association_box(self):
"""Verify __repr__ method on asoc box."""
asoc = glymur.jp2box.AssociationBox()
newbox = eval(repr(asoc))
self.assertEqual(newbox.box_id, 'asoc')
self.assertEqual(len(newbox.box), 0)
def test_codestreamheader_box(self):
"""Verify __repr__ method on jpch box."""
jpch = glymur.jp2box.CodestreamHeaderBox()