feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change
on this file since 25d0c42 was
0b6d23d,
checked in by Paul Brossier <piem@piem.org>, 9 years ago
|
python/tests: fix most prospect warnings
|
-
Property mode set to
100755
|
File size:
1.2 KB
|
Rev | Line | |
---|
[7d89e61] | 1 | #! /usr/bin/env python |
---|
| 2 | # -*- coding: utf-8 -*- |
---|
[9ead7a9] | 3 | |
---|
| 4 | from aubio import midi2note |
---|
| 5 | import unittest |
---|
| 6 | |
---|
| 7 | list_of_known_midis = ( |
---|
| 8 | ( 0, 'C-1' ), |
---|
| 9 | ( 1, 'C#-1' ), |
---|
| 10 | ( 38, 'D2' ), |
---|
| 11 | ( 48, 'C3' ), |
---|
| 12 | ( 59, 'B3' ), |
---|
| 13 | ( 60, 'C4' ), |
---|
| 14 | ( 127, 'G9' ), |
---|
| 15 | ) |
---|
| 16 | |
---|
[7d89e61] | 17 | class midi2note_good_values(unittest.TestCase): |
---|
[9ead7a9] | 18 | |
---|
| 19 | def test_midi2note_known_values(self): |
---|
| 20 | " known values are correctly converted " |
---|
| 21 | for midi, note in list_of_known_midis: |
---|
| 22 | self.assertEqual ( midi2note(midi), note ) |
---|
| 23 | |
---|
[7d89e61] | 24 | class midi2note_wrong_values(unittest.TestCase): |
---|
[9ead7a9] | 25 | |
---|
| 26 | def test_midi2note_negative_value(self): |
---|
| 27 | " fails when passed a negative value " |
---|
| 28 | self.assertRaises(ValueError, midi2note, -2) |
---|
| 29 | |
---|
[0b6d23d] | 30 | def test_midi2note_large(self): |
---|
[9ead7a9] | 31 | " fails when passed a value greater than 127 " |
---|
| 32 | self.assertRaises(ValueError, midi2note, 128) |
---|
| 33 | |
---|
| 34 | def test_midi2note_floating_value(self): |
---|
| 35 | " fails when passed a floating point " |
---|
| 36 | self.assertRaises(TypeError, midi2note, 69.2) |
---|
| 37 | |
---|
| 38 | def test_midi2note_character_value(self): |
---|
| 39 | " fails when passed a value that can not be transformed to integer " |
---|
| 40 | self.assertRaises(TypeError, midi2note, "a") |
---|
| 41 | |
---|
| 42 | if __name__ == '__main__': |
---|
| 43 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.