History

[tests] use _tools in test_mfcc

Paul Brossier committed 8 years ago

Commit 38592a61 parent 98972b92 files · +16 −20Browse files

Showing the changes to python/tests (2 of 2 files). Show all

Unified · Split

2 files
  1. python/tests/_tools.py +0 −0
  2. python/tests/test_mfcc.py +16 −20
python/tests/_tools.pyrenamed from python/tests/checks.py+0−0

File renamed without changes.

python/tests/test_mfcc.py+16−20
@@ -1,7 +1,6 @@
11 #! /usr/bin/env python
22
3−from nose2 import main
4−from nose2.tools import params
3+from ._tools import parametrize, assert_raises
54 from numpy import random, count_nonzero
65 from numpy.testing import TestCase
76 from aubio import mfcc, cvec, float_type
@@ -15,28 +14,21 @@ samplerate = 44100 · 7 unmodified lines
1514 new_params = ['buf_size', 'n_filters', 'n_coeffs', 'samplerate']
1615 new_deflts = [1024, 40, 13, 44100]
1716
18−class aubio_mfcc(TestCase):
17+class Test_aubio_mfcc:
1918
20− def setUp(self):
21− self.o = mfcc()
19+ members_args = 'name'
2220
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)
3022 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)):
3325 setattr(o, name, 0)
3426
35− @params(*zip(new_params, new_deflts))
27+ @parametrize('name, expected', zip(new_params, new_deflts))
3628 def test_default_param(self, name, expected):
3729 """ 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
4032
4133 class aubio_mfcc_wrong_params(TestCase):
4234
@@ -82,9 +74,9 @@ class aubio_mfcc_compute(TestCase): · 39 unmodified lines
8274 #print coeffs
8375
8476
85−class aubio_mfcc_all_parameters(TestCase):
77+class Test_aubio_mfcc_all_parameters:
8678
87− @params(
79+ run_values = [
8880 (2048, 40, 13, 44100),
8981 (1024, 40, 13, 44100),
9082 (512, 40, 13, 44100),
@@ -100,7 +92,10 @@ class aubio_mfcc_all_parameters(TestCase): · 9 unmodified lines
10092 #(1024, 30, 20, 44100),
10193 (1024, 40, 40, 44100),
10294 (1024, 40, 3, 44100),
103− )
95+ ]
96+ run_args = ['buf_size', 'n_filters', 'n_coeffs', 'samplerate']
97+
98+ @parametrize(run_args, run_values)
10499 def test_run_with_params(self, buf_size, n_filters, n_coeffs, samplerate):
105100 " check mfcc can run with reasonable parameters "
106101 o = mfcc(buf_size, n_filters, n_coeffs, samplerate)
@@ -111,4 +106,5 @@ class aubio_mfcc_all_parameters(TestCase): · 4 unmodified lines
111106 #print coeffs
112107
113108 if __name__ == '__main__':
109+ from unittest import main
114110 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