Changeset 38592a6


Ignore:
Timestamp:
Nov 1, 2018, 10:30:57 PM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
Children:
4c1eff4
Parents:
98972b9
Message:

[tests] use _tools in test_mfcc

Location:
python/tests
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • python/tests/test_mfcc.py

    r98972b9 r38592a6  
    11#! /usr/bin/env python
    22
    3 from nose2 import main
    4 from nose2.tools import params
     3from ._tools import parametrize, assert_raises
    54from numpy import random, count_nonzero
    65from numpy.testing import TestCase
     
    1615new_deflts = [1024, 40, 13, 44100]
    1716
    18 class aubio_mfcc(TestCase):
     17class 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
    4133class aubio_mfcc_wrong_params(TestCase):
     
    8375
    8476
    85 class aubio_mfcc_all_parameters(TestCase):
     77class Test_aubio_mfcc_all_parameters:
    8678
    87     @params(
     79    run_values = [
    8880            (2048, 40, 13, 44100),
    8981            (1024, 40, 13, 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 "
     
    112107
    113108if __name__ == '__main__':
     109    from unittest import main
    114110    main()
Note: See TracChangeset for help on using the changeset viewer.