Skip to content

Commit

Permalink
ListContainer must be used if the list is a list of containers
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaphoenix committed Apr 17, 2023
1 parent 59119e3 commit 7119b9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions tests/test_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import logging
import unittest

from construct import Container
from construct import Container, ListContainer
from pymp4.parser import Box

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -89,13 +89,13 @@ def test_mdhd_build(self):

def test_moov_build(self):
moov = \
Container(type="moov", children=[ # 96 bytes
Container(type="mvex", children=[ # 88 bytes
Container(type="moov", children=ListContainer([ # 96 bytes
Container(type="mvex", children=ListContainer([ # 88 bytes
Container(type="mehd", version=0, flags=0, fragment_duration=0), # 16 bytes
Container(type="trex", track_ID=1), # 32 bytes
Container(type="trex", track_ID=2), # 32 bytes
])
])
]))
]))

moov_data = Box.build(moov)

Expand Down Expand Up @@ -141,9 +141,9 @@ def test_stsd_parse(self):
type="stsd",
version=0,
flags=0,
entries=[
entries=ListContainer([
Container(format='tx3g', data_reference_index=1, data=tx3g_data)
],
]),
end=len(in_bytes)
)
)
18 changes: 9 additions & 9 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import logging
import unittest

from construct import Container
from construct import Container, ListContainer

from pymp4.exceptions import BoxNotFound
from pymp4.util import BoxUtil
Expand All @@ -28,23 +28,23 @@
class BoxTests(unittest.TestCase):
box_data = Container(
type="demo",
children=[
children=ListContainer([
Container(type="a ", id=1),
Container(type="b ", id=2),
Container(
type="c ",
children=[
children=ListContainer([
Container(type="a ", id=3),
Container(type="b ", id=4)
]
])
),
Container(type="d ", id=5)
]
])
)

box_extended_data = Container(
type="test",
children=[
children=ListContainer([
Container(
type="a ",
id=1,
Expand All @@ -55,7 +55,7 @@ class BoxTests(unittest.TestCase):
id=2,
extended_type=b"e--b"
)
]
])
)

def test_find(self):
Expand All @@ -73,10 +73,10 @@ def test_find_after_nest(self):
def test_find_nested_type(self):
self.assertListEqual(
list(BoxUtil.find(self.box_data, "c ")),
[Container(type="c ", children=[
[Container(type="c ", children=ListContainer([
Container(type="a ", id=3),
Container(type="b ", id=4),
])]
]))]
)

def test_find_empty(self):
Expand Down

0 comments on commit 7119b9d

Please sign in to comment.