Changeset 51b5f9c


Ignore:
Timestamp:
Dec 23, 2018, 5:50:07 AM (5 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:
b4445fb
Parents:
cd46892
Message:

[tests] check resampling a source raises a warning when expected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_source.py

    rcd46892 r51b5f9c  
    44from numpy.testing import TestCase, assert_equal
    55from aubio import source
    6 from utils import list_all_sounds
     6from utils import list_all_sounds, parse_file_samplerate
    77import unittest
    8 from _tools import parametrize, assert_raises, assert_equal, skipTest
     8from _tools import assert_raises, assert_equal, assert_warns
     9from _tools import parametrize, skipTest
    910
    1011list_of_sounds = list_all_sounds('sounds')
     
    2324
    2425_debug = False
     26
    2527
    2628class Test_aubio_source_test_case(TestCase):
     
    7577    @parametrize('hop_size, samplerate, soundfile', all_params)
    7678    def test_samplerate_hopsize(self, hop_size, samplerate, soundfile):
     79        orig_samplerate = parse_file_samplerate(soundfile)
    7780        try:
    78             f = source(soundfile, samplerate, hop_size)
     81            if orig_samplerate is not None and orig_samplerate < samplerate:
     82                # upsampling should emit a warning
     83                with assert_warns(UserWarning):
     84                    f = source(soundfile, samplerate, hop_size)
     85            else:
     86                f = source(soundfile, samplerate, hop_size)
    7987        except RuntimeError as e:
    8088            err_msg = 'failed opening with hop_s={:d}, samplerate={:d} ({:s})'
Note: See TracChangeset for help on using the changeset viewer.