3 # © Copyright 2021-2022, Scott Gasch
5 """chord parser unittest"""
9 from music.chords import ChordParser
12 import unittest_utils as uu
15 class TestChordParder(unittest.TestCase):
16 def test_with_known_correct_answers(self):
18 'D': "root=D, others={'maj3': 4, 'perfect5th': 7}",
19 'Dmaj': "root=D, others={'maj3': 4, 'perfect5th': 7}",
20 'D major': "root=D, others={'maj3': 4, 'perfect5th': 7}",
21 'DM': "root=D, others={'maj3': 4, 'perfect5th': 7}",
22 'Dm': "root=D, others={'min3': 3, 'perfect5th': 7}",
23 'Dmin': "root=D, others={'min3': 3, 'perfect5th': 7}",
24 'D minor': "root=D, others={'min3': 3, 'perfect5th': 7}",
25 'Asus2': "root=A, others={'maj2': 2, 'perfect5th': 7}",
26 'Bsus4': "root=B, others={'perfect4': 5, 'perfect5th': 7}",
27 'F5': "root=F, others={'perfect5th': 7}",
28 'G/B': "root=G, others={'maj3': 4, 'perfect5th': 7, 'B': 3}",
32 for chord_name, expected_answer in expected_answers.items():
34 expected_answer, cp.parse(chord_name).__repr__(), f'Failed for {chord_name}'
38 if __name__ == '__main__':
39 bootstrap.initialize(unittest.main)()