Ejemplo n.º 1
0
def test_me():
    """Runs unit tests for the associated module"""
    try:
        import test_all #@UnresolvedImport
    except ImportError:
        import tests.test_all as test_all
    test_all.run_tests([Test_ID3v2Common])
Ejemplo n.º 2
0
def test_ELF_tiny45(assertion):
    global log_history
    elf_tiny = open(__dir__+'/binary_input/tiny45.bin', 'rb').read()
    assertion('44023f74799f2e009a1400c74de50cdd',
              hashlib.md5(elf_tiny).hexdigest(),
              'Reading tiny45')
    e = ELF(elf_tiny)
    assertion([('error', ('Invalid ELF, endianess defined to %d', 0), {}),
               ('error', ('Offset to section headers after end of file',), {}),
               ('error', ('Ehdr version is 65568 instead of 1',), {})],
              log_history,
              'tiny45 (logs)')
    log_history = []
    d = e.pack()
    # packing tiny45 generates tiny52 :-)
    assertion('18ddd4966cb003b80862735d19ddbeb7',
              hashlib.md5(d).hexdigest(),
              'Packing after reading tiny45')
    assertion([],
              log_history,
              'No non-regression test created unwanted log messages')

def run_test(assertion):
    for name, value in dict(globals()).items():
        if name.startswith('test_'):
            value(assertion)

if __name__ == "__main__":
    run_tests(run_test)
Ejemplo n.º 3
0
def test_me():
    """Runs unit tests for the associated module"""
    import test_all #@UnresolvedImport
    test_all.run_tests([Test_ID3v2x])
Ejemplo n.º 4
0
def test_me():
    """Runs unit tests for the associated module"""
    import test_all #@UnresolvedImport
    test_all.run_tests([Test_ID3])
Ejemplo n.º 5
0
# pylint: disable=import-error, invalid-name
# pylint: disable=too-many-public-methods
# Pylint options disabled due to poor Python 3 support.
'''Test Module for mp3protocol module'''

import unittest


class Test_MP3Header(unittest.TestCase):
    """Unit test class for MP3Header"""
    def setUp(self):
        pass

    def test_short_todo(self):
        """Test Method?"""
        #TODO: find some tests to do here? MP3Header
        pass


if __name__ == '__main__':
    import test_all  #@UnresolvedImport
    test_all.run_tests([Test_MP3Header])
Ejemplo n.º 6
0
    def identify_frame_after_false_seek(self):
        """Implimentation of above"""
        config.OPTS.consecutive_frames_to_id = 3
        temp = SampleMP3File()
        temp.add_char(255)
        temp.add_valid_frames(5)
        junkstart = temp.get_size()
        temp.add_char(255)
        temp.add_char(255)
        framestart = temp.get_size()
        temp.add_valid_frames(5)
        mfile = mp3file.MP3File(temp.get_file())
        mfile.scan_file()
        self.assertEqual(1, mfile.frames[0][1], "Didn't skip false seek byte")
        self.assertEqual(0, mfile.other[0].position,
                         "junk #1 found in wrong location")
        self.assertEqual(junkstart, mfile.other[1].position,
                         "junk #2 found in wrong location")
        self.assertEqual(2, len(mfile.other[1]), "junk was wrong length")
        self.assertEqual(framestart, mfile.frames[5][1],
                         "Didn't skip 2 byte false seek tag")

    def tearDown(self):
        """restore opts"""
        config.OPTS = self.savedopts


if __name__ == '__main__':
    import test_all  #@UnresolvedImport
    test_all.run_tests([Test_MP3File])
Ejemplo n.º 7
0
# pylint: disable=import-error, invalid-name
# pylint: disable=too-many-public-methods
# Pylint options disabled due to poor Python 3 support.
"""Test Module for mp3protocol module"""

import unittest


class Test_MP3Header(unittest.TestCase):
    """Unit test class for MP3Header"""

    def setUp(self):
        pass

    def test_short_todo(self):
        """Test Method?"""
        # TODO: find some tests to do here? MP3Header
        pass


if __name__ == "__main__":
    import test_all  # @UnresolvedImport

    test_all.run_tests([Test_MP3Header])
Ejemplo n.º 8
0
# pylint: disable=import-error
# pylint: disable=too-many-public-methods, invalid-name
"""Test Module for mp3frame module"""

import unittest

class Test_MP3FrameList(unittest.TestCase):
    """Test suite for the MP3Frame module"""

    def setUp(self):
        pass

    def test_short_init(self):
        """Test method???"""
        #TODO: find some testing to do here (MP3FrameList)?
        self.assertTrue(True)

if __name__ == '__main__':
    import test_all #@UnresolvedImport
    test_all.run_tests([Test_MP3FrameList])
    
Ejemplo n.º 9
0
        self.identify_frame_after_false_seek()

    def identify_frame_after_false_seek(self):
        """Implimentation of above"""
        config.OPTS.consecutive_frames_to_id = 3
        temp = SampleMP3File()
        temp.add_char(255)
        temp.add_valid_frames(5)
        junkstart = temp.get_size()
        temp.add_char(255)
        temp.add_char(255)
        framestart = temp.get_size()
        temp.add_valid_frames(5)
        mfile = mp3file.MP3File(temp.get_file())
        mfile.scan_file()
        self.assertEqual(1, mfile.frames[0][1], "Didn't skip false seek byte")
        self.assertEqual(0, mfile.other[0].position, "junk #1 found in wrong location")
        self.assertEqual(junkstart, mfile.other[1].position, "junk #2 found in wrong location")
        self.assertEqual(2, len(mfile.other[1]), "junk was wrong length")
        self.assertEqual(framestart, mfile.frames[5][1], "Didn't skip 2 byte false seek tag")

    def tearDown(self):
        """restore opts"""
        config.OPTS = self.savedopts


if __name__ == "__main__":
    import test_all  # @UnresolvedImport

    test_all.run_tests([Test_MP3File])
Ejemplo n.º 10
0
# pylint: disable=no-member, too-many-public-methods
'''Test Module for pythonrecordarray module'''

import unittest
import pythonrecordarray

class Test_PythonRecordArray(unittest.TestCase):
    """Test class for PythonRecordArray"""

    def test_short_01_init_and_access(self):
        """Currently tests everything in this class."""
        typedef = [("recordone",'H'),
                   ("recordtwo",'L'),
                   ("recordthree",'L')]
        parray = pythonrecordarray.PythonRecordArray(10,typedef,0)
        self.assertEqual([0,0,0],parray[0])
        self.assertEqual(0, parray.recordone[0])
        parray[0] = (1,2,3)
        self.assertEqual([1,2,3],parray[0])
        self.assertEqual(2, parray.recordtwo[0])
        self.assertEqual(2, parray[0][1])
        parray.recordthree[0] = 9
        self.assertEqual(9, parray.recordthree[0])
        self.assertEqual(10, len(parray))
        with self.assertRaises(TypeError):
            pythonrecordarray.PythonRecordArray(10, [("recordone",None),])

if __name__ == '__main__':
    import test_all #@UnresolvedImport
    test_all.run_tests([Test_PythonRecordArray])
    
Ejemplo n.º 11
0
import unittest
import pythonrecordarray


class Test_PythonRecordArray(unittest.TestCase):
    """Test class for PythonRecordArray"""
    def test_short_01_init_and_access(self):
        """Currently tests everything in this class."""
        typedef = [("recordone", 'H'), ("recordtwo", 'L'),
                   ("recordthree", 'L')]
        parray = pythonrecordarray.PythonRecordArray(10, typedef, 0)
        self.assertEqual([0, 0, 0], parray[0])
        self.assertEqual(0, parray.recordone[0])
        parray[0] = (1, 2, 3)
        self.assertEqual([1, 2, 3], parray[0])
        self.assertEqual(2, parray.recordtwo[0])
        self.assertEqual(2, parray[0][1])
        parray.recordthree[0] = 9
        self.assertEqual(9, parray.recordthree[0])
        self.assertEqual(10, len(parray))
        with self.assertRaises(TypeError):
            pythonrecordarray.PythonRecordArray(10, [
                ("recordone", None),
            ])


if __name__ == '__main__':
    import test_all  #@UnresolvedImport
    test_all.run_tests([Test_PythonRecordArray])
Ejemplo n.º 12
0
# pylint: disable=import-error
# pylint: disable=too-many-public-methods, invalid-name
"""Test Module for mp3frame module"""

import unittest


class Test_MP3FrameList(unittest.TestCase):
    """Test suite for the MP3Frame module"""
    def setUp(self):
        pass

    def test_short_init(self):
        """Test method???"""
        #TODO: find some testing to do here (MP3FrameList)?
        self.assertTrue(True)


if __name__ == '__main__':
    import test_all  #@UnresolvedImport
    test_all.run_tests([Test_MP3FrameList])