From 7fd92ca36f0277efb6955d1ab53c74043e449437 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 2 Nov 2018 22:13:56 +0100 Subject: [PATCH] [tests] use run_module_suite so tests can run when pytest is not installed --- python/tests/_tools.py | 4 ++++ python/tests/test_mfcc.py | 4 ++-- python/tests/test_midi2note.py | 4 ++-- python/tests/test_note2midi.py | 4 ++-- python/tests/test_sink.py | 4 ++-- python/tests/test_source.py | 4 ++-- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/python/tests/_tools.py b/python/tests/_tools.py index a0810d0c..41216563 100644 --- a/python/tests/_tools.py +++ b/python/tests/_tools.py @@ -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 diff --git a/python/tests/test_mfcc.py b/python/tests/test_mfcc.py index f25fb9d8..d54f44e1 100755 --- a/python/tests/test_mfcc.py +++ b/python/tests/test_mfcc.py @@ -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() diff --git a/python/tests/test_midi2note.py b/python/tests/test_midi2note.py index 63ceda8a..5451c581 100755 --- a/python/tests/test_midi2note.py +++ b/python/tests/test_midi2note.py @@ -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() diff --git a/python/tests/test_note2midi.py b/python/tests/test_note2midi.py index cfa1db68..06081958 100755 --- a/python/tests/test_note2midi.py +++ b/python/tests/test_note2midi.py @@ -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() diff --git a/python/tests/test_sink.py b/python/tests/test_sink.py index 51f60ea0..b9f9c56d 100755 --- a/python/tests/test_sink.py +++ b/python/tests/test_sink.py @@ -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() diff --git a/python/tests/test_source.py b/python/tests/test_source.py index 0ab87aed..6d88c626 100755 --- a/python/tests/test_source.py +++ b/python/tests/test_source.py @@ -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() -- 2.11.0