Paul Brossier[tests] update _tools01d56c18 years agoHistory
47 lines · 1.2 KB · Python
RawDownload
"""This file imports test methods from different testing modules, in thisorder:     - if 'nose2' is found in the list of loaded module, use it    - otherwise, try using 'pytest'    - if that also fails, fallback to 'numpy.testing'""" import sys _has_pytest = False_has_nose2 = False # if nose2 has already been imported, use itif 'nose2' in sys.modules:    from nose2.tools import params, such    def parametrize(argnames, argvalues):        return params(*argvalues)    assert_raises = such.helper.assertRaises    assert_warns = such.helper.assertWarns    skipTest = such.helper.skipTest    _has_nose2 = True # otherwise, check if we have pytestif not _has_nose2:    try:        import pytest        parametrize = pytest.mark.parametrize        assert_raises = pytest.raises        assert_warns = pytest.warns        skipTest = pytest.skip        _has_pytest = True    except:        pass # otherwise fallback on numpy.testingif not _has_pytest and not _has_nose2:    from numpy.testing import dec, assert_raises, assert_warns    from numpy.testing import SkipTest    parametrize = dec.parametrize    def skipTest(msg):        raise SkipTest(msg) # always use numpy's assert_equalimport numpyassert_equal = numpy.testing.assert_equal

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t