source: python/tests/_tools.py @ 38592a6

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/timestretchfix/ffmpeg5
Last change on this file since 38592a6 was 38592a6, checked in by Paul Brossier <piem@piem.org>, 5 years ago

[tests] use _tools in test_mfcc

  • Property mode set to 100644
File size: 1.3 KB
Line 
1"""
2This file imports test methods from different testing modules, in this
3order:
4
5    - if 'nose2' is found in the list of loaded module, use it
6    - otherwise, try using 'pytest'
7    - if that also fails, fallback to 'numpy.testing'
8"""
9
10import sys
11
12_has_pytest = False
13_has_nose2 = False
14
15# if nose2 has already been imported, use it
16if 'nose2' in sys.modules:
17    from nose2.tools import params, such
18    def parametrize(argnames, argvalues):
19        return params(*argvalues)
20    assert_raises = such.helper.assertRaises
21    assert_warns = such.helper.assertWarns
22    skipTest = such.helper.skipTest
23    _has_nose2 = True
24    print ('using nose2')
25
26# otherwise, check if we have pytest
27if not _has_nose2:
28    try:
29        import pytest
30        parametrize = pytest.mark.parametrize
31        _has_pytest = True
32        assert_raises = pytest.raises
33        assert_warns = pytest.warns
34        skipTest = pytest.skip
35        print ('using pytest')
36    except:
37        pass
38
39# otherwise fallback on numpy.testing
40if not _has_pytest and not _has_nose2:
41    from numpy.testing import dec, assert_raises, assert_warns
42    from numpy.testing import SkipTest
43    parametrize = dec.parametrize
44    def skipTest(msg):
45        raise SkipTest(msg)
46    print ('using numpy')
47
48# always use numpy's assert_equal
49import numpy
50assert_equal = numpy.testing.assert_equal
Note: See TracBrowser for help on using the repository browser.