projects
/
aubio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
51b5f9c
)
[tests] also capture expected source warnings in test_sink
author
Paul Brossier
<piem@piem.org>
Sun, 23 Dec 2018 04:50:36 +0000
(
05:50
+0100)
committer
Paul Brossier
<piem@piem.org>
Sun, 23 Dec 2018 04:50:36 +0000
(
05:50
+0100)
python/tests/test_sink.py
patch
|
blob
|
history
diff --git
a/python/tests/test_sink.py
b/python/tests/test_sink.py
index
b9f9c56
..
9516fe4
100755
(executable)
--- a/
python/tests/test_sink.py
+++ b/
python/tests/test_sink.py
@@
-3,7
+3,8
@@
from numpy.testing import TestCase
from aubio import fvec, source, sink
from utils import list_all_sounds, get_tmp_sink_path, del_tmp_sink_path
from numpy.testing import TestCase
from aubio import fvec, source, sink
from utils import list_all_sounds, get_tmp_sink_path, del_tmp_sink_path
-from _tools import parametrize, skipTest, assert_raises
+from utils import parse_file_samplerate
+from _tools import parametrize, skipTest, assert_raises, assert_warns
list_of_sounds = list_all_sounds('sounds')
samplerates = [0, 44100, 8000, 32000]
list_of_sounds = list_all_sounds('sounds')
samplerates = [0, 44100, 8000, 32000]
@@
-60,8
+61,14
@@
class Test_aubio_sink(object):
@parametrize('hop_size, samplerate, path', all_params)
def test_read_and_write(self, hop_size, samplerate, path):
@parametrize('hop_size, samplerate, path', all_params)
def test_read_and_write(self, hop_size, samplerate, path):
+ orig_samplerate = parse_file_samplerate(soundfile)
try:
try:
- f = source(path, samplerate, hop_size)
+ if orig_samplerate is not None and orig_samplerate < samplerate:
+ # upsampling should emit a warning
+ with assert_warns(UserWarning):
+ f = source(soundfile, samplerate, hop_size)
+ else:
+ f = source(soundfile, samplerate, hop_size)
except RuntimeError as e:
err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})'
skipTest(err_msg.format(str(e), hop_size, samplerate))
except RuntimeError as e:
err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})'
skipTest(err_msg.format(str(e), hop_size, samplerate))
@@
-78,8
+85,14
@@
class Test_aubio_sink(object):
@parametrize('hop_size, samplerate, path', all_params)
def test_read_and_write_multi(self, hop_size, samplerate, path):
@parametrize('hop_size, samplerate, path', all_params)
def test_read_and_write_multi(self, hop_size, samplerate, path):
+ orig_samplerate = parse_file_samplerate(soundfile)
try:
try:
- f = source(path, samplerate, hop_size)
+ if orig_samplerate is not None and orig_samplerate < samplerate:
+ # upsampling should emit a warning
+ with assert_warns(UserWarning):
+ f = source(soundfile, samplerate, hop_size)
+ else:
+ f = source(soundfile, samplerate, hop_size)
except RuntimeError as e:
err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})'
skipTest(err_msg.format(str(e), hop_size, samplerate))
except RuntimeError as e:
err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})'
skipTest(err_msg.format(str(e), hop_size, samplerate))