Пример #1
0
class TMidiFile(TestCase):
    def setUp(self):
        self.song = MidiFile(get_data_path('test.mid'))

    def test_length(self):
        self.failUnlessAlmostEqual(87, self.song("~#length", 0), 0)

    def test_reload(self):
        self.song["title"] = "foobar"
        self.song.reload()
        self.failUnlessEqual(self.song("title"), "foobar")

    def test_write(self):
        self.song.write()

    def test_can_change(self):
        self.failUnlessEqual(self.song.can_change(), ["title"])
        self.failUnless(self.song.can_change("title"))
        self.failIf(self.song.can_change("album"))

    def test_invalid(self):
        path = get_data_path('empty.xm')
        self.failUnlessRaises(Exception, MidiFile, path)

    def test_format_codec(self):
        self.assertEqual(self.song("~format"), "MIDI")
        self.assertEqual(self.song("~codec"), "MIDI")
        self.assertEqual(self.song("~encoding"), "")
Пример #2
0
class TMidiFile(TestCase):
    def setUp(self):
        self.song = MidiFile(os.path.join(DATA_DIR, 'test.mid'))

    def test_length(self):
        self.failUnlessAlmostEqual(87, self.song("~#length", 0), 0)

    def test_reload(self):
        self.song["title"] = "foobar"
        self.song.reload()
        self.failUnlessEqual(self.song("title"), "foobar")

    def test_write(self):
        self.song.write()

    def test_can_change(self):
        self.failUnlessEqual(self.song.can_change(), ["title"])
        self.failUnless(self.song.can_change("title"))
        self.failIf(self.song.can_change("album"))

    def test_invalid(self):
        path = os.path.join(DATA_DIR, 'empty.xm')
        self.failUnlessRaises(Exception, MidiFile, path)

    def test_format_codec(self):
        self.assertEqual(self.song("~format"), "MIDI")
        self.assertEqual(self.song("~codec"), "MIDI")
        self.assertEqual(self.song("~encoding"), "")
Пример #3
0
class TMidiFile(TestCase):
    def setUp(self):
        self.song = MidiFile(os.path.join('tests', 'data', 'test.mid'))

    def test_length(self):
        self.failUnlessAlmostEqual(87, self.song("~#length", 0), 0)

    def test_reload(self):
        self.song["title"] = "foobar"
        self.song.reload()
        self.failUnlessEqual(self.song("title"), "foobar")

    def test_write(self):
        self.song.write()

    def test_can_change(self):
        self.failUnlessEqual(self.song.can_change(), ["title"])
        self.failUnless(self.song.can_change("title"))
        self.failIf(self.song.can_change("album"))

    def test_invalid(self):
        path = os.path.join('tests', 'data', 'empty.xm')
        self.failUnlessRaises(Exception, MidiFile, path)
Пример #4
0
class TMidiFile(TestCase):
    def setUp(self):
        self.song = MidiFile(os.path.join(DATA_DIR, 'test.mid'))

    def test_length(self):
        self.failUnlessAlmostEqual(87, self.song("~#length", 0), 0)

    def test_reload(self):
        self.song["title"] = "foobar"
        self.song.reload()
        self.failUnlessEqual(self.song("title"), "foobar")

    def test_write(self):
        self.song.write()

    def test_can_change(self):
        self.failUnlessEqual(self.song.can_change(), ["title"])
        self.failUnless(self.song.can_change("title"))
        self.failIf(self.song.can_change("album"))

    def test_invalid(self):
        path = os.path.join(DATA_DIR, 'empty.xm')
        self.failUnlessRaises(Exception, MidiFile, path)