[tests] use run_module_suite so tests can run when pytest is not installed
authorPaul Brossier <piem@piem.org>
Fri, 2 Nov 2018 21:13:56 +0000 (22:13 +0100)
committerPaul Brossier <piem@piem.org>
Fri, 2 Nov 2018 21:13:56 +0000 (22:13 +0100)
python/tests/_tools.py
python/tests/test_mfcc.py
python/tests/test_midi2note.py
python/tests/test_note2midi.py
python/tests/test_sink.py
python/tests/test_source.py

index a0810d0..4121656 100644 (file)
@@ -21,6 +21,9 @@ try:
     assert_warns = pytest.warns
     skipTest = pytest.skip
     _has_pytest = True
+    def run_module_suite():
+        import sys, pytest
+        pytest.main(sys.argv)
 except:
     pass
 
@@ -31,6 +34,7 @@ if not _has_pytest:
     parametrize = dec.parametrize
     def skipTest(msg):
         raise SkipTest(msg)
+    from numpy.testing import run_module_suite
 
 # always use numpy's assert_equal
 import numpy
index f25fb9d..d54f44e 100755 (executable)
@@ -106,5 +106,5 @@ class Test_aubio_mfcc_all_parameters(object):
         #print coeffs
 
 if __name__ == '__main__':
-    import sys, pytest
-    pytest.main(sys.argv)
+    from _tools import run_module_suite
+    run_module_suite()
index 63ceda8..5451c58 100755 (executable)
@@ -40,5 +40,5 @@ class Test_midi2note_wrong_values(object):
         assert_raises(TypeError, midi2note, "a")
 
 if __name__ == '__main__':
-    import sys, pytest
-    pytest.main(sys.argv)
+    from _tools import run_module_suite
+    run_module_suite()
index cfa1db6..0608195 100755 (executable)
@@ -138,5 +138,5 @@ class note2freq_simple_test(TestCase):
             self.assertLess(abs(note2freq("A4")-440), 1.e-12)
 
 if __name__ == '__main__':
-    import sys, pytest
-    pytest.main(sys.argv)
+    from _tools import run_module_suite
+    run_module_suite()
index 51f60ea..b9f9c56 100755 (executable)
@@ -118,5 +118,5 @@ class Test_aubio_sink(object):
                 g(vec, 128)
 
 if __name__ == '__main__':
-    import pytest, sys
-    pytest.main(sys.argv)
+    from _tools import run_module_suite
+    run_module_suite()
index 0ab87ae..6d88c62 100755 (executable)
@@ -187,5 +187,5 @@ class Test_aubio_source_with(object):
             assert_equal(total_frames, input_source.duration)
 
 if __name__ == '__main__':
-    import sys, pytest
-    pytest.main(sys.argv)
+    from _tools import run_module_suite
+    run_module_suite()