Mercurial > hg > auditok
changeset 134:0125bd4ee317
Add tests for to_file with wave data
author | Amine Sehili <amine.sehili@gmail.com> |
---|---|
date | Mon, 11 Feb 2019 20:19:46 +0100 |
parents | d8ae412e5aa8 |
children | 4d290493f590 |
files | tests/test_io.py |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_io.py Sun Feb 10 21:21:19 2019 +0100 +++ b/tests/test_io.py Mon Feb 11 20:19:46 2019 +0100 @@ -580,3 +580,22 @@ _save_raw(filename, data) self.assertTrue(filecmp.cmp(filename, exp_filename, shallow=False)) tmpdir.cleanup() + + @genty_dataset( + wav_with_audio_format=("audio", "wav"), + wav_with_extension=("audio.wav", None), + wav_with_audio_format_and_extension=("audio.mp3", "wav"), + wave_with_audio_format=("audio", "wave"), + wave_with_extension=("audio.wave", None), + wave_with_audio_format_and_extension=("audio.mp3", "wave"), + ) + def test_to_file_wav(self, filename, audio_format): + exp_filename = "tests/data/test_16KHZ_mono_400Hz.wav" + tmpdir = TemporaryDirectory() + filename = os.path.join(tmpdir.name, filename) + data = _array_to_bytes(PURE_TONE_DICT[400]) + _save_wave( + filename, data, sampling_rate=16000, sample_width=2, channels=1 + ) + self.assertTrue(filecmp.cmp(filename, exp_filename, shallow=False)) + tmpdir.cleanup()