Changeset ecd370b
- Timestamp:
- Nov 2, 2018, 12:01:54 AM (6 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_sink.py
rd4fae34 recd370b 1 1 #! /usr/bin/env python 2 2 3 from nose2 import main4 from nose2.tools import params5 3 from numpy.testing import TestCase 6 4 from 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) 5 from utils import list_all_sounds, get_tmp_sink_path, del_tmp_sink_path 6 from _tools import parametrize, skipTest, assert_raises 11 7 12 8 list_of_sounds = list_all_sounds('sounds') … … 24 20 all_params.append((hop_size, samplerate, soundfile)) 25 21 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\'') 22 class Test_aubio_sink: 31 23 32 24 def test_wrong_filename(self): 33 with self.assertRaises(RuntimeError):25 with assert_raises(RuntimeError): 34 26 sink('') 35 27 36 28 def test_wrong_samplerate(self): 37 with self.assertRaises(RuntimeError):29 with assert_raises(RuntimeError): 38 30 sink(get_tmp_sink_path(), -1) 39 31 40 32 def test_wrong_samplerate_too_large(self): 41 with self.assertRaises(RuntimeError):33 with assert_raises(RuntimeError): 42 34 sink(get_tmp_sink_path(), 1536001, 2) 43 35 44 36 def test_wrong_channels(self): 45 with self.assertRaises(RuntimeError):37 with assert_raises(RuntimeError): 46 38 sink(get_tmp_sink_path(), 44100, -1) 47 39 48 40 def test_wrong_channels_too_large(self): 49 with self.assertRaises(RuntimeError):41 with assert_raises(RuntimeError): 50 42 sink(get_tmp_sink_path(), 44100, 202020) 51 43 … … 67 59 shutil.rmtree(tmpdir) 68 60 69 @param s(*all_params)61 @parametrize('hop_size, samplerate, path', all_params) 70 62 def test_read_and_write(self, hop_size, samplerate, path): 71 72 63 try: 73 64 f = source(path, samplerate, hop_size) 74 65 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)) 76 68 if samplerate == 0: samplerate = f.samplerate 77 69 sink_path = get_tmp_sink_path() … … 85 77 del_tmp_sink_path(sink_path) 86 78 87 @param s(*all_params)79 @parametrize('hop_size, samplerate, path', all_params) 88 80 def test_read_and_write_multi(self, hop_size, samplerate, path): 89 81 try: 90 82 f = source(path, samplerate, hop_size) 91 83 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)) 93 86 if samplerate == 0: samplerate = f.samplerate 94 87 sink_path = get_tmp_sink_path() … … 126 119 127 120 if __name__ == '__main__': 128 main() 121 import pytest, sys 122 pytest.main(sys.argv)
Note: See TracChangeset
for help on using the changeset viewer.