More changes to get 3.9 working.
[python_utils.git] / tests / chords_test.py
1 #!/usr/bin/env python3
2
3 # © Copyright 2021-2022, Scott Gasch
4
5 """chord parser unittest"""
6
7 import unittest
8
9 from music.chords import ChordParser
10
11 import bootstrap
12 import unittest_utils as uu
13
14
15 class TestChordParder(unittest.TestCase):
16     def test_with_known_correct_answers(self):
17         expected_answers = {
18             'D': "D (major)\nroot=D\n+ major 3rd (4) => F#\n+ perfect 5th (7) => A\n",
19             'DM': "D (major)\nroot=D\n+ major 3rd (4) => F#\n+ perfect 5th (7) => A\n",
20             'Dmaj': "D (major)\nroot=D\n+ major 3rd (4) => F#\n+ perfect 5th (7) => A\n",
21             'D major': "D (major)\nroot=D\n+ major 3rd (4) => F#\n+ perfect 5th (7) => A\n",
22         }
23
24         cp = ChordParser()
25         for chord_name, expected_answer in expected_answers.items():
26             self.assertEqual(
27                 expected_answer, cp.parse(chord_name).__repr__(), f'Failed for {chord_name}'
28             )
29
30
31 if __name__ == '__main__':
32     bootstrap.initialize(unittest.main)()