def compare_humdrum_file(filename): with open(filename) as f: orig = f.read().strip() conv = emit.show_humdrum(humdrum.parse_file(filename)) s = difflib.SequenceMatcher(None, orig, conv) lines = zip(orig.splitlines(), conv.splitlines(), count()) diff = [(o, g, n) for o, g, n in lines if o != g] return s.ratio(), diff, orig, conv
def test_show_note_c_with_articulations(): note3 = score.Note("C", Fraction(1, 4)) note3.articulations = ["harmonic", "turn", "tie-start"] assert emit.show_humdrum(note3) == "4coS["
def test_show_note_c2f(two_notes): note1, note2 = two_notes assert emit.show_humdrum(note2) == "4.C--"
def test_show_note_cs(two_notes): note1, note2 = two_notes assert emit.show_humdrum(note1) == "4cccc#"
def test_show_list(two_notes): note1, note2 = two_notes alist = [note1, note2] assert emit.show_humdrum(alist) == "4cccc# 4.C--"
def generate_humdrum(filename, options): print emit.show_humdrum(humdrum.parse_file(filename))
def test_show_nulltoken(): assert emit.show_humdrum(score.NullToken()) == "."
def test_show_rest(): rest = score.Rest(Fraction(3, 8)) assert emit.show_humdrum(rest) == "4.r"
def test_show_spine_end(): assert emit.show_humdrum(score.SpinePath("spine-end")) == '*-'
def test_show_nullinterpretation(): assert emit.show_humdrum(score.NullInterpretation()) == '*'
def test_show_exclusive(): exclusive = score.Exclusive("kern") assert emit.show_humdrum(exclusive) == "**kern"
def test_show_tandem_instrument_user(): tandem = score.Tandem("instrument-user", "violin") assert emit.show_humdrum(tandem) == '*I:violin'
def test_show_comment(): comment = score.Comment("bla bla", 2) assert emit.show_humdrum(comment) == '!! bla bla'
def test_show_record(): record = score.Record("COM", "J. S. Bach") assert emit.show_humdrum(record) == '!!! COM: J. S. Bach'
def test_show_chord(two_notes): note1, note2 = two_notes chord = score.MultipleStop([note1, note2]) assert emit.show_humdrum(chord) == "4cccc# 4.C--"
def test_show_bar(): bar = score.Bar(2) assert emit.show_humdrum(bar) == "=2"
def test_show_spine_add(): assert emit.show_humdrum(score.SpinePath("spine-add")) == '*+'
def test_show_blankline(): assert emit.show_humdrum(score.BlankLine()) == "\n"
def test_show_spine_split(): assert emit.show_humdrum(score.SpinePath("spine-split")) == '*^'
def test_show_unknowntype(): unknowntype = score.UnknownType("foo") assert emit.show_humdrum(unknowntype) == "foo"
def test_show_spine_join(): assert emit.show_humdrum(score.SpinePath("spine-join")) == '*v'
def test_show_spine_swap(): assert emit.show_humdrum(score.SpinePath("spine-swap")) == '*x'
def test_show_score(two_notes): record = score.Record("COM", "J. S. Bach") kern = score.Exclusive("kern") note1, note2 = two_notes sco = score.Score(record, kern, [note1], [note2]) assert emit.show_humdrum(sco) == "!!! COM: J. S. Bach\n**kern\n4cccc#\n4.C--"