ref: d554321c6c3b7648bbf4e44e35c55999683ea74e
parent: 473ab11339f73c5e6a04265aab092c8bfb5c7974
author: Paul Brossier <piem@piem.org>
date: Fri Dec 2 08:44:12 EST 2016
python/tests/test_{midi2note,note2midi}.py: use nose2.params, add unicode tests
--- a/python/tests/test_midi2note.py
+++ b/python/tests/test_midi2note.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from aubio import midi2note
+from nose2.tools import params
import unittest
list_of_known_midis = (
@@ -16,10 +17,10 @@
class midi2note_good_values(unittest.TestCase):
- def test_midi2note_known_values(self):
+ @params(*list_of_known_midis)
+ def test_midi2note_known_values(self, midi, note):
" known values are correctly converted "
- for midi, note in list_of_known_midis:
- self.assertEqual ( midi2note(midi), note )
+ self.assertEqual ( midi2note(midi), note )
class midi2note_wrong_values(unittest.TestCase):
@@ -40,4 +41,5 @@
self.assertRaises(TypeError, midi2note, "a")
if __name__ == '__main__':
- unittest.main()
+ import nose2
+ nose2.main()
--- a/python/tests/test_note2midi.py
+++ b/python/tests/test_note2midi.py
@@ -4,6 +4,7 @@
from __future__ import unicode_literals
from aubio import note2midi, freq2note
+from nose2.tools import params
import unittest
list_of_known_notes = (
@@ -13,6 +14,9 @@
( 'C3', 48 ),
( 'B3', 59 ),
( 'B#3', 60 ),
+ ( 'C\u266f4', 61 ),
+ ( 'C\U0001D12A4', 62 ),
+ ( 'E\U0001D12B4', 62 ),
( 'A4', 69 ),
( 'A#4', 70 ),
( 'Bb4', 70 ),
@@ -27,10 +31,10 @@
class note2midi_good_values(unittest.TestCase):
- def test_note2midi_known_values(self):
+ @params(*list_of_known_notes)
+ def test_note2midi_known_values(self, note, midi):
" known values are correctly converted "
- for note, midi in list_of_known_notes:
- self.assertEqual ( note2midi(note), midi )
+ self.assertEqual ( note2midi(note), midi )
class note2midi_wrong_values(unittest.TestCase):
@@ -74,4 +78,5 @@
self.assertEqual("A4", freq2note(441))
if __name__ == '__main__':
- unittest.main()
+ import nose2
+ nose2.main()