[tests] simplify test_source.py, skip if no test sounds
authorPaul Brossier <piem@piem.org>
Fri, 21 Dec 2018 15:39:56 +0000 (16:39 +0100)
committerPaul Brossier <piem@piem.org>
Fri, 21 Dec 2018 15:39:56 +0000 (16:39 +0100)
python/tests/test_source.py

index 9d2e61f..97290eb 100755 (executable)
@@ -23,28 +23,29 @@ no_sounds_msg = "no test sounds, add some in 'python/tests/sounds/'!"
 
 _debug = False
 
-class Test_aubio_source_test_case(object):
+class Test_aubio_source_test_case(TestCase):
 
-    @parametrize('filename', list_of_sounds)
-    def test_close_file(self, filename):
+    def setUp(self):
+        if not default_test_sound:
+            skipTest(no_sounds_msg)
+
+    def test_close_file(self):
         samplerate = 0 # use native samplerate
         hop_size = 256
-        f = source(filename, samplerate, hop_size)
+        f = source(default_test_sound, samplerate, hop_size)
         f.close()
 
-    @parametrize('filename', list_of_sounds)
-    def test_close_file_twice(self, filename):
+    def test_close_file_twice(self):
         samplerate = 0 # use native samplerate
         hop_size = 256
-        f = source(filename, samplerate, hop_size)
+        f = source(default_test_sound, samplerate, hop_size)
         f.close()
         f.close()
 
-    @parametrize('filename', [default_test_sound])
-    def test_read_after_close(self, filename):
+    def test_read_after_close(self):
         samplerate = 0 # use native samplerate
         hop_size = 256
-        f = source(filename, samplerate, hop_size)
+        f = source(default_test_sound, samplerate, hop_size)
         read, frames = f()
         f.close()
         with assert_raises(RuntimeError):