Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -4,8 +4,8 @@ · 3 unmodified lines | ||
| 4 | 4 | from __future__ import unicode_literals |
| 5 | 5 | |
| 6 | 6 | from aubio import note2midi, freq2note, note2freq, float_type |
| 7 | −from nose2.tools import params | |
| 8 | −import unittest | |
| 7 | +from numpy.testing import TestCase | |
| 8 | +from ._tools import parametrize, assert_raises | |
| 9 | 9 | |
| 10 | 10 | list_of_known_notes = ( |
| 11 | 11 | ( 'C-1', 0 ), |
| @@ -44,29 +44,29 @@ list_of_unknown_notes = ( · 32 unmodified lines | ||
| 44 | 44 | ( '2' ), |
| 45 | 45 | ) |
| 46 | 46 | |
| 47 | −class note2midi_good_values(unittest.TestCase): | |
| 47 | +class Test_note2midi_good_values: | |
| 48 | 48 | |
| 49 | − @params(*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 | − @params(*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 |
| 61 | 61 | strfmt = "len(u'\\U0001D12A') != 1, excpected decoding failure | {:s} | {:s} {:s}" |
| 62 | 62 | strres = strfmt.format(e, sys.platform, sys.version) |
| 63 | 63 | # happens with: darwin 2.7.10, windows 2.7.12 |
| 64 | 64 | 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") | |
| 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): |
| 72 | 72 | " fails when passed only one character" |
| @@ -104,12 +104,14 @@ class note2midi_wrong_values(unittest.TestCase): · 31 unmodified lines | ||
| 104 | 104 | " fails when passed a note with a note name longer than expected" |
| 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): |
| 115 | 117 | " make sure freq2note(441) == A4 " |
| @@ -119,7 +121,7 @@ class freq2note_simple_test(unittest.TestCase): · 3 unmodified lines | ||
| 119 | 121 | " make sure freq2note(439) == A4 " |
| 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): |
| 125 | 127 | " make sure note2freq('A3') == 220" |
| @@ -133,5 +135,5 @@ class note2freq_simple_test(unittest.TestCase): · 7 unmodified lines | ||
| 133 | 135 | self.assertLess(abs(note2freq("A4")-440), 1.e-12) |
| 134 | 136 | |
| 135 | 137 | if __name__ == '__main__': |
| 136 | − import nose2 | |
| 137 | − nose2.main() | |
| 138 | + from unittest import main | |
| 139 | + main() | |