Mercurial > hg > auditok
changeset 133:d8ae412e5aa8
Add tests for to_file with raw data
author | Amine Sehili <amine.sehili@gmail.com> |
---|---|
date | Sun, 10 Feb 2019 21:21:19 +0100 |
parents | a9d74315f2ee |
children | 0125bd4ee317 |
files | tests/test_io.py |
diffstat | 1 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_io.py Sat Feb 09 18:42:14 2019 +0100 +++ b/tests/test_io.py Sun Feb 10 21:21:19 2019 +0100 @@ -2,7 +2,7 @@ import sys import math from array import array -from tempfile import NamedTemporaryFile +from tempfile import NamedTemporaryFile, TemporaryDirectory import filecmp from unittest import TestCase from genty import genty, genty_dataset @@ -565,3 +565,18 @@ del params[missing_param] srate, swidth, channels, _ = _get_audio_parameters(params) _save_wave("audio", b"\0\0", srate, swidth, channels) + + @genty_dataset( + raw_with_audio_format=("audio", "raw"), + raw_with_extension=("audio.raw", None), + raw_with_audio_format_and_extension=("audio.mp3", "raw"), + raw_no_audio_format_nor_extension=("audio", None), + ) + def test_to_file_raw(self, filename, audio_format): + exp_filename = "tests/data/test_16KHZ_mono_400Hz.raw" + tmpdir = TemporaryDirectory() + filename = os.path.join(tmpdir.name, filename) + data = _array_to_bytes(PURE_TONE_DICT[400]) + _save_raw(filename, data) + self.assertTrue(filecmp.cmp(filename, exp_filename, shallow=False)) + tmpdir.cleanup()