changeset 142:d42c0c2858c5

Use TemporaryDirectory to export test audio files
author Amine Sehili <amine.sehili@gmail.com>
date Sun, 17 Feb 2019 14:18:47 +0100
parents 995a568e6eff
children 5ff29f286374
files tests/test_io.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_io.py	Sun Feb 17 14:02:45 2019 +0100
+++ b/tests/test_io.py	Sun Feb 17 14:18:47 2019 +0100
@@ -581,8 +581,11 @@
 
     def test_save_with_pydub(self):
         with patch("auditok.io.AudioSegment.export") as export:
-            _save_with_pydub(b"\0\0", "audio.org", "ogg", 16000, 2, 1)
+            tmpdir = TemporaryDirectory()
+            filename = os.path.join(tmpdir.name, "audio.ogg")
+            _save_with_pydub(b"\0\0", filename, "ogg", 16000, 2, 1)
             self.assertTrue(export.called)
+            tmpdir.cleanup()
 
     @genty_dataset(
         raw_with_audio_format=("audio", "raw"),
@@ -649,5 +652,8 @@
     )
     def test_to_file_compressed(self, filename, audio_format, *mocks):
         with patch("auditok.io.AudioSegment.export") as export:
+            tmpdir = TemporaryDirectory()
+            filename = os.path.join(tmpdir.name, filename)
             to_file(b"\0\0", filename, audio_format, **AUDIO_PARAMS_SHORT)
             self.assertTrue(export.called)
+            tmpdir.cleanup()