From: Paul Brossier Date: Fri, 2 Dec 2016 12:44:12 +0000 (+0100) Subject: python/tests/test_{midi2note,note2midi}.py: use nose2.params, add unicode tests X-Git-Tag: 0.4.4~102 X-Git-Url: https://git.aubio.org/?p=aubio.git;a=commitdiff_plain;h=d554321c6c3b7648bbf4e44e35c55999683ea74e python/tests/test_{midi2note,note2midi}.py: use nose2.params, add unicode tests --- diff --git a/python/tests/test_midi2note.py b/python/tests/test_midi2note.py index 1c2ccf5b..056738e3 100755 --- 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 @@ list_of_known_midis = ( 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 @@ class midi2note_wrong_values(unittest.TestCase): self.assertRaises(TypeError, midi2note, "a") if __name__ == '__main__': - unittest.main() + import nose2 + nose2.main() diff --git a/python/tests/test_note2midi.py b/python/tests/test_note2midi.py index 968c34a8..7524a519 100755 --- 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 @@ list_of_known_notes = ( ( '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 @@ list_of_known_notes = ( 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 @@ class freq2note_simple_test(unittest.TestCase): self.assertEqual("A4", freq2note(441)) if __name__ == '__main__': - unittest.main() + import nose2 + nose2.main()