-
Notifications
You must be signed in to change notification settings - Fork 2
/
iso14496_tests.py
53 lines (45 loc) · 1.41 KB
/
iso14496_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
''' Unit tests for cs.iso14496.
'''
from __future__ import print_function
import sys
import os
import os.path
import unittest
from cs.logutils import setup_logging
from .binary_tests import BaseTestBinaryClasses
from .iso14496 import parse
from . import iso14496 as iso14496_module
TESTFILE = 'TEST.mp4'
class Test_iso14496(unittest.TestCase):
''' Test `cs.iso14496`.
'''
@unittest.skipUnless(os.path.exists(TESTFILE), 'no ' + TESTFILE)
def test(self):
''' Basic scan of the test MP4 file.
'''
S = os.stat(TESTFILE)
mp4_size = S.st_size
with open(TESTFILE, 'rb') as mp4fp:
over_box = parse(mp4fp)
self.assertEqual(over_box.end_offset - over_box.offset, mp4fp.tell())
self.assertEqual(over_box.offset, 0)
self.assertEqual(
over_box.end_offset, mp4_size,
"over_box.end_offset=%d, mp4fp.tell=%d" %
(over_box.end_offset, mp4_size)
)
class TestISO14496BinaryClasses(BaseTestBinaryClasses, unittest.TestCase):
''' Test the `PacketField`s in `cs.iso14496`.
Subclasses `cs.binary_tests.BaseTestBinaryClasses`
which locates all `PacketFields` in the associated module.
'''
test_module = iso14496_module
def selftest(argv, **kw):
''' Run the unit tests.
'''
setup_logging(__file__)
sys.argv = argv
unittest.main(__name__, defaultTest=None, argv=argv, failfast=True, **kw)
if __name__ == '__main__':
selftest(sys.argv)