Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -3,7 +3,8 @@ · 2 unmodified lines | |||
| 3 | from numpy.testing import TestCase | 3 | from numpy.testing import TestCase |
| 4 | from aubio import fvec, source, sink | 4 | from aubio import fvec, source, sink |
| 5 | from utils import list_all_sounds, get_tmp_sink_path, del_tmp_sink_path | 5 | 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 | ||
| 7 | 8 | ||
| 8 | list_of_sounds = list_all_sounds('sounds') | 9 | list_of_sounds = list_all_sounds('sounds') |
| 9 | samplerates = [0, 44100, 8000, 32000] | 10 | samplerates = [0, 44100, 8000, 32000] |
| @@ -60,8 +61,14 @@ class Test_aubio_sink(object): · 50 unmodified lines | |||
| 60 | 61 | ||
| 61 | @parametrize('hop_size, samplerate, path', all_params) | 62 | @parametrize('hop_size, samplerate, path', all_params) |
| 62 | def test_read_and_write(self, hop_size, samplerate, path): | 63 | def test_read_and_write(self, hop_size, samplerate, path): |
| 64 | orig_samplerate = parse_file_samplerate(soundfile) | ||
| 63 | try: | 65 | 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) | ||
| 65 | except RuntimeError as e: | 72 | except RuntimeError as e: |
| 66 | err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})' | 73 | err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})' |
| 67 | skipTest(err_msg.format(str(e), hop_size, samplerate)) | 74 | skipTest(err_msg.format(str(e), hop_size, samplerate)) |
| @@ -78,8 +85,14 @@ class Test_aubio_sink(object): · 10 unmodified lines | |||
| 78 | 85 | ||
| 79 | @parametrize('hop_size, samplerate, path', all_params) | 86 | @parametrize('hop_size, samplerate, path', all_params) |
| 80 | def test_read_and_write_multi(self, hop_size, samplerate, path): | 87 | def test_read_and_write_multi(self, hop_size, samplerate, path): |
| 88 | orig_samplerate = parse_file_samplerate(soundfile) | ||
| 81 | try: | 89 | 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) | ||
| 83 | except RuntimeError as e: | 96 | except RuntimeError as e: |
| 84 | err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})' | 97 | err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})' |
| 85 | skipTest(err_msg.format(str(e), hop_size, samplerate)) | 98 | skipTest(err_msg.format(str(e), hop_size, samplerate)) |