Changeset 86deeed


Ignore:
Timestamp:
Nov 1, 2018, 10:33:39 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
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
Message:

[tests] use _tools in test_note2midi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_note2midi.py

    r4c1eff4 r86deeed  
    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
    99
    1010list_of_known_notes = (
     
    4545        )
    4646
    47 class note2midi_good_values(unittest.TestCase):
     47class Test_note2midi_good_values:
    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):
    5656        " known values are correctly converted, unless decoding is expected to fail"
    5757        try:
    58             self.assertEqual ( note2midi(note), midi )
     58            assert note2midi(note) == midi
    5959        except UnicodeEncodeError as e:
    6060            import sys
     
    6363            # happens with: darwin 2.7.10, windows 2.7.12
    6464            if len('\U0001D12A') != 1 and sys.version[0] == '2':
    65                 self.skipTest(strres + " | upgrade to Python 3 to fix")
     65                skipTest(strres + " | upgrade to Python 3 to fix")
    6666            else:
    6767                raise
    6868
    69 class note2midi_wrong_values(unittest.TestCase):
     69class note2midi_wrong_values(TestCase):
    7070
    7171    def test_note2midi_missing_octave(self):
     
    105105        self.assertRaises(ValueError, note2midi, 'CB+-3')
    106106
    107     @params(*list_of_unknown_notes)
     107class Test_note2midi_unknown_values:
     108
     109    @parametrize('note', list_of_unknown_notes)
    108110    def test_note2midi_unknown_values(self, note):
    109111        " unknown values throw out an error "
    110         self.assertRaises(ValueError, note2midi, note)
     112        assert_raises(ValueError, note2midi, note)
    111113
    112 class freq2note_simple_test(unittest.TestCase):
     114class freq2note_simple_test(TestCase):
    113115
    114116    def test_freq2note_above(self):
     
    120122        self.assertEqual("A4", freq2note(439))
    121123
    122 class note2freq_simple_test(unittest.TestCase):
     124class note2freq_simple_test(TestCase):
    123125
    124126    def test_note2freq(self):
     
    134136
    135137if __name__ == '__main__':
    136     import nose2
    137     nose2.main()
     138    from unittest import main
     139    main()
Note: See TracChangeset for help on using the changeset viewer.