Ignore:
Timestamp:
Dec 19, 2018, 9:50:06 PM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/crepe, fix/ffmpeg5, master
Children:
65628c4, 9630fa8
Parents:
eba24c59 (diff), f5adffe (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'feature/sink_vorbis' into feature/sink_flac

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_note2midi.py

    reba24c59 r5573a6b  
    55
    66from aubio import note2midi, freq2note, note2freq, float_type
    7 from nose2.tools import params
    8 import unittest
     7from numpy.testing import TestCase
     8from _tools import parametrize, assert_raises, skipTest
    99
    1010list_of_known_notes = (
     
    4545        )
    4646
    47 class note2midi_good_values(unittest.TestCase):
     47class Test_note2midi_good_values(object):
    4848
    49     @params(*list_of_known_notes)
     49    @parametrize('note, midi', list_of_known_notes)
    5050    def test_note2midi_known_values(self, note, midi):
    5151        " known values are correctly converted "
    52         self.assertEqual ( note2midi(note), midi )
     52        assert note2midi(note) == midi
    5353
    54     @params(*list_of_known_notes_with_unicode_issues)
     54    @parametrize('note, midi', list_of_known_notes_with_unicode_issues)
    5555    def test_note2midi_known_values_with_unicode_issues(self, note, midi):
    56         " known values are correctly converted, unless decoding is expected to fail"
     56        " difficult values are correctly converted unless expected failure "
    5757        try:
    58             self.assertEqual ( note2midi(note), midi )
     58            assert 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
    6063            import sys
    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
     64            strmsg = "len(u'\\U0001D12A') != 1, expected decoding failure"
     65            strmsg += " | upgrade to Python 3 to fix"
     66            strmsg += " | {:s} | {:s} {:s}"
    6467            if len('\U0001D12A') != 1 and sys.version[0] == '2':
    65                 self.skipTest(strres + " | upgrade to Python 3 to fix")
     68                skipTest(strmsg.format(repr(e), sys.platform, sys.version))
    6669            else:
    6770                raise
    6871
    69 class note2midi_wrong_values(unittest.TestCase):
     72class note2midi_wrong_values(TestCase):
    7073
    7174    def test_note2midi_missing_octave(self):
     
    105108        self.assertRaises(ValueError, note2midi, 'CB+-3')
    106109
    107     @params(*list_of_unknown_notes)
     110class Test_note2midi_unknown_values(object):
     111
     112    @parametrize('note', list_of_unknown_notes)
    108113    def test_note2midi_unknown_values(self, note):
    109114        " unknown values throw out an error "
    110         self.assertRaises(ValueError, note2midi, note)
     115        assert_raises(ValueError, note2midi, note)
    111116
    112 class freq2note_simple_test(unittest.TestCase):
     117class freq2note_simple_test(TestCase):
    113118
    114119    def test_freq2note_above(self):
     
    120125        self.assertEqual("A4", freq2note(439))
    121126
    122 class note2freq_simple_test(unittest.TestCase):
     127class note2freq_simple_test(TestCase):
    123128
    124129    def test_note2freq(self):
     
    134139
    135140if __name__ == '__main__':
    136     import nose2
    137     nose2.main()
     141    from _tools import run_module_suite
     142    run_module_suite()
Note: See TracChangeset for help on using the changeset viewer.