ref: 7fd92ca36f0277efb6955d1ab53c74043e449437
parent: 8607a74536678d2c6d2fceca750c4ccf6c1d174d
author: Paul Brossier <piem@piem.org>
date: Fri Nov 2 18:13:56 EDT 2018
[tests] use run_module_suite so tests can run when pytest is not installed
--- a/python/tests/_tools.py
+++ b/python/tests/_tools.py
@@ -21,6 +21,9 @@
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 @@
parametrize = dec.parametrize
def skipTest(msg):
raise SkipTest(msg)
+ from numpy.testing import run_module_suite
# always use numpy's assert_equal
import numpy
--- a/python/tests/test_mfcc.py
+++ b/python/tests/test_mfcc.py
@@ -106,5 +106,5 @@
#print coeffs
if __name__ == '__main__':
- import sys, pytest
- pytest.main(sys.argv)
+ from _tools import run_module_suite
+ run_module_suite()
--- a/python/tests/test_midi2note.py
+++ b/python/tests/test_midi2note.py
@@ -40,5 +40,5 @@
assert_raises(TypeError, midi2note, "a")
if __name__ == '__main__':
- import sys, pytest
- pytest.main(sys.argv)
+ from _tools import run_module_suite
+ run_module_suite()
--- a/python/tests/test_note2midi.py
+++ b/python/tests/test_note2midi.py
@@ -138,5 +138,5 @@
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()
--- a/python/tests/test_sink.py
+++ b/python/tests/test_sink.py
@@ -118,5 +118,5 @@
g(vec, 128)
if __name__ == '__main__':
- import pytest, sys
- pytest.main(sys.argv)
+ from _tools import run_module_suite
+ run_module_suite()
--- a/python/tests/test_source.py
+++ b/python/tests/test_source.py
@@ -187,5 +187,5 @@
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()