Improve error messages for 24-bit WAV files (#443)

pull/451/head
kitten 2023-11-27 19:32:15 -08:00 zatwierdzone przez GitHub
rodzic e6347dfe39
commit cb215cdb1c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 15 dodań i 2 usunięć

Wyświetl plik

@ -482,8 +482,7 @@ def _read_data_chunk(fid, format_tag, channels, bit_depth, is_big_endian,
shape=(n_samples,))
fid.seek(start + size)
else:
raise ValueError("mmap=True not compatible with "
f"{bytes_per_sample}-byte container size.")
raise ValueError(f"{bytes_per_sample * 8}-bit WAV is not supported.")
_handle_pad_byte(fid, size)

Wyświetl plik

@ -50,6 +50,20 @@ def test_incomplete_wav_chunk():
data = wave[:]
def test_24_bit_wav():
"""Tests that WAV files exported from foobar2000 can be loaded properly,
without a `ValueError: Incomplete wav chunk.` exception being raised."""
try:
wave = Wave(prefix + "s24-impulse1000.wav")
except ValueError as e:
assert e.args == (f"24-bit WAV is not supported.",)
except Exception as e:
pytest.fail(f"Unexpected exception {e}")
else:
pytest.fail(f"Expected exception loading 24-bit wav, none found")
# Stereo tests