示例#1
0
    def testIncompleteNoteAndUpdate(self):
        """test a few basic examples of a lilypond note
        """
        for s, expNote in [(",8.", ("", ",", "8.", "", None)),
                           ("8", ("", "", "8", "", None)),
                           ("\melismaEnd", ("", "", "", "", [r"\melismaEnd"])),
                           (r",,1\melismaEnd]\break\)",
                            ("", ",,", "1", r"]\)",
                             [r'\melismaEnd', r'\break']))]:

            lyn = lynote.LyNote(s)
            self.checkLyResult(expNote, lyn)
            print 'testIncompleteNote OK: "%s", result: "%s"' % (s, lyn)

        updateNote = ","
        orgNote = "g'4("
        lyorg = lynote.LyNote(orgNote)
        lyorg.updateNote(updateNote)
        expUpdated = ("g", "", "4", "(", None)
        self.checkLyResult(expUpdated, lyorg)
        print 'testIncompleteNote "%s" updated with "%s" OK, result: "%s"' % (
            orgNote, updateNote, lyorg)

        updateNote = "8"
        orgNote = "a'4("
        lyorg = lynote.LyNote(orgNote)
        lyorg.updateNote(updateNote)
        expUpdated = ("a", "'", "8", "(", None)
        self.checkLyResult(expUpdated, lyorg)
        print 'testIncompleteNote "%s" updated with string "%s" OK, result: "%s"' % (
            orgNote, updateNote, lyorg)

        lyorg = lynote.LyNote(orgNote)
        lyupdate = lynote.LyNote(updateNote)
        lyorg.updateNote(lyupdate)
        self.checkLyResult(expUpdated, lyorg)
        print 'testIncompleteNote "%s" updated with instance "%s" OK, result: "%s"' % (
            orgNote, lyupdate, lyorg)

        updateNote = "c'8..\melisma"
        orgNote = "b'4("
        lyorg = lynote.LyNote(orgNote)
        lyorg.updateNote(updateNote)
        expUpdated = ("c", "''", "8..", "(", [r"\melisma"])
        self.checkLyResult(expUpdated, lyorg)
        print 'testIncompleteNote "%s" updated with "%s" OK, result: "%s"' % (
            orgNote, updateNote, lyorg)

        lyorg = lynote.LyNote(orgNote)
        lyupdate = lynote.LyNote(updateNote)
        lyorg.updateNote(lyupdate)
        self.checkLyResult(expUpdated, lyorg)
        print 'testIncompleteNote "%s" updated with instance "%s" OK, result: "%s"' % (
            orgNote, lyupdate, lyorg)
示例#2
0
 def testStrAndRepr(self):
     """check the correct str and repr result"""
     for s in ["g,8.", "a,,8"]:
         expStr = s
         lyn = lynote.LyNote(s)
         self.assertEqual(expStr, str(lyn),
                          'str of "%s" fails ("%s")' % (s, str(lyn)))
         print 'testStrAndRepr: correct str "%s" (being the same)' % s
         expRepr = "lynote: " + s
         self.assertEqual(expRepr, repr(lyn),
                          'repr of "%s" fails ("%s")' % (s, repr(lyn)))
         print 'testStrAndRepr: correct repr "%s" (of "%s")' % (s, repr(s))
示例#3
0
    def testSimpleNote(self):
        """test a few basic examples of a lilypond note
        """
        for s, expNote in [
            ("g,8.", ("g", ",", "8.", "", None)),
            ("a,,8", ("a", ",,", "8", "", None)),
            ("cis", ("cis", "", "", "", None)),
            ("aes'(", ("aes", "'", "", "(", None)),
            (r"d4([\melisma", ("d", "", "4", "([", ['\\melisma'])),
            (r"ais,,32..\melismaEnd]\break\)", ("ais", ",,", "32..", r"]\)",
                                                [r'\melismaEnd', r'\break']))
        ]:

            lyn = lynote.LyNote(s)
            self.checkLyResult(expNote, lyn)
            self.assert_(
                lyn.isNote(),
                '"%s" should be a note (isNote function), not: %s' %
                (s, lyn.isNote()))
            print 'testSimpleNote OK: "%s", result: "%s"' % (s, lyn)