changeset 407:6c33626d0bff

Convert pathlib.Path to str to open with wave
author Amine Sehili <amine.sehili@gmail.com>
date Wed, 19 Jun 2024 23:06:32 +0200
parents 79bd3de43a5b
children 60a7fb533fba
files auditok/io.py tests/test_io.py
diffstat 2 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/auditok/io.py	Wed Jun 19 22:48:54 2024 +0200
+++ b/auditok/io.py	Wed Jun 19 23:06:32 2024 +0200
@@ -834,7 +834,7 @@
 
     if large_file:
         return WaveAudioSource(filename)
-    with wave.open(filename) as fp:
+    with wave.open(str(filename)) as fp:
         channels = fp.getnchannels()
         srate = fp.getframerate()
         swidth = fp.getsampwidth()
--- a/tests/test_io.py	Wed Jun 19 22:48:54 2024 +0200
+++ b/tests/test_io.py	Wed Jun 19 23:06:32 2024 +0200
@@ -248,6 +248,12 @@
     [
         (False, BufferAudioSource, -1, False),  # large_file_false_negative_size
         (False, BufferAudioSource, None, False),  # large_file_false_None_size
+        (
+            False,
+            BufferAudioSource,
+            None,
+            True,
+        ),  # large_file_false_None_size_Path
         (True, RawAudioSource, -1, False),  # large_file_true_negative_size
         (True, RawAudioSource, None, False),  # large_file_true_None_size
         (True, RawAudioSource, -1, True),  # large_file_true_negative_size_Path
@@ -255,6 +261,7 @@
     ids=[
         "large_file_false_negative_size",
         "large_file_false_None_size",
+        "large_file_false_None_size_Path",
         "large_file_true_negative_size",
         "large_file_true_None_size",
         "large_file_true_negative_size_Path",
@@ -286,6 +293,12 @@
     [
         (False, BufferAudioSource, -1, False),  # large_file_false_negative_size
         (False, BufferAudioSource, None, False),  # large_file_false_None_size
+        (
+            False,
+            BufferAudioSource,
+            None,
+            True,
+        ),  # large_file_false_None_size_Path
         (True, WaveAudioSource, -1, False),  # large_file_true_negative_size
         (True, WaveAudioSource, None, False),  # large_file_true_None_size
         (True, WaveAudioSource, -1, True),  # large_file_true_negative_size_Path
@@ -293,6 +306,7 @@
     ids=[
         "large_file_false_negative_size",
         "large_file_false_None_size",
+        "large_file_false_None_size_Path",
         "large_file_true_negative_size",
         "large_file_true_None_size",
         "large_file_true_negative_size_Path",