From: Paul Brossier Date: Wed, 30 Nov 2016 17:39:41 +0000 (+0100) Subject: python/tests/test_source.py: remove fragile brownnoise test, check duration on short... X-Git-Tag: 0.4.4~120 X-Git-Url: https://git.aubio.org/?p=aubio.git;a=commitdiff_plain;h=8a49bb9e88d0d1a0b551fb1d383ee6cf29b7dc00 python/tests/test_source.py: remove fragile brownnoise test, check duration on short files --- diff --git a/python/tests/test_source.py b/python/tests/test_source.py index 19f403f2..467290f4 100755 --- a/python/tests/test_source.py +++ b/python/tests/test_source.py @@ -56,8 +56,6 @@ class aubio_source_read_test_case(aubio_source_test_case_base): total_frames += read if read < f.hop_size: assert_equal(samples[read:], 0) - if 'brownnoise' in f.uri: - self.assertEquals(np.count_nonzero(samples[:read]), read) break #result_str = "read {:.2f}s ({:d} frames in {:d} blocks at {:d}Hz) from {:s}" #result_params = total_frames / float(f.samplerate), total_frames, total_frames//f.hop_size, f.samplerate, f.uri @@ -71,7 +69,14 @@ class aubio_source_read_test_case(aubio_source_test_case_base): except RuntimeError as e: self.skipTest('failed opening with hop_s = {:d}, samplerate = {:d} ({:s})'.format(hop_size, samplerate, str(e))) assert f.samplerate != 0 - self.read_from_source(f) + read_frames = self.read_from_source(f) + if 'f_' in soundfile and samplerate == 0: + import re + f = re.compile('.*_\([0:9]*f\)_.*') + match_f = re.findall('([0-9]*)f_', soundfile) + if len(match_f) == 1: + expected_frames = int(match_f[0]) + self.assertEqual(expected_frames, read_frames) @params(*list_of_sounds) def test_samplerate_none(self, p): @@ -158,8 +163,6 @@ class aubio_source_readmulti_test_case(aubio_source_read_test_case): total_frames += read if read < f.hop_size: assert_equal(samples[:,read:], 0) - if 'brownnoise' in f.uri: - self.assertEquals(np.count_nonzero(samples[:,:read]), read) break #result_str = "read {:.2f}s ({:d} frames in {:d} channels and {:d} blocks at {:d}Hz) from {:s}" #result_params = total_frames / float(f.samplerate), total_frames, f.channels, int(total_frames/f.hop_size), f.samplerate, f.uri