Showing the changes to python (2 of 2 files). Show all
Unified · Split
File renamed without changes.
| @@ -1,7 +1,6 @@ | |||
| 1 | #! /usr/bin/env python | 1 | #! /usr/bin/env python |
| 2 | 2 | ||
| 3 | from nose2 import main | 3 | from ._tools import parametrize, assert_raises |
| 4 | from nose2.tools import params | ||
| 5 | from numpy import random, count_nonzero | 4 | from numpy import random, count_nonzero |
| 6 | from numpy.testing import TestCase | 5 | from numpy.testing import TestCase |
| 7 | from aubio import mfcc, cvec, float_type | 6 | from aubio import mfcc, cvec, float_type |
| @@ -15,28 +14,21 @@ samplerate = 44100 · 7 unmodified lines | |||
| 15 | new_params = ['buf_size', 'n_filters', 'n_coeffs', 'samplerate'] | 14 | new_params = ['buf_size', 'n_filters', 'n_coeffs', 'samplerate'] |
| 16 | new_deflts = [1024, 40, 13, 44100] | 15 | new_deflts = [1024, 40, 13, 44100] |
| 17 | 16 | ||
| 18 | class aubio_mfcc(TestCase): | 17 | class Test_aubio_mfcc: |
| 19 | 18 | ||
| 20 | def setUp(self): | 19 | members_args = 'name' |
| 21 | self.o = mfcc() | ||
| 22 | 20 | ||
| 23 | def test_default_creation(self): | 21 | @parametrize(members_args, new_params) |
| 24 | pass | ||
| 25 | |||
| 26 | def test_delete(self): | ||
| 27 | del self.o | ||
| 28 | |||
| 29 | @params(*new_params) | ||
| 30 | def test_read_only_member(self, name): | 22 | def test_read_only_member(self, name): |
| 31 | o = self.o | 23 | o = mfcc() |
| 32 | with self.assertRaises((TypeError, AttributeError)): | 24 | with assert_raises((TypeError, AttributeError)): |
| 33 | setattr(o, name, 0) | 25 | setattr(o, name, 0) |
| 34 | 26 | ||
| 35 | @params(*zip(new_params, new_deflts)) | 27 | @parametrize('name, expected', zip(new_params, new_deflts)) |
| 36 | def test_default_param(self, name, expected): | 28 | def test_default_param(self, name, expected): |
| 37 | """ test mfcc.{:s} = {:d} """.format(name, expected) | 29 | """ test mfcc.{:s} = {:d} """.format(name, expected) |
| 38 | o = self.o | 30 | o = mfcc() |
| 39 | self.assertEqual( getattr(o, name), expected) | 31 | assert getattr(o, name) == expected |
| 40 | 32 | ||
| 41 | class aubio_mfcc_wrong_params(TestCase): | 33 | class aubio_mfcc_wrong_params(TestCase): |
| 42 | 34 | ||
| @@ -82,9 +74,9 @@ class aubio_mfcc_compute(TestCase): · 39 unmodified lines | |||
| 82 | #print coeffs | 74 | #print coeffs |
| 83 | 75 | ||
| 84 | 76 | ||
| 85 | class aubio_mfcc_all_parameters(TestCase): | 77 | class Test_aubio_mfcc_all_parameters: |
| 86 | 78 | ||
| 87 | @params( | 79 | run_values = [ |
| 88 | (2048, 40, 13, 44100), | 80 | (2048, 40, 13, 44100), |
| 89 | (1024, 40, 13, 44100), | 81 | (1024, 40, 13, 44100), |
| 90 | (512, 40, 13, 44100), | 82 | (512, 40, 13, 44100), |
| @@ -100,7 +92,10 @@ class aubio_mfcc_all_parameters(TestCase): · 9 unmodified lines | |||
| 100 | #(1024, 30, 20, 44100), | 92 | #(1024, 30, 20, 44100), |
| 101 | (1024, 40, 40, 44100), | 93 | (1024, 40, 40, 44100), |
| 102 | (1024, 40, 3, 44100), | 94 | (1024, 40, 3, 44100), |
| 103 | ) | 95 | ] |
| 96 | run_args = ['buf_size', 'n_filters', 'n_coeffs', 'samplerate'] | ||
| 97 | |||
| 98 | @parametrize(run_args, run_values) | ||
| 104 | def test_run_with_params(self, buf_size, n_filters, n_coeffs, samplerate): | 99 | def test_run_with_params(self, buf_size, n_filters, n_coeffs, samplerate): |
| 105 | " check mfcc can run with reasonable parameters " | 100 | " check mfcc can run with reasonable parameters " |
| 106 | o = mfcc(buf_size, n_filters, n_coeffs, samplerate) | 101 | o = mfcc(buf_size, n_filters, n_coeffs, samplerate) |
| @@ -111,4 +106,5 @@ class aubio_mfcc_all_parameters(TestCase): · 4 unmodified lines | |||
| 111 | #print coeffs | 106 | #print coeffs |
| 112 | 107 | ||
| 113 | if __name__ == '__main__': | 108 | if __name__ == '__main__': |
| 109 | from unittest import main | ||
| 114 | main() | 110 | main() |