changeset 193:b274a22c9685

Add tests for AudioRegion.save when file exists
author Amine Sehili <amine.sehili@gmail.com>
date Tue, 23 Apr 2019 18:37:22 +0100
parents 8e63fc5d1af6
children 89872ec2e30d
files auditok/core.py tests/test_core.py
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/auditok/core.py	Sun Apr 21 19:10:07 2019 +0100
+++ b/auditok/core.py	Tue Apr 23 18:37:22 2019 +0100
@@ -335,7 +335,7 @@
             sr=self.sr,
             sw=self.sw,
             ch=self.ch,
-            **audio_parameters
+            audio_parameters=audio_parameters
         )
         return file
 
--- a/tests/test_core.py	Sun Apr 21 19:10:07 2019 +0100
+++ b/tests/test_core.py	Tue Apr 23 18:37:22 2019 +0100
@@ -239,6 +239,14 @@
             filename = region.save(format)[len(tmpdir) + 1 :]
             self.assertEqual(filename, expected)
 
+    def test_save_file_exists_exception(self):
+        with TemporaryDirectory() as tmpdir:
+            filename = os.path.join(tmpdir, "output.wav")
+            open(filename, "w").close()
+            region = AudioRegion(b"0" * 160, 0, 160, 1, 1)
+            with self.assertRaises(FileExistsError):
+                region.save(filename, exists_ok=False)
+
     @genty_dataset(
         simple=(8000, 1, 1),
         stereo_sw_2=(8000, 2, 2),