Repository: nipy/nipype

Issue:
nipype nosetests documentation broken
either we have to ask everyone to do their tests using docker containers, or we need to ensure the relevant nose components are present. for @djarecka and myself running the tests with instructions in the docs gave unicode errors.

a `pip install doctest-ignore-unicode` fixed the issue. based on our new setup.py perhaps we should update the install docs.

i've asked @djarecka to look into py.test conversion and support as part of her learning nipype.



Discussion:
Ok, so the extra component doc (https://github.com/nipy/nipype/blob/master/nipype/info.py#L159) needs `doctest-ignore-unicode`. We also will want to add the package to `requirements.txt` for readthedocs to build, most probably.

I've also found out that nipype.testing requires `nose`. However, it is not installed if you do not request the "test" extra. I think we should try not to import anything from nipype.testing (only within test files). There is a problem here with nipype.testing.data (some examples will try to import from that). To reproduce this:

```
conda create -y --name test numpy scipy matplotlib pandas lxml dipy scikit-learn python=2.7
pip install -e git+https://github.com/nipy/nipype.git@master#egg=nipype
python -c 'import nipype'
```


Resolving patch:
diff --git a/nipype/info.py b/nipype/info.py
--- 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
--- 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
 
 


Test patch:
diff --git a/doc/devel/testing_nipype.rst b/doc/devel/testing_nipype.rst
--- 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 <http://nose.readthedocs.io/en/latest/>`_.
 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
+<http://github.com/nipy/nipype/issues>`_.
+
+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
 <http://fsl.fmrib.ox.ac.uk/fslcourse/>`_. This reduced version of the package can be downloaded `here
-<https://3552243d5be815c1b09152da6525cb8fe7b900a6.googledrive.com/host/0BxI12kyv2olZVUswazA3NkFvOXM/nipype-fsl_course_data.tar.gz>`_.
+<https://files.osf.io/v1/resources/nefdp/providers/osfstorage/57f472cf9ad5a101f977ecfe>`_.
 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/docker/nipype_test/Dockerfile_py27 b/docker/nipype_test/Dockerfile_py27
--- 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
--- 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
--- 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