Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_note2midi.py

    r7fd92ca r27ed546  
    55
    66from aubio import note2midi, freq2note, note2freq, float_type
    7 from numpy.testing import TestCase
    8 from _tools import parametrize, assert_raises, skipTest
     7from nose2.tools import params
     8import unittest
    99
    1010list_of_known_notes = (
     
    4545        )
    4646
    47 class Test_note2midi_good_values(object):
     47class note2midi_good_values(unittest.TestCase):
    4848
    49     @parametrize('note, midi', list_of_known_notes)
     49    @params(*list_of_known_notes)
    5050    def test_note2midi_known_values(self, note, midi):
    5151        " known values are correctly converted "
    52         assert note2midi(note) == midi
     52        self.assertEqual ( note2midi(note), midi )
    5353
    54     @parametrize('note, midi', list_of_known_notes_with_unicode_issues)
     54    @params(*list_of_known_notes_with_unicode_issues)
    5555    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"
    5757        try:
    58             assert note2midi(note) == midi
     58            self.assertEqual ( note2midi(note), midi )
    5959        except UnicodeEncodeError as e:
    60             # platforms with decoding failures include:
    61             # - osx: python <= 2.7.10
    62             # - win: python <= 2.7.12
    6360            import sys
    64             strmsg = "len(u'\\U0001D12A') != 1, expected decoding failure"
    65             strmsg += " | 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
    6764            if len('\U0001D12A') != 1 and sys.version[0] == '2':
    68                 skipTest(strmsg.format(repr(e), sys.platform, sys.version))
     65                self.skipTest(strres + " | upgrade to Python 3 to fix")
    6966            else:
    7067                raise
    7168
    72 class note2midi_wrong_values(TestCase):
     69class note2midi_wrong_values(unittest.TestCase):
    7370
    7471    def test_note2midi_missing_octave(self):
     
    108105        self.assertRaises(ValueError, note2midi, 'CB+-3')
    109106
    110 class Test_note2midi_unknown_values(object):
    111 
    112     @parametrize('note', list_of_unknown_notes)
     107    @params(*list_of_unknown_notes)
    113108    def test_note2midi_unknown_values(self, note):
    114109        " unknown values throw out an error "
    115         assert_raises(ValueError, note2midi, note)
     110        self.assertRaises(ValueError, note2midi, note)
    116111
    117 class freq2note_simple_test(TestCase):
     112class freq2note_simple_test(unittest.TestCase):
    118113
    119114    def test_freq2note_above(self):
     
    125120        self.assertEqual("A4", freq2note(439))
    126121
    127 class note2freq_simple_test(TestCase):
     122class note2freq_simple_test(unittest.TestCase):
    128123
    129124    def test_note2freq(self):
     
    139134
    140135if __name__ == '__main__':
    141     from _tools import run_module_suite
    142     run_module_suite()
     136    import nose2
     137    nose2.main()
Note: See TracChangeset for help on using the changeset viewer.