Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -1,7 +1,7 @@ | |||
| 1 | #! /usr/bin/env python | 1 | #! /usr/bin/env python |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | 3 | ||
| 4 | from aubio import note2midi | 4 | from aubio import note2midi, freq2note |
| 5 | import unittest | 5 | import unittest |
| 6 | 6 | ||
| 7 | list_of_known_notes = ( | 7 | list_of_known_notes = ( |
| @@ -49,12 +49,27 @@ class note2midi_wrong_values(unittest.TestCase): · 41 unmodified lines | |||
| 49 | self.assertRaises(ValueError, note2midi, 'CBc') | 49 | self.assertRaises(ValueError, note2midi, 'CBc') |
| 50 | 50 | ||
| 51 | def test_note2midi_out_of_range(self): | 51 | def test_note2midi_out_of_range(self): |
| 52 | " fails when passed a out of range note" | 52 | " fails when passed a note out of range" |
| 53 | self.assertRaises(ValueError, note2midi, 'A9') | 53 | self.assertRaises(ValueError, note2midi, 'A9') |
| 54 | 54 | ||
| 55 | def test_note2midi_wrong_note_name(self): | ||
| 56 | " fails when passed a note with a wrong name" | ||
| 57 | self.assertRaises(ValueError, note2midi, 'W9') | ||
| 58 | |||
| 59 | def test_note2midi_wrong_octave(self): | ||
| 60 | " fails when passed a note with a wrong octave" | ||
| 61 | self.assertRaises(ValueError, note2midi, 'C-9') | ||
| 62 | |||
| 55 | def test_note2midi_wrong_data_type(self): | 63 | def test_note2midi_wrong_data_type(self): |
| 56 | " fails when passed a non-string value " | 64 | " fails when passed a non-string value " |
| 57 | self.assertRaises(TypeError, note2midi, 123) | 65 | self.assertRaises(TypeError, note2midi, 123) |
| 58 | 66 | ||
| 67 | |||
| 68 | class freq2note_simple_test(unittest.TestCase): | ||
| 69 | |||
| 70 | def test_freq2note(self): | ||
| 71 | " make sure freq2note(441) == A4 " | ||
| 72 | self.assertEquals("A4", freq2note(441)) | ||
| 73 | |||
| 59 | if __name__ == '__main__': | 74 | if __name__ == '__main__': |
| 60 | unittest.main() | 75 | unittest.main() |