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 42 43 44 45 46 47 48 49
|
#!/usr/bin/env python
# vim: ft=python
""" Run nosetests for dipy while patching nose
Use as ``nosetests`` except we always run the doctests, and we patch the doctest
plugin to deal with a bug in nose at least <= 1.2.1
To reproduce a standard test run::
dipnost /path/to/dipy/dipy
"""
import sys
import nose
from nose.plugins import doctests
# We were getting errors for the extension modules. See:
# https://github.com/nose-devs/nose/pull/661
# and
# https://github.com/nose-devs/nose/issues/447
def id(self):
name = self._dt_test.name
filename = self._dt_test.filename
if filename is not None:
pk = doctests.getpackage(filename)
if pk is None:
return name
if not name.startswith(pk):
name = "%s.%s" % (pk, name)
return name
def prepare_imports():
# Set matplotlib backend as 'agg'
try:
import matplotlib as mpl
except ImportError:
pass
else:
mpl.use('agg')
if __name__ == '__main__':
# Monkeypatch. Yes, it's nasty
doctests.DocTestCase.id = id
# Set mpl backend
prepare_imports()
# Enable doctests
argv = sys.argv + ['--with-doctest']
nose.core.TestProgram(argv=argv, addplugins=[doctests.Doctest()])
|