diff --git a/.gitignore b/.gitignore index 7a928b4..b6d1948 100644 --- a/.gitignore +++ b/.gitignore @@ -65,4 +65,8 @@ target/ #Ipython Notebook .ipynb_checkpoints -**/noise.prof \ No newline at end of file +**/noise.prof + +# IDE Stuff +.idea/ +.vscode/ \ No newline at end of file diff --git a/sox/transform.py b/sox/transform.py index 83e0506..f067f45 100644 --- a/sox/transform.py +++ b/sox/transform.py @@ -836,6 +836,9 @@ def build_array(self, 'append_comments': True, } + if self.output_format.get('file_type') is not None: + output_format['file_type'] = self.output_format['file_type'] + if self.output_format.get('rate') is not None: output_format['rate'] = self.output_format['rate'] diff --git a/tests/test_transform.py b/tests/test_transform.py index 14a99f8..5bef3dd 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -1,6 +1,7 @@ from pathlib import Path import os import unittest +from unittest.mock import patch from sox import transform, file_info from sox.core import SoxError @@ -676,6 +677,7 @@ def test_append_comments_invalid(self): with self.assertRaises(ValueError): self.tfm._output_format_args({'append_comments': None}) + class TestTransformerBuild(unittest.TestCase): def setUp(self): self.tfm = new_transformer() @@ -814,6 +816,17 @@ def test_bits_invalid(self): with self.assertRaises(ValueError): self.tfm.build_array(INPUT_FILE) + def test_output_file_type(self): + with patch("sox.transform.sox") as patched_sox_call: + patched_sox_call.return_value = 0, b"", b"" + self.tfm.build_array(INPUT_FILE) + sox_cmd_args, src_array, decode_out_with_utf = patched_sox_call.call_args[0] + self.assertIn("raw", sox_cmd_args) # default output file type + self.tfm.set_output_format(file_type="gsm") + self.tfm.build_array(INPUT_FILE) + sox_cmd_args, src_array, decode_out_with_utf = patched_sox_call.call_args[0] + self.assertIn("gsm", sox_cmd_args) # desired output file type + class TestTransformerClearEffects(unittest.TestCase):