File: _tools.py

package info (click to toggle)
aubio 0.4.9-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,720 kB
  • sloc: python: 20,447; ansic: 20,127; makefile: 348; sh: 232
file content (41 lines) | stat: -rw-r--r-- 958 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
This file imports test methods from different testing modules, in this
order:

    - try importing 'pytest'
    - if it fails, fallback to 'numpy.testing'

Nose2 support was removed because of lacking assertWarns on py2.7.

"""

import sys

_has_pytest = False

# check if we have pytest
try:
    import pytest
    parametrize = pytest.mark.parametrize
    assert_raises = pytest.raises
    assert_warns = pytest.warns
    skipTest = pytest.skip
    _has_pytest = True
    def run_module_suite():
        import sys, pytest
        pytest.main(sys.argv)
except:
    pass

# otherwise fallback on numpy.testing
if not _has_pytest:
    from numpy.testing import dec, assert_raises, assert_warns
    from numpy.testing import SkipTest
    parametrize = dec.parametrize
    def skipTest(msg):
        raise SkipTest(msg)
    from numpy.testing import run_module_suite

# always use numpy's assert_equal
import numpy
assert_equal = numpy.testing.assert_equal