Changes in python/tests/test_note2midi.py [7fd92ca:27ed546]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_note2midi.py
r7fd92ca r27ed546 5 5 6 6 from aubio import note2midi, freq2note, note2freq, float_type 7 from n umpy.testing import TestCase8 from _tools import parametrize, assert_raises, skipTest7 from nose2.tools import params 8 import unittest 9 9 10 10 list_of_known_notes = ( … … 45 45 ) 46 46 47 class Test_note2midi_good_values(object):47 class note2midi_good_values(unittest.TestCase): 48 48 49 @param etrize('note, midi',list_of_known_notes)49 @params(*list_of_known_notes) 50 50 def test_note2midi_known_values(self, note, midi): 51 51 " known values are correctly converted " 52 assert note2midi(note) == midi52 self.assertEqual ( note2midi(note), midi ) 53 53 54 @param etrize('note, midi',list_of_known_notes_with_unicode_issues)54 @params(*list_of_known_notes_with_unicode_issues) 55 55 def test_note2midi_known_values_with_unicode_issues(self, note, midi): 56 " difficult values are correctly converted unless expected failure"56 " known values are correctly converted, unless decoding is expected to fail" 57 57 try: 58 assert note2midi(note) == midi58 self.assertEqual ( note2midi(note), midi ) 59 59 except UnicodeEncodeError as e: 60 # platforms with decoding failures include:61 # - osx: python <= 2.7.1062 # - win: python <= 2.7.1263 60 import sys 64 str msg = "len(u'\\U0001D12A') != 1, expected decoding failure"65 str msg += " | upgrade to Python 3 to fix"66 strmsg += " | {:s} | {:s} {:s}"61 strfmt = "len(u'\\U0001D12A') != 1, excpected decoding failure | {:s} | {:s} {:s}" 62 strres = strfmt.format(e, sys.platform, sys.version) 63 # happens with: darwin 2.7.10, windows 2.7.12 67 64 if len('\U0001D12A') != 1 and sys.version[0] == '2': 68 s kipTest(strmsg.format(repr(e), sys.platform, sys.version))65 self.skipTest(strres + " | upgrade to Python 3 to fix") 69 66 else: 70 67 raise 71 68 72 class note2midi_wrong_values( TestCase):69 class note2midi_wrong_values(unittest.TestCase): 73 70 74 71 def test_note2midi_missing_octave(self): … … 108 105 self.assertRaises(ValueError, note2midi, 'CB+-3') 109 106 110 class Test_note2midi_unknown_values(object): 111 112 @parametrize('note', list_of_unknown_notes) 107 @params(*list_of_unknown_notes) 113 108 def test_note2midi_unknown_values(self, note): 114 109 " unknown values throw out an error " 115 assert_raises(ValueError, note2midi, note)110 self.assertRaises(ValueError, note2midi, note) 116 111 117 class freq2note_simple_test( TestCase):112 class freq2note_simple_test(unittest.TestCase): 118 113 119 114 def test_freq2note_above(self): … … 125 120 self.assertEqual("A4", freq2note(439)) 126 121 127 class note2freq_simple_test( TestCase):122 class note2freq_simple_test(unittest.TestCase): 128 123 129 124 def test_note2freq(self): … … 139 134 140 135 if __name__ == '__main__': 141 from _tools import run_module_suite142 run_module_suite()136 import nose2 137 nose2.main()
Note: See TracChangeset
for help on using the changeset viewer.