(self, answer_dict, scale, name)
| 8 | |
| 9 | class test_scales(unittest.TestCase): |
| 10 | def scaleTest(self, answer_dict, scale, name): |
| 11 | for k in answer_dict: |
| 12 | if name == "diatonic scale": |
| 13 | self.assertEqual( |
| 14 | answer_dict[k][0], |
| 15 | scale(k[0], k[1]).ascending(), |
| 16 | ( |
| 17 | "The ascending %s of %s, with semitones in %s, " |
| 18 | "is not %s; expecting %s" |
| 19 | % ( |
| 20 | name, |
| 21 | k[0], |
| 22 | k[1], |
| 23 | scale(k[0], k[1]).ascending(), |
| 24 | answer_dict[k][0], |
| 25 | ) |
| 26 | ), |
| 27 | ) |
| 28 | self.assertEqual( |
| 29 | answer_dict[k][1], |
| 30 | scale(k[0], k[1]).descending(), |
| 31 | ( |
| 32 | "The descending %s of %s, with semitones in %s, " |
| 33 | "is not %s; expecting %s" |
| 34 | % ( |
| 35 | name, |
| 36 | k[0], |
| 37 | k[1], |
| 38 | scale(k[0], k[1]).descending(), |
| 39 | answer_dict[k][1], |
| 40 | ) |
| 41 | ), |
| 42 | ) |
| 43 | else: |
| 44 | self.assertEqual( |
| 45 | answer_dict[k][0], |
| 46 | scale(k).ascending(), |
| 47 | ( |
| 48 | "The ascending %s of %s is not %s; " |
| 49 | "expecting %s" |
| 50 | % (name, k, scale(k).ascending(), answer_dict[k][0]) |
| 51 | ), |
| 52 | ) |
| 53 | self.assertEqual( |
| 54 | answer_dict[k][1], |
| 55 | scale(k).descending(), |
| 56 | ( |
| 57 | "The descending %s of %s is not %s; " |
| 58 | "expecting %s" |
| 59 | % (name, k, scale(k).descending(), answer_dict[k][1]) |
| 60 | ), |
| 61 | ) |
| 62 | |
| 63 | def test_diatonic(self): |
| 64 | self.scaleTest( |
no test coverage detected