python/tests/utils.py: by default, use 5 seconds brownoise
authorPaul Brossier <piem@piem.org>
Sun, 21 Aug 2016 10:45:04 +0000 (12:45 +0200)
committerPaul Brossier <piem@piem.org>
Sun, 21 Aug 2016 10:45:04 +0000 (12:45 +0200)
python/tests/utils.py

index 2e3c31e..b0963fc 100644 (file)
@@ -5,6 +5,8 @@ import glob
 import numpy as np
 from tempfile import mkstemp
 
+DEFAULT_SOUND = '22050Hz_5s_brownnoise.wav'
+
 def array_from_text_file(filename, dtype = 'float'):
     filename = os.path.join(os.path.dirname(__file__), filename)
     with open(filename) as f:
@@ -21,7 +23,11 @@ def get_default_test_sound(TestCase, rel_dir = 'sounds'):
     if len(all_sounds) == 0:
         TestCase.skipTest("please add some sounds in \'python/tests/sounds\'")
     else:
-        return all_sounds[0]
+        default_sound = all_sounds[0]
+        if DEFAULT_SOUND in map(os.path.basename, all_sounds):
+            while os.path.basename(default_sound) != DEFAULT_SOUND:
+                default_sound = all_sounds.pop(0)
+        return default_sound
 
 def get_tmp_sink_path():
     fd, path = mkstemp()