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 (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 @@
1#! /usr/bin/env python1#! /usr/bin/env python
2 2
3from nose2 import main3from ._tools import parametrize, assert_raises
4from nose2.tools import params
5from numpy import random, count_nonzero4from numpy import random, count_nonzero
6from numpy.testing import TestCase5from numpy.testing import TestCase
7from aubio import mfcc, cvec, float_type6from aubio import mfcc, cvec, float_type
@@ -15,28 +14,21 @@ samplerate = 44100 · 7 unmodified lines
15new_params = ['buf_size', 'n_filters', 'n_coeffs', 'samplerate']14new_params = ['buf_size', 'n_filters', 'n_coeffs', 'samplerate']
16new_deflts = [1024, 40, 13, 44100]15new_deflts = [1024, 40, 13, 44100]
17 16
18class aubio_mfcc(TestCase):17class 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.o23 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.o30 o = mfcc()
39 self.assertEqual( getattr(o, name), expected)31 assert getattr(o, name) == expected
40 32
41class aubio_mfcc_wrong_params(TestCase):33class aubio_mfcc_wrong_params(TestCase):
42 34
@@ -82,9 +74,9 @@ class aubio_mfcc_compute(TestCase): · 39 unmodified lines
82 #print coeffs74 #print coeffs
83 75
84 76
85class aubio_mfcc_all_parameters(TestCase):77class 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 coeffs106 #print coeffs
112 107
113if __name__ == '__main__':108if __name__ == '__main__':
109 from unittest import main
114 main()110 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