History

[tests] use _tools in test_midi2note

Paul Brossier committed 8 years ago

Commit 4c1eff41 parent 38592a61 file · +11 −12Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/tests/test_midi2note.py+11−12
@@ -2,8 +2,7 @@ · 1 unmodified line
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3 3
4from aubio import midi2note4from aubio import midi2note
5from nose2.tools import params5from ._tools import parametrize, assert_raises
6import unittest
7 6
8list_of_known_midis = (7list_of_known_midis = (
9 ( 0, 'C-1' ),8 ( 0, 'C-1' ),
@@ -15,31 +14,31 @@ list_of_known_midis = ( · 5 unmodified lines
15 ( 127, 'G9' ),14 ( 127, 'G9' ),
16 )15 )
17 16
18class midi2note_good_values(unittest.TestCase):17class Test_midi2note_good_values:
19 18
20 @params(*list_of_known_midis)19 @parametrize('midi, note', list_of_known_midis)
21 def test_midi2note_known_values(self, midi, note):20 def test_midi2note_known_values(self, midi, note):
22 " known values are correctly converted "21 " known values are correctly converted "
23 self.assertEqual ( midi2note(midi), note )22 assert midi2note(midi) == (note)
24 23
25class midi2note_wrong_values(unittest.TestCase):24class Test_midi2note_wrong_values:
26 25
27 def test_midi2note_negative_value(self):26 def test_midi2note_negative_value(self):
28 " fails when passed a negative value "27 " fails when passed a negative value "
29 self.assertRaises(ValueError, midi2note, -2)28 assert_raises(ValueError, midi2note, -2)
30 29
31 def test_midi2note_large(self):30 def test_midi2note_large(self):
32 " fails when passed a value greater than 127 "31 " fails when passed a value greater than 127 "
33 self.assertRaises(ValueError, midi2note, 128)32 assert_raises(ValueError, midi2note, 128)
34 33
35 def test_midi2note_floating_value(self):34 def test_midi2note_floating_value(self):
36 " fails when passed a floating point "35 " fails when passed a floating point "
37 self.assertRaises(TypeError, midi2note, 69.2)36 assert_raises(TypeError, midi2note, 69.2)
38 37
39 def test_midi2note_character_value(self):38 def test_midi2note_character_value(self):
40 " fails when passed a value that can not be transformed to integer "39 " fails when passed a value that can not be transformed to integer "
41 self.assertRaises(TypeError, midi2note, "a")40 assert_raises(TypeError, midi2note, "a")
42 41
43if __name__ == '__main__':42if __name__ == '__main__':
44 import nose243 from unittest import main
45 nose2.main()44 main()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t