Mercurial > hg > auditok
changeset 140:b5a2da2e61f9
Add test for to_file with compressed audio data
author | Amine Sehili <amine.sehili@gmail.com> |
---|---|
date | Sat, 16 Feb 2019 18:25:26 +0100 |
parents | 01ef241d17e6 |
children | 995a568e6eff |
files | auditok/io.py tests/test_io.py |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/auditok/io.py Fri Feb 15 21:47:42 2019 +0100 +++ b/auditok/io.py Sat Feb 16 18:25:26 2019 +0100 @@ -961,7 +961,7 @@ _save_wave(data, file, sampling_rate, sample_width, channels) elif _WITH_PYDUB: _save_with_pydub( - file, data, audio_format, sampling_rate, sample_width, channels + data, file, audio_format, sampling_rate, sample_width, channels ) else: err_message = "cannot write file format {} (file name: {})"
--- a/tests/test_io.py Fri Feb 15 21:47:42 2019 +0100 +++ b/tests/test_io.py Sat Feb 16 18:25:26 2019 +0100 @@ -634,3 +634,14 @@ with patch("auditok.io._WITH_PYDUB", False): with self.assertRaises(AudioIOError): to_file("audio", b"", "mp3") + + @patch("auditok.io._WITH_PYDUB", True) + @genty_dataset( + ogg_with_extension=("audio.ogg", None), + ogg_with_audio_format=("audio", "ogg"), + ogg_format_with_wrong_extension=("audio.wav", "ogg"), + ) + def test_to_file_compressed(self, filename, audio_format, *mocks): + with patch("auditok.io.AudioSegment.export") as export: + to_file(b"\0\0", filename, audio_format, **AUDIO_PARAMS_SHORT) + self.assertTrue(export.called)