Test to ensure no FutureWarning when determining Wave type

pull/357/head
nyanpasu64 2018-07-20 15:29:36 -07:00
rodzic 206294f5c2
commit 054ba642eb
1 zmienionych plików z 16 dodań i 6 usunięć

Wyświetl plik

@ -1,3 +1,5 @@
import warnings
import numpy as np
import pytest
@ -18,10 +20,18 @@ wave_paths = [
@pytest.mark.parametrize("wave_path", wave_paths)
def test_wave(wave_path):
wave = Wave(None, prefix + wave_path)
data = wave[:]
with warnings.catch_warnings(record=True) as w:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
# Audacity dithers <=16-bit WAV files upon export, creating a few bits of noise.
# As a result, amin(data) <= 0.
assert -0.01 < np.amin(data) <= 0
assert 0.99 < np.amax(data) <= 1
wave = Wave(None, prefix + wave_path)
data = wave[:]
# Audacity dithers <=16-bit WAV files upon export, creating a few bits of noise.
# As a result, amin(data) <= 0.
assert -0.01 < np.amin(data) <= 0
assert 0.99 < np.amax(data) <= 1
# check for FutureWarning (raised when determining wavfile type)
warns = [o for o in w if issubclass(o.category, FutureWarning)]
assert not [str(w) for w in warns]