diff --git a/Makefile b/Makefile index 5ae05c5c98..977e723ebb 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # rsync -e ssh nipype-0.1-py2.5.egg cburns,nipy@frs.sourceforge.net:/home/frs/project/n/ni/nipy/nipype/nipype-0.1/ PYTHON ?= python -NOSETESTS ?= nosetests +NOSETESTS=`which nosetests` .PHONY: zipdoc sdist egg upload_to_pypi trailing-spaces clean-pyc clean-so clean-build clean-ctags clean in inplace test-code test-doc test-coverage test html specs check-before-commit check @@ -56,7 +56,7 @@ inplace: $(PYTHON) setup.py build_ext -i test-code: in - $(NOSETESTS) -s nipype --with-doctest --with-doctest-ignore-unicode + python -W once:FSL:UserWarning:nipype $(NOSETESTS) --with-doctest --with-doctest-ignore-unicode --logging-level=DEBUG --verbosity=3 nipype test-doc: $(NOSETESTS) -s --with-doctest --with-doctest-ignore-unicode --doctest-tests --doctest-extension=rst \ @@ -66,7 +66,8 @@ test-coverage: clean-tests in $(NOSETESTS) -s --with-doctest --with-doctest-ignore-unicode --with-coverage --cover-package=nipype \ --config=.coveragerc -test: clean test-code +test: tests # just another name +tests: clean test-code html: @echo "building docs" diff --git a/doc/devel/testing_nipype.rst b/doc/devel/testing_nipype.rst index e723334a0b..61fd877fbc 100644 --- a/doc/devel/testing_nipype.rst +++ b/doc/devel/testing_nipype.rst @@ -1,3 +1,5 @@ +.. _dev_testing_nipype: + ============== Testing nipype ============== @@ -14,25 +16,69 @@ If both batteries of tests are passing, the following badges should be shown in :target: https://circleci.com/gh/nipy/nipype/tree/master -Tests implementation --------------------- +Installation for developers +--------------------------- + +To check out the latest development version:: + + git clone https://github.com/nipy/nipype.git + +After cloning:: + + cd nipype + pip install -r requirements.txt + python setup.py develop + +or:: + + cd nipype + pip install -r requirements.txt + pip install -e .[tests] + + + +Test implementation +------------------- Nipype testing framework is built upon `nose `_. By the time these guidelines are written, Nipype implements 17638 tests. -To run the tests locally, first get nose installed:: +After installation in developer mode, the tests can be run with the +following simple command at the root folder of the project :: + + make tests - pip install nose +If ``make`` is not installed in the system, it is possible to run the tests using:: + python -W once:FSL:UserWarning:nipype `which nosetests` --with-doctest \ + --with-doctest-ignore-unicode --logging-level=DEBUG --verbosity=3 nipype -Then, after nipype is `installed in developer mode <../users/install.html#nipype-for-developers>`_, -the tests can be run with the following simple command:: - make tests +A successful test run should complete in a few minutes and end with +something like:: + ---------------------------------------------------------------------- + Ran 17922 tests in 107.254s + + OK (SKIP=27) + + +All tests should pass (unless you're missing a dependency). If the ``SUBJECTS_DIR``` +environment variable is not set, some FreeSurfer related tests will fail. +If any of the tests failed, please report them on our `bug tracker +`_. + +On Debian systems, set the following environment variable before running +tests:: + + export MATLABCMD=$pathtomatlabdir/bin/$platform/MATLAB + +where ``$pathtomatlabdir`` is the path to your matlab installation and +``$platform`` is the directory referring to x86 or x64 installations +(typically ``glnxa64`` on 64-bit installations). Skip tests ----------- +~~~~~~~~~~ Nipype will skip some tests depending on the currently available software and data dependencies. Installing software dependencies and downloading the necessary data @@ -40,11 +86,21 @@ will reduce the number of skip tests. Some tests in Nipype make use of some images distributed within the `FSL course data `_. This reduced version of the package can be downloaded `here -`_. +`_. To enable the tests depending on these data, just unpack the targz file and set the :code:`FSL_COURSE_DATA` environment variable to point to that folder. +Avoiding any MATLAB calls from testing +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +On unix systems, set an empty environment variable:: + + export NIPYPE_NO_MATLAB= + +This will skip any tests that require matlab. + + Testing Nipype using Docker --------------------------- diff --git a/doc/users/install.rst b/doc/users/install.rst index f8645aeb73..5caaf56160 100644 --- a/doc/users/install.rst +++ b/doc/users/install.rst @@ -43,6 +43,12 @@ or:: pip install nipype +If you want to install all the optional features of ``nipype``, +use the following command (only for ``nipype>=0.13``):: + + pip install nipype[all] + + Debian and Ubuntu ~~~~~~~~~~~~~~~~~ @@ -73,77 +79,24 @@ If you downloaded the source distribution named something like ``nipype-x.y.tar.gz``, then unpack the tarball, change into the ``nipype-x.y`` directory and install nipype using:: - pip install -r requirements.txt python setup.py install **Note:** Depending on permissions you may need to use ``sudo``. -Nipype for developers ---------------------- - -To check out the latest development version:: - - git clone git://github.com/nipy/nipype.git - -or:: - - git clone https://github.com/nipy/nipype.git - -After cloning:: - - pip install -r requirements.txt - python setup.py develop - - -Check out the list of nipype's `current dependencies `_. - - Testing the install ------------------- -The best way to test the install is to run the test suite. If you have -nose_ installed, then do the following:: - - python -c "import nipype; nipype.test()" - -you can also test with nosetests:: - - nosetests --with-doctest /nipype --exclude=external --exclude=testing - -or:: - - nosetests --with-doctest nipype - -A successful test run should complete in a few minutes and end with -something like:: - - Ran 13053 tests in 126.618s - - OK (SKIP=66) - -All tests should pass (unless you're missing a dependency). If SUBJECTS_DIR -variable is not set some FreeSurfer related tests will fail. If any tests -fail, please report them on our `bug tracker -`_. - -On Debian systems, set the following environment variable before running -tests:: - - export MATLABCMD=$pathtomatlabdir/bin/$platform/MATLAB +The best way to test the install is checking nipype's version :: -where ``$pathtomatlabdir`` is the path to your matlab installation and -``$platform`` is the directory referring to x86 or x64 installations -(typically ``glnxa64`` on 64-bit installations). + python -c "import nipype; print(nipype.__version__)" -Avoiding any MATLAB calls from testing -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -On unix systems, set an empty environment variable:: +Installation for developers +--------------------------- - export NIPYPE_NO_MATLAB= +Developers should start `here <../devel/testing_nipype.html>`_. -This will skip any tests that require matlab. Recommended Software ------------ diff --git a/docker/nipype_test/Dockerfile_py27 b/docker/nipype_test/Dockerfile_py27 index 6e38a5bf52..d648771b6f 100644 --- a/docker/nipype_test/Dockerfile_py27 +++ b/docker/nipype_test/Dockerfile_py27 @@ -40,7 +40,8 @@ RUN chmod +x /usr/bin/run_* # Speed up building RUN mkdir -p /root/src/nipype COPY requirements.txt /root/src/nipype/requirements.txt -RUN pip install -r /root/src/nipype/requirements.txt +RUN pip install -r /root/src/nipype/requirements.txt && \ + sed -i 's/\(backend *: \).*$/\1Agg/g' /usr/local/miniconda/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc # Re-install nipype COPY . /root/src/nipype diff --git a/docker/nipype_test/Dockerfile_py34 b/docker/nipype_test/Dockerfile_py34 index e0d192ccae..9f49f86206 100644 --- a/docker/nipype_test/Dockerfile_py34 +++ b/docker/nipype_test/Dockerfile_py34 @@ -45,7 +45,8 @@ RUN rm -r ${FSLDIR}/bin/imglob && \ # Speed up building RUN mkdir -p /root/src/nipype COPY requirements.txt /root/src/nipype/requirements.txt -RUN pip install -r /root/src/nipype/requirements.txt +RUN pip install -r /root/src/nipype/requirements.txt && \ + sed -i 's/\(backend *: \).*$/\1Agg/g' /usr/local/miniconda/lib/python3.4/site-packages/matplotlib/mpl-data/matplotlibrc # Re-install nipype COPY . /root/src/nipype diff --git a/docker/nipype_test/Dockerfile_py35 b/docker/nipype_test/Dockerfile_py35 index 93007c1e53..a5107b9bad 100644 --- a/docker/nipype_test/Dockerfile_py35 +++ b/docker/nipype_test/Dockerfile_py35 @@ -43,7 +43,8 @@ RUN rm -r ${FSLDIR}/bin/imglob && \ # Speed up building RUN mkdir -p /root/src/nipype COPY requirements.txt /root/src/nipype/requirements.txt -RUN pip install -r /root/src/nipype/requirements.txt +RUN pip install -r /root/src/nipype/requirements.txt && \ + sed -i 's/\(backend *: \).*$/\1Agg/g' /usr/local/miniconda/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc # Re-install nipype COPY . /root/src/nipype diff --git a/nipype/info.py b/nipype/info.py index ca8aaa9ba7..565ecd4577 100644 --- a/nipype/info.py +++ b/nipype/info.py @@ -156,7 +156,7 @@ def get_nipype_gitversion(): ] EXTRA_REQUIRES = { - 'doc': ['Sphinx>=0.3', 'matplotlib', 'pydotplus'], + 'doc': ['Sphinx>=0.3', 'matplotlib', 'pydotplus', 'doctest-ignore-unicode'], 'tests': TESTS_REQUIRES, 'fmri': ['nitime', 'nilearn', 'dipy', 'nipy', 'matplotlib'], 'profiler': ['psutil'], diff --git a/nipype/interfaces/utility.py b/nipype/interfaces/utility.py index 4289c7dc85..8423c64301 100644 --- a/nipype/interfaces/utility.py +++ b/nipype/interfaces/utility.py @@ -25,7 +25,6 @@ Undefined, isdefined, OutputMultiPath, runtime_profile, InputMultiPath, BaseInterface, BaseInterfaceInputSpec) from .io import IOBase, add_traits -from ..testing import assert_equal from ..utils.filemanip import (filename_to_list, copyfile, split_filename) from ..utils.misc import getsource, create_function_from_source @@ -530,8 +529,8 @@ def _run_interface(self, runtime): data1 = nb.load(self.inputs.volume1).get_data() data2 = nb.load(self.inputs.volume2).get_data() - assert_equal(data1, data2) - + if not np.all(data1 == data2): + raise RuntimeError('Input images are not exactly equal') return runtime diff --git a/requirements.txt b/requirements.txt index ef66036744..a2e3a04853 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,3 +12,4 @@ xvfbwrapper psutil funcsigs configparser +doctest-ignore-unicode \ No newline at end of file