Ignore:
Timestamp:
Nov 2, 2018, 12:01:54 AM (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:
ad45776
Parents:
d4fae34
Message:

[tests] update sink tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_sink.py

    rd4fae34 recd370b  
    11#! /usr/bin/env python
    22
    3 from nose2 import main
    4 from nose2.tools import params
    53from numpy.testing import TestCase
    64from aubio import fvec, source, sink
    7 from .utils import list_all_sounds, get_tmp_sink_path, del_tmp_sink_path
    8 
    9 import warnings
    10 warnings.filterwarnings('ignore', category=UserWarning, append=True)
     5from utils import list_all_sounds, get_tmp_sink_path, del_tmp_sink_path
     6from _tools import parametrize, skipTest, assert_raises
    117
    128list_of_sounds = list_all_sounds('sounds')
     
    2420            all_params.append((hop_size, samplerate, soundfile))
    2521
    26 class aubio_sink_test_case(TestCase):
    27 
    28     def setUp(self):
    29         if not len(list_of_sounds):
    30             self.skipTest('add some sound files in \'python/tests/sounds\'')
     22class Test_aubio_sink:
    3123
    3224    def test_wrong_filename(self):
    33         with self.assertRaises(RuntimeError):
     25        with assert_raises(RuntimeError):
    3426            sink('')
    3527
    3628    def test_wrong_samplerate(self):
    37         with self.assertRaises(RuntimeError):
     29        with assert_raises(RuntimeError):
    3830            sink(get_tmp_sink_path(), -1)
    3931
    4032    def test_wrong_samplerate_too_large(self):
    41         with self.assertRaises(RuntimeError):
     33        with assert_raises(RuntimeError):
    4234            sink(get_tmp_sink_path(), 1536001, 2)
    4335
    4436    def test_wrong_channels(self):
    45         with self.assertRaises(RuntimeError):
     37        with assert_raises(RuntimeError):
    4638            sink(get_tmp_sink_path(), 44100, -1)
    4739
    4840    def test_wrong_channels_too_large(self):
    49         with self.assertRaises(RuntimeError):
     41        with assert_raises(RuntimeError):
    5042            sink(get_tmp_sink_path(), 44100, 202020)
    5143
     
    6759        shutil.rmtree(tmpdir)
    6860
    69     @params(*all_params)
     61    @parametrize('hop_size, samplerate, path', all_params)
    7062    def test_read_and_write(self, hop_size, samplerate, path):
    71 
    7263        try:
    7364            f = source(path, samplerate, hop_size)
    7465        except RuntimeError as e:
    75             self.skipTest('failed opening with hop_s = {:d}, samplerate = {:d} ({:s})'.format(hop_size, samplerate, str(e)))
     66            err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})'
     67            skipTest(err_msg.format(str(e), hop_size, samplerate))
    7668        if samplerate == 0: samplerate = f.samplerate
    7769        sink_path = get_tmp_sink_path()
     
    8577        del_tmp_sink_path(sink_path)
    8678
    87     @params(*all_params)
     79    @parametrize('hop_size, samplerate, path', all_params)
    8880    def test_read_and_write_multi(self, hop_size, samplerate, path):
    8981        try:
    9082            f = source(path, samplerate, hop_size)
    9183        except RuntimeError as e:
    92             self.skipTest('failed opening with hop_s = {:d}, samplerate = {:d} ({:s})'.format(hop_size, samplerate, str(e)))
     84            err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})'
     85            skipTest(err_msg.format(str(e), hop_size, samplerate))
    9386        if samplerate == 0: samplerate = f.samplerate
    9487        sink_path = get_tmp_sink_path()
     
    126119
    127120if __name__ == '__main__':
    128     main()
     121    import pytest, sys
     122    pytest.main(sys.argv)
Note: See TracChangeset for help on using the changeset viewer.