Changeset b4445fb


Ignore:
Timestamp:
Dec 23, 2018, 5:50:36 AM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
Children:
c1c3a99
Parents:
51b5f9c
Message:

[tests] also capture expected source warnings in test_sink

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_sink.py

    r51b5f9c rb4445fb  
    44from aubio import fvec, source, sink
    55from utils import list_all_sounds, get_tmp_sink_path, del_tmp_sink_path
    6 from _tools import parametrize, skipTest, assert_raises
     6from utils import parse_file_samplerate
     7from _tools import parametrize, skipTest, assert_raises, assert_warns
    78
    89list_of_sounds = list_all_sounds('sounds')
     
    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})'
     
    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})'
Note: See TracChangeset for help on using the changeset viewer.