mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-27 19:48:43 +08:00
Return correct exit code for tests
This commit is contained in:
+2
-2
@@ -59,8 +59,8 @@ script:
|
||||
- "echo 'backend : Agg' > $HOME/.matplotlib/matplotlibrc"
|
||||
- "echo 'backend.qt4 : PyQt4' >> $HOME/.matplotlib/matplotlibrc"
|
||||
# Run all tests
|
||||
- python -c "import skimage; skimage.test_verbose()"
|
||||
- python -c "import skimage; skimage.doctest_verbose()"
|
||||
- python -c "import skimage, sys; sys.exit(skimage.test_verbose())"
|
||||
- python -c "import skimage, sys; sys.exit(skimage.doctest_verbose())"
|
||||
# Run all doc examples
|
||||
- export PYTHONPATH=$(pwd):$PYTHONPATH
|
||||
- for f in doc/examples/*.py; do $PYTHON "$f"; if [ $? -ne 0 ]; then exit 1; fi done
|
||||
|
||||
@@ -7,10 +7,10 @@ clean:
|
||||
find . -name "*.so" -o -name "*.pyc" -o -name "*.pyx.md5" | xargs rm -f
|
||||
|
||||
test:
|
||||
python -c "import skimage; skimage.test_verbose()"
|
||||
python -c "import skimage, sys; sys.exit(skimage.test_verbose())"
|
||||
|
||||
doctest:
|
||||
python -c "import skimage; skimage.doctest_verbose()"
|
||||
python -c "import skimage, sys; sys.exit(skimage.doctest_verbose())"
|
||||
|
||||
coverage:
|
||||
nosetests skimage --with-coverage --cover-package=skimage
|
||||
|
||||
+17
-16
@@ -80,25 +80,25 @@ except ImportError:
|
||||
"""
|
||||
raise ImportError("Could not load nose. Doctests not available.")
|
||||
else:
|
||||
def _test(verbose=False):
|
||||
def _test(doctest=False, verbose=False):
|
||||
"""Run all unit tests."""
|
||||
import nose
|
||||
args = ['', pkg_dir, '--exe', '--ignore-files=^_test']
|
||||
if verbose:
|
||||
args.extend(['-v', '-s'])
|
||||
nose.run('skimage', argv=args)
|
||||
|
||||
def _doctest(verbose=False):
|
||||
"""Run all doctests."""
|
||||
import nose
|
||||
# do not run normal test files
|
||||
args = ['', pkg_dir, '--exe', '--with-doctest', '--ignore-files=^\.',
|
||||
'--ignore-files=^setup\.py$$', '--ignore-files=test']
|
||||
if verbose:
|
||||
args.extend(['-v', '-s'])
|
||||
with _warnings.catch_warnings():
|
||||
_warnings.simplefilter("ignore")
|
||||
nose.run('skimage', argv=args)
|
||||
if doctest:
|
||||
args.extend(['--with-doctest', '--ignore-files=^\.',
|
||||
'--ignore-files=^setup\.py$$', '--ignore-files=test'])
|
||||
with _warnings.catch_warnings():
|
||||
_warnings.simplefilter("ignore")
|
||||
success = nose.run('skimage', argv=args)
|
||||
else:
|
||||
success = nose.run('skimage', argv=args)
|
||||
# Return sys.exit code
|
||||
if success:
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
|
||||
|
||||
# do not use `test` as function name as this leads to a recursion problem with
|
||||
@@ -106,9 +106,10 @@ else:
|
||||
test = _test
|
||||
test_verbose = _functools.partial(test, verbose=True)
|
||||
test_verbose.__doc__ = test.__doc__
|
||||
doctest = _doctest
|
||||
doctest_verbose = _functools.partial(_doctest, verbose=True)
|
||||
doctest = _functools.partial(test, doctest=True)
|
||||
doctest.__doc__ = doctest.__doc__
|
||||
doctest_verbose = _functools.partial(test, doctest=True, verbose=True)
|
||||
doctest_verbose.__doc__ = doctest.__doc__
|
||||
|
||||
|
||||
class _Log(Warning):
|
||||
|
||||
Reference in New Issue
Block a user