_debug = False
-class Test_aubio_source_test_case:
+class Test_aubio_source_test_case(TestCase):
- @parametrize('filename', list_of_sounds)
- def test_close_file(self, filename):
+ def setUp(self):
+ if not default_test_sound:
+ skipTest(no_sounds_msg)
+
+ def test_close_file(self):
samplerate = 0 # use native samplerate
hop_size = 256
- f = source(filename, samplerate, hop_size)
+ f = source(default_test_sound, samplerate, hop_size)
f.close()
- @parametrize('filename', list_of_sounds)
- def test_close_file_twice(self, filename):
+ def test_close_file_twice(self):
samplerate = 0 # use native samplerate
hop_size = 256
- f = source(filename, samplerate, hop_size)
+ f = source(default_test_sound, samplerate, hop_size)
f.close()
f.close()
-class Test_aubio_source_read:
+ def test_read_after_close(self):
+ samplerate = 0 # use native samplerate
+ hop_size = 256
+ f = source(default_test_sound, samplerate, hop_size)
+ read, frames = f()
+ f.close()
+ with assert_raises(RuntimeError):
+ read, frames = f()
+ with assert_raises(RuntimeError):
+ read, frames = f.do_multi()
+
+
+class Test_aubio_source_read(object):
def read_from_source(self, f):
total_frames = 0
read_frames = self.read_from_source(f)
if 'f_' in soundfile and samplerate == 0:
import re
- f = re.compile('.*_\([0:9]*f\)_.*')
+ f = re.compile(r'.*_\([0:9]*f\)_.*')
match_f = re.findall('([0-9]*)f_', soundfile)
if len(match_f) == 1:
expected_frames = int(match_f[0])
assert_equal (duration, total_frames)
-class Test_aubio_source_wrong_params:
+class Test_aubio_source_wrong_params(object):
def test_wrong_file(self):
with assert_raises(RuntimeError):
print (result_str.format(*result_params))
return total_frames
-class Test_aubio_source_with:
+class Test_aubio_source_with(object):
@parametrize('filename', list_of_sounds)
def test_read_from_mono(self, filename):
assert_equal(total_frames, input_source.duration)
if __name__ == '__main__':
- import sys, pytest
- pytest.main(sys.argv)
+ from _tools import run_module_suite
+ run_module_suite()