History

python/tests/test_{midi2note,note2midi}.py: use nose2.params, add unicode tests

Paul Brossier committed 9 years ago

Commit d5543211 parent 473ab112 files · +15 −8Browse files

Showing the changes to python/tests (2 of 2 files). Show all

Unified · Split

2 files
  1. python/tests/test_midi2note.py +6 −4
  2. python/tests/test_note2midi.py +9 −4
python/tests/test_midi2note.py+6−4
@@ -2,6 +2,7 @@ · 1 unmodified line
22 # -*- coding: utf-8 -*-
33
44 from aubio import midi2note
5+from nose2.tools import params
56 import unittest
67
78 list_of_known_midis = (
@@ -16,10 +17,10 @@ list_of_known_midis = ( · 8 unmodified lines
1617
1718 class midi2note_good_values(unittest.TestCase):
1819
19− def test_midi2note_known_values(self):
20+ @params(*list_of_known_midis)
21+ def test_midi2note_known_values(self, midi, note):
2022 " known values are correctly converted "
21− for midi, note in list_of_known_midis:
22− self.assertEqual ( midi2note(midi), note )
23+ self.assertEqual ( midi2note(midi), note )
2324
2425 class midi2note_wrong_values(unittest.TestCase):
2526
@@ -40,4 +41,5 @@ class midi2note_wrong_values(unittest.TestCase): · 14 unmodified lines
4041 self.assertRaises(TypeError, midi2note, "a")
4142
4243 if __name__ == '__main__':
43− unittest.main()
44+ import nose2
45+ nose2.main()
python/tests/test_note2midi.py+9−4
@@ -4,6 +4,7 @@ · 3 unmodified lines
44 from __future__ import unicode_literals
55
66 from aubio import note2midi, freq2note
7+from nose2.tools import params
78 import unittest
89
910 list_of_known_notes = (
@@ -13,6 +14,9 @@ list_of_known_notes = ( · 3 unmodified lines
1314 ( 'C3', 48 ),
1415 ( 'B3', 59 ),
1516 ( 'B#3', 60 ),
17+ ( 'C\u266f4', 61 ),
18+ ( 'C\U0001D12A4', 62 ),
19+ ( 'E\U0001D12B4', 62 ),
1620 ( 'A4', 69 ),
1721 ( 'A#4', 70 ),
1822 ( 'Bb4', 70 ),
@@ -27,10 +31,10 @@ list_of_known_notes = ( · 8 unmodified lines
2731
2832 class note2midi_good_values(unittest.TestCase):
2933
30− def test_note2midi_known_values(self):
34+ @params(*list_of_known_notes)
35+ def test_note2midi_known_values(self, note, midi):
3136 " known values are correctly converted "
32− for note, midi in list_of_known_notes:
33− self.assertEqual ( note2midi(note), midi )
37+ self.assertEqual ( note2midi(note), midi )
3438
3539 class note2midi_wrong_values(unittest.TestCase):
3640
@@ -74,4 +78,5 @@ class freq2note_simple_test(unittest.TestCase): · 37 unmodified lines
7478 self.assertEqual("A4", freq2note(441))
7579
7680 if __name__ == '__main__':
77− unittest.main()
81+ import nose2
82+ nose2.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