History

[tests] also capture expected source warnings in test_sink

Paul Brossier committed 7 years ago

Commit b4445fb1 parent 51b5f9c1 file · +16 −3Browse files

Showing the changes to python/tests (1 of 1 file). Show all

Unified · Split

python/tests/test_sink.py+16−3
@@ -3,7 +3,8 @@ · 2 unmodified lines
33 from numpy.testing import TestCase
44 from aubio import fvec, source, sink
55 from utils import list_all_sounds, get_tmp_sink_path, del_tmp_sink_path
6−from _tools import parametrize, skipTest, assert_raises
6+from utils import parse_file_samplerate
7+from _tools import parametrize, skipTest, assert_raises, assert_warns
78
89 list_of_sounds = list_all_sounds('sounds')
910 samplerates = [0, 44100, 8000, 32000]
@@ -60,8 +61,14 @@ class Test_aubio_sink(object): · 50 unmodified lines
6061
6162 @parametrize('hop_size, samplerate, path', all_params)
6263 def test_read_and_write(self, hop_size, samplerate, path):
64+ orig_samplerate = parse_file_samplerate(soundfile)
6365 try:
64− f = source(path, samplerate, hop_size)
66+ if orig_samplerate is not None and orig_samplerate < samplerate:
67+ # upsampling should emit a warning
68+ with assert_warns(UserWarning):
69+ f = source(soundfile, samplerate, hop_size)
70+ else:
71+ f = source(soundfile, samplerate, hop_size)
6572 except RuntimeError as e:
6673 err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})'
6774 skipTest(err_msg.format(str(e), hop_size, samplerate))
@@ -78,8 +85,14 @@ class Test_aubio_sink(object): · 10 unmodified lines
7885
7986 @parametrize('hop_size, samplerate, path', all_params)
8087 def test_read_and_write_multi(self, hop_size, samplerate, path):
88+ orig_samplerate = parse_file_samplerate(soundfile)
8189 try:
82− f = source(path, samplerate, hop_size)
90+ if orig_samplerate is not None and orig_samplerate < samplerate:
91+ # upsampling should emit a warning
92+ with assert_warns(UserWarning):
93+ f = source(soundfile, samplerate, hop_size)
94+ else:
95+ f = source(soundfile, samplerate, hop_size)
8396 except RuntimeError as e:
8497 err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})'
8598 skipTest(err_msg.format(str(e), hop_size, samplerate))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t