diff --git a/.travis.yml b/.travis.yml index ebe63f3d..91cc8141 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Makefile b/Makefile index 13f82103..e8a85587 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/skimage/__init__.py b/skimage/__init__.py index 61a3e57f..49510c91 100644 --- a/skimage/__init__.py +++ b/skimage/__init__.py @@ -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):