History

tests/test_note2midi.py: more tests

Paul Brossier committed 10 years ago

Commit 6db76001 parent 689106e1 file · +17 −2Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/tests/test_note2midi.py+17−2
@@ -1,7 +1,7 @@
1#! /usr/bin/env python1#! /usr/bin/env python
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3 3
4from aubio import note2midi4from aubio import note2midi, freq2note
5import unittest5import unittest
6 6
7list_of_known_notes = (7list_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
68class freq2note_simple_test(unittest.TestCase):
69
70 def test_freq2note(self):
71 " make sure freq2note(441) == A4 "
72 self.assertEquals("A4", freq2note(441))
73
59if __name__ == '__main__':74if __name__ == '__main__':
60 unittest.main()75 unittest.main()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t