Mercurial > hg > auditok
changeset 111:85fbaf34c88b
Add tests for _save_raw
author | Amine Sehili <amine.sehili@gmail.com> |
---|---|
date | Wed, 16 Jan 2019 20:54:50 +0100 |
parents | 950cfd5ba9f2 |
children | e5813b709634 |
files | tests/test_io.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_io.py Tue Jan 15 22:08:04 2019 +0100 +++ b/tests/test_io.py Wed Jan 16 20:54:50 2019 +0100 @@ -10,6 +10,7 @@ DATA_FORMAT, AudioParameterError, check_audio_data, + _save_raw, _save_wave, ) @@ -96,6 +97,20 @@ self.assertIsNone(check_audio_data(data, sample_width, channels)) @genty_dataset( + mono=("mono_400Hz.raw", (400,)), + three_channel=("3channel_400-800-1600Hz.raw", (400, 800, 1600)), + ) + def test_save_raw(self, filename, frequencies): + filename = "tests/data/test_16KHZ_{}".format(filename) + sample_width = 2 + fmt = DATA_FORMAT[sample_width] + mono_channels = [PURE_TONE_DICT[freq] for freq in frequencies] + data = _array_to_bytes(array(fmt, _sample_generator(*mono_channels))) + tmpfile = NamedTemporaryFile() + _save_raw(tmpfile.name, data) + self.assertTrue(filecmp.cmp(tmpfile.name, filename, shallow=False)) + + @genty_dataset( mono=("mono_400Hz.wav", (400,)), three_channel=("3channel_400-800-1600Hz.wav", (400, 800, 1600)), )