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