Example #1
0
def parse_chord_line_test():
    parsed = parser.parse_line('A7    Cm    Fm7')
    eq_(parsed.type, 'chord')
    chords = parsed.data.chords
    eq_(len(chords), 3)
    eq_(chords[0].chord, Chord.parse('A7'))
    eq_(chords[0].position, 0)
    eq_(chords[1].chord, Chord.parse('Cm'))
    eq_(chords[1].position, 6)
    eq_(chords[2].chord, Chord.parse('Fm7'))
    eq_(chords[2].position, 12)
Example #2
0
def basic_chord_parse_test():
    """ Parse chords with no variations """
    for key in _KEYS:
        parsed = Chord.parse(key.text())
        eq_(parsed.key, key)
        eq_(parsed.variation, None)
        eq_(parsed.bass, key)
        _check_text_parsing(parsed)
Example #3
0
def variation_chord_parse_test():
    """ Parse chords with variations """
    for key in _KEYS:
        for variation in _VARIATIONS:
            parsed = Chord.parse(key.text() + variation)
            eq_(parsed.key, key)
            eq_(parsed.variation, variation)
            eq_(parsed.bass, key)
            _check_text_parsing(parsed)
Example #4
0
def bass_chord_parse_test():
    """ Parse chords with bass """
    for key in _KEYS:
        for variation in _VARIATIONS + [""]:
            for bass in _KEYS:
                text = key.text() + variation + "/" + bass.text()
                parsed = Chord.parse(text)
                eq_(parsed.key, key)
                eq_(parsed.variation, variation if variation else None)
                eq_(parsed.bass, bass)
Example #5
0
def parse_tab_test():
    parsed = parser.parse_tablature([
        'A',
        'A line',
        '',
    ])
    lines = parsed.lines
    eq_(len(lines), 3)
    eq_(lines[0].type, 'chord')
    eq_(len(lines[0].data.chords), 1)
    eq_(lines[0].data.chords[0].position, 0)
    eq_(lines[0].data.chords[0].chord, Chord.parse("A"))
    eq_(lines[1].type, 'lyric')
    eq_(lines[1].data.lyrics, 'A line')
    eq_(lines[2].type, 'empty')
Example #6
0
def _check_text_parsing(chord):
    eq_(Chord.parse(chord.text()), chord)