Changeset 86deeed
- Timestamp:
- Nov 1, 2018, 10:33:39 PM (6 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
- Children:
- 7debeb6
- Parents:
- 4c1eff4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_note2midi.py
r4c1eff4 r86deeed 5 5 6 6 from aubio import note2midi, freq2note, note2freq, float_type 7 from n ose2.tools import params8 import unittest 7 from numpy.testing import TestCase 8 from ._tools import parametrize, assert_raises 9 9 10 10 list_of_known_notes = ( … … 45 45 ) 46 46 47 class note2midi_good_values(unittest.TestCase):47 class Test_note2midi_good_values: 48 48 49 @param s(*list_of_known_notes)49 @parametrize('note, midi', list_of_known_notes) 50 50 def test_note2midi_known_values(self, note, midi): 51 51 " known values are correctly converted " 52 self.assertEqual ( note2midi(note), midi )52 assert note2midi(note) == midi 53 53 54 @param s(*list_of_known_notes_with_unicode_issues)54 @parametrize('note, midi', list_of_known_notes_with_unicode_issues) 55 55 def test_note2midi_known_values_with_unicode_issues(self, note, midi): 56 56 " known values are correctly converted, unless decoding is expected to fail" 57 57 try: 58 self.assertEqual ( note2midi(note), midi )58 assert note2midi(note) == midi 59 59 except UnicodeEncodeError as e: 60 60 import sys … … 63 63 # happens with: darwin 2.7.10, windows 2.7.12 64 64 if len('\U0001D12A') != 1 and sys.version[0] == '2': 65 s elf.skipTest(strres + " | upgrade to Python 3 to fix")65 skipTest(strres + " | upgrade to Python 3 to fix") 66 66 else: 67 67 raise 68 68 69 class note2midi_wrong_values( unittest.TestCase):69 class note2midi_wrong_values(TestCase): 70 70 71 71 def test_note2midi_missing_octave(self): … … 105 105 self.assertRaises(ValueError, note2midi, 'CB+-3') 106 106 107 @params(*list_of_unknown_notes) 107 class Test_note2midi_unknown_values: 108 109 @parametrize('note', list_of_unknown_notes) 108 110 def test_note2midi_unknown_values(self, note): 109 111 " unknown values throw out an error " 110 self.assertRaises(ValueError, note2midi, note)112 assert_raises(ValueError, note2midi, note) 111 113 112 class freq2note_simple_test( unittest.TestCase):114 class freq2note_simple_test(TestCase): 113 115 114 116 def test_freq2note_above(self): … … 120 122 self.assertEqual("A4", freq2note(439)) 121 123 122 class note2freq_simple_test( unittest.TestCase):124 class note2freq_simple_test(TestCase): 123 125 124 126 def test_note2freq(self): … … 134 136 135 137 if __name__ == '__main__': 136 import nose2137 nose2.main()138 from unittest import main 139 main()
Note: See TracChangeset
for help on using the changeset viewer.