Skip to content

Commit 8ff1851

Browse files
authored
Merge pull request #1722 from djarecka/pytest
Pytest
2 parents 18468d1 + 7b00617 commit 8ff1851

File tree

817 files changed

+3791
-5209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

817 files changed

+3791
-5209
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ install:
4242
echo "data_file = ${COVERAGE_DATA_FILE}" >> ${COVERAGE_PROCESS_START}; }
4343
- travis_retry inst
4444
script:
45-
- python -W once:FSL:UserWarning:nipype `which nosetests` --with-doctest --with-doctest-ignore-unicode --with-cov --cover-package nipype --logging-level=DEBUG --verbosity=3
45+
- py.test --doctest-modules --cov=nipype nipype
4646
after_success:
4747
- bash <(curl -s https://codecov.io/bash) -t ac172a50-8e66-42e5-8822-5373fcf54686 -cF unittests
4848
deploy:

Makefile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
PYTHON ?= python
66
NOSETESTS=`which nosetests`
77

8-
.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
8+
.PHONY: zipdoc sdist egg upload_to_pypi trailing-spaces clean-pyc clean-so clean-build clean-ctags clean in inplace test-code test-coverage test html specs check-before-commit check
99

1010
zipdoc: html
1111
zip documentation.zip doc/_build/html
@@ -56,16 +56,11 @@ inplace:
5656
$(PYTHON) setup.py build_ext -i
5757

5858
test-code: in
59-
python -W once:FSL:UserWarning:nipype $(NOSETESTS) --with-doctest --with-doctest-ignore-unicode --logging-level=DEBUG --verbosity=3 nipype
60-
61-
test-doc:
62-
$(NOSETESTS) -s --with-doctest --with-doctest-ignore-unicode --doctest-tests --doctest-extension=rst \
63-
--doctest-fixtures=_fixture doc/
59+
py.test --doctest-module nipype
6460

6561
test-coverage: clean-tests in
66-
$(NOSETESTS) -s --with-doctest --with-doctest-ignore-unicode --with-coverage --cover-package=nipype \
67-
--config=.coveragerc
68-
62+
py.test --doctest-modules --cov-config .coveragerc --cov=nipype nipype
63+
6964
test: tests # just another name
7065
tests: clean test-code
7166

circle.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
- sudo apt-get -y update && sudo apt-get install -y wget bzip2
2121

2222
override:
23-
- mkdir -p ~/examples ~/scratch/nose ~/scratch/logs
23+
- mkdir -p ~/examples ~/scratch/pytest ~/scratch/logs
2424
- if [[ ! -d ~/examples/nipype-tutorial ]]; then wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q -O nipype-tutorial.tar.bz2 "${DATA_NIPYPE_TUTORIAL_URL}" && tar xjf nipype-tutorial.tar.bz2 -C ~/examples/; fi
2525
- if [[ ! -d ~/examples/nipype-fsl_course_data ]]; then wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q -O nipype-fsl_course_data.tar.gz "${DATA_NIPYPE_FSL_COURSE}" && tar xzf nipype-fsl_course_data.tar.gz -C ~/examples/; fi
2626
- if [[ ! -d ~/examples/feeds ]]; then wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q -O fsl-5.0.9-feeds.tar.gz "${DATA_NIPYPE_FSL_FEEDS}" && tar xzf fsl-5.0.9-feeds.tar.gz -C ~/examples/; fi
@@ -35,10 +35,10 @@ dependencies:
3535
test:
3636
override:
3737
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/scratch:/scratch -w /root/src/nipype/doc nipype/nipype_test:py35 /usr/bin/run_builddocs.sh
38-
- docker run -v /etc/localtime:/etc/localtime:ro -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -e TRAVIS_PYTHON_VERSION="3.5" -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /root/src/nipype nipype/nipype_test:py35 /usr/bin/run_nosetests.sh py35 :
38+
- docker run -v /etc/localtime:/etc/localtime:ro -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /root/src/nipype nipype/nipype_test:py35 /usr/bin/run_pytests.sh py35 :
39+
timeout: 2600
40+
- docker run -v /etc/localtime:/etc/localtime:ro -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /root/src/nipype nipype/nipype_test:py27 /usr/bin/run_pytests.sh py27 :
3941
timeout: 2600
40-
- docker run -v /etc/localtime:/etc/localtime:ro -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -e TRAVIS_PYTHON_VERSION="2.7" -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /root/src/nipype nipype/nipype_test:py27 /usr/bin/run_nosetests.sh py27 :
41-
timeout: 5200
4242
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh test_spm Linear /root/examples/ workflow3d :
4343
timeout: 1600
4444
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh test_spm Linear /root/examples/ workflow4d :
@@ -56,8 +56,8 @@ test:
5656

5757
post:
5858
- bash docker/circleci/teardown.sh
59-
- for xml_f in ${CIRCLE_TEST_REPORTS}/nose/coverage*.xml; do bash <(curl -s https://codecov.io/bash) -f $xml_f -t ac172a50-8e66-42e5-8822-5373fcf54686 -F unittests; done
60-
- for xml_f in ${CIRCLE_TEST_REPORTS}/nose/smoketest*.xml; do bash <(curl -s https://codecov.io/bash) -f $xml_f -t ac172a50-8e66-42e5-8822-5373fcf54686 -F smoketests; done
59+
- for xml_f in ${CIRCLE_TEST_REPORTS}/pytest/coverage*.xml; do bash <(curl -s https://codecov.io/bash) -f $xml_f -t ac172a50-8e66-42e5-8822-5373fcf54686 -F unittests; done
60+
- for xml_f in ${CIRCLE_TEST_REPORTS}/pytest/smoketest*.xml; do bash <(curl -s https://codecov.io/bash) -f $xml_f -t ac172a50-8e66-42e5-8822-5373fcf54686 -F smoketests; done
6161

6262
general:
6363
artifacts:

doc/devel/testing_nipype.rst

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ or::
4040
Test implementation
4141
-------------------
4242

43-
Nipype testing framework is built upon `nose <http://nose.readthedocs.io/en/latest/>`_.
43+
Nipype testing framework is built upon `pytest <http://doc.pytest.org/en/latest/>`_.
4444
By the time these guidelines are written, Nipype implements 17638 tests.
4545

4646
After installation in developer mode, the tests can be run with the
@@ -50,20 +50,18 @@ following simple command at the root folder of the project ::
5050

5151
If ``make`` is not installed in the system, it is possible to run the tests using::
5252

53-
python -W once:FSL:UserWarning:nipype `which nosetests` --with-doctest \
54-
--with-doctest-ignore-unicode --logging-level=DEBUG --verbosity=3 nipype
53+
py.test --doctest-modules --cov=nipype nipype
5554

5655

57-
A successful test run should complete in a few minutes and end with
56+
A successful test run should complete in 10-30 minutes and end with
5857
something like::
5958

6059
----------------------------------------------------------------------
61-
Ran 17922 tests in 107.254s
60+
2445 passed, 41 skipped, 7 xfailed in 1277.66 seconds
6261

63-
OK (SKIP=27)
6462

6563

66-
All tests should pass (unless you're missing a dependency). If the ``SUBJECTS_DIR```
64+
No test should fail (unless you're missing a dependency). If the ``SUBJECTS_DIR```
6765
environment variable is not set, some FreeSurfer related tests will fail.
6866
If any of the tests failed, please report them on our `bug tracker
6967
<http://github.com/nipy/nipype/issues>`_.
@@ -90,6 +88,11 @@ Some tests in Nipype make use of some images distributed within the `FSL course
9088
To enable the tests depending on these data, just unpack the targz file and set the :code:`FSL_COURSE_DATA` environment
9189
variable to point to that folder.
9290

91+
Xfail tests
92+
~~~~~~~~~~
93+
94+
Some tests are expect to fail until the code will be changed or for other reasons.
95+
9396

9497
Avoiding any MATLAB calls from testing
9598
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -115,7 +118,7 @@ Nipype is as easy as follows::
115118
-v ~/examples:/root/examples:ro \
116119
-v ~/scratch:/scratch \
117120
-w /root/src/nipype \
118-
nipype/nipype_test:py27 /usr/bin/run_nosetests.sh
121+
nipype/nipype_test:py27 /usr/bin/run_pytest.sh
119122

120123
For running nipype in Python 3.5::
121124

@@ -126,4 +129,4 @@ For running nipype in Python 3.5::
126129
-v ~/examples:/root/examples:ro \
127130
-v ~/scratch:/scratch \
128131
-w /root/src/nipype \
129-
nipype/nipype_test:py35 /usr/bin/run_nosetests.sh
132+
nipype/nipype_test:py35 /usr/bin/run_pytest.sh

docker/circleci/run_nosetests.sh renamed to docker/circleci/run_pytests.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -u
66
PYTHON_VERSION=$( python -c "import sys; print('{}{}'.format(sys.version_info[0], sys.version_info[1]))" )
77

88
# Create necessary directories
9-
mkdir -p /scratch/nose /scratch/crashfiles /scratch/logs/py${PYTHON_VERSION}
9+
mkdir -p /scratch/pytest /scratch/crashfiles /scratch/logs/py${PYTHON_VERSION}
1010

1111
# Create a nipype config file
1212
mkdir -p /root/.nipype
@@ -20,17 +20,18 @@ if [[ "${PYTHON_VERSION}" -lt "30" ]]; then
2020
echo 'profile_runtime = true' >> /root/.nipype/nipype.cfg
2121
fi
2222

23-
# Run tests
23+
# Run tests using pytest
2424
cd /root/src/nipype/
2525
make clean
26-
nosetests -s nipype -c /root/src/nipype/.noserc --xunit-file="/scratch/nosetests_py${PYTHON_VERSION}.xml" --cover-xml-file="/scratch/coverage_py${PYTHON_VERSION}.xml"
26+
py.test --doctest-modules --cov-report xml:/scratch/coverage_py${PYTHON_VERSION}.xml --cov=nipype nipype
27+
2728

2829
# Workaround: run here the profiler tests in python 3
2930
if [[ "${PYTHON_VERSION}" -ge "30" ]]; then
3031
echo '[execution]' >> /root/.nipype/nipype.cfg
3132
echo 'profile_runtime = true' >> /root/.nipype/nipype.cfg
32-
nosetests nipype/interfaces/tests/test_runtime_profiler.py --xunit-file="/scratch/nosetests_py${PYTHON_VERSION}_profiler.xml" --cover-xml-file="/scratch/coverage_py${PYTHON_VERSION}_profiler.xml"
33-
nosetests nipype/pipeline/plugins/tests/test_multiproc*.py --xunit-file="/scratch/nosetests_py${PYTHON_VERSION}_multiproc.xml" --cover-xml-file="/scratch/coverage_py${PYTHON_VERSION}_multiproc.xml"
33+
py.test --cov-report xml:/scratch/coverage_py${PYTHON_VERSION}_profiler.xml --cov=nipype nipype/interfaces/tests/test_runtime_profiler.py
34+
py.test --cov-report xml:/scratch/coverage_py${PYTHON_VERSION}_multiproc.xml --cov=nipype nipype/pipeline/plugins/tests/test_multiproc*.py
3435
fi
3536

3637
# Copy crashfiles to scratch

docker/circleci/teardown.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
set -u
77
set -e
88

9-
mkdir -p ${CIRCLE_TEST_REPORTS}/nose
10-
sudo mv ~/scratch/*.xml ${CIRCLE_TEST_REPORTS}/nose
9+
mkdir -p ${CIRCLE_TEST_REPORTS}/pytest
10+
sudo mv ~/scratch/*.xml ${CIRCLE_TEST_REPORTS}/pytest
1111
mkdir -p ~/docs
1212
sudo mv ~/scratch/docs/* ~/docs/
1313
mkdir -p ~/logs

docker/nipype_test/Dockerfile_base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ RUN conda config --add channels conda-forge && \
122122
nitime \
123123
dipy \
124124
pandas && \
125-
pip install nose-cov doctest-ignore-unicode configparser
125+
pip install configparser
126126

127127
CMD ["/bin/bash"]

docker/nipype_test/Dockerfile_py27

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ MAINTAINER The nipype developers https://github.com/nipy/nipype
3232
# Downgrade python to 2.7
3333
RUN conda update -y conda && \
3434
conda update --all -y python=2.7 && \
35-
pip install nose-cov doctest-ignore-unicode configparser
35+
pip install configparser
3636

3737
COPY docker/circleci/run_* /usr/bin/
3838
RUN chmod +x /usr/bin/run_*

nipype/algorithms/tests/test_auto_AddCSVColumn.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2-
from ...testing import assert_equal
32
from ..misc import AddCSVColumn
43

54

@@ -15,7 +14,7 @@ def test_AddCSVColumn_inputs():
1514

1615
for key, metadata in list(input_map.items()):
1716
for metakey, value in list(metadata.items()):
18-
yield assert_equal, getattr(inputs.traits()[key], metakey), value
17+
assert getattr(inputs.traits()[key], metakey) == value
1918

2019

2120
def test_AddCSVColumn_outputs():
@@ -25,4 +24,4 @@ def test_AddCSVColumn_outputs():
2524

2625
for key, metadata in list(output_map.items()):
2726
for metakey, value in list(metadata.items()):
28-
yield assert_equal, getattr(outputs.traits()[key], metakey), value
27+
assert getattr(outputs.traits()[key], metakey) == value

nipype/algorithms/tests/test_auto_AddCSVRow.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2-
from ...testing import assert_equal
32
from ..misc import AddCSVRow
43

54

@@ -16,7 +15,7 @@ def test_AddCSVRow_inputs():
1615

1716
for key, metadata in list(input_map.items()):
1817
for metakey, value in list(metadata.items()):
19-
yield assert_equal, getattr(inputs.traits()[key], metakey), value
18+
assert getattr(inputs.traits()[key], metakey) == value
2019

2120

2221
def test_AddCSVRow_outputs():
@@ -26,4 +25,4 @@ def test_AddCSVRow_outputs():
2625

2726
for key, metadata in list(output_map.items()):
2827
for metakey, value in list(metadata.items()):
29-
yield assert_equal, getattr(outputs.traits()[key], metakey), value
28+
assert getattr(outputs.traits()[key], metakey) == value

nipype/algorithms/tests/test_auto_AddNoise.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2-
from ...testing import assert_equal
32
from ..misc import AddNoise
43

54

@@ -21,7 +20,7 @@ def test_AddNoise_inputs():
2120

2221
for key, metadata in list(input_map.items()):
2322
for metakey, value in list(metadata.items()):
24-
yield assert_equal, getattr(inputs.traits()[key], metakey), value
23+
assert getattr(inputs.traits()[key], metakey) == value
2524

2625

2726
def test_AddNoise_outputs():
@@ -31,4 +30,4 @@ def test_AddNoise_outputs():
3130

3231
for key, metadata in list(output_map.items()):
3332
for metakey, value in list(metadata.items()):
34-
yield assert_equal, getattr(outputs.traits()[key], metakey), value
33+
assert getattr(outputs.traits()[key], metakey) == value

nipype/algorithms/tests/test_auto_ArtifactDetect.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2-
from ...testing import assert_equal
32
from ..rapidart import ArtifactDetect
43

54

@@ -49,7 +48,7 @@ def test_ArtifactDetect_inputs():
4948

5049
for key, metadata in list(input_map.items()):
5150
for metakey, value in list(metadata.items()):
52-
yield assert_equal, getattr(inputs.traits()[key], metakey), value
51+
assert getattr(inputs.traits()[key], metakey) == value
5352

5453

5554
def test_ArtifactDetect_outputs():
@@ -65,4 +64,4 @@ def test_ArtifactDetect_outputs():
6564

6665
for key, metadata in list(output_map.items()):
6766
for metakey, value in list(metadata.items()):
68-
yield assert_equal, getattr(outputs.traits()[key], metakey), value
67+
assert getattr(outputs.traits()[key], metakey) == value

nipype/algorithms/tests/test_auto_CalculateNormalizedMoments.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2-
from ...testing import assert_equal
32
from ..misc import CalculateNormalizedMoments
43

54

@@ -13,7 +12,7 @@ def test_CalculateNormalizedMoments_inputs():
1312

1413
for key, metadata in list(input_map.items()):
1514
for metakey, value in list(metadata.items()):
16-
yield assert_equal, getattr(inputs.traits()[key], metakey), value
15+
assert getattr(inputs.traits()[key], metakey) == value
1716

1817

1918
def test_CalculateNormalizedMoments_outputs():
@@ -23,4 +22,4 @@ def test_CalculateNormalizedMoments_outputs():
2322

2423
for key, metadata in list(output_map.items()):
2524
for metakey, value in list(metadata.items()):
26-
yield assert_equal, getattr(outputs.traits()[key], metakey), value
25+
assert getattr(outputs.traits()[key], metakey) == value

nipype/algorithms/tests/test_auto_ComputeDVARS.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2-
from ...testing import assert_equal
32
from ..confounds import ComputeDVARS
43

54

@@ -35,7 +34,7 @@ def test_ComputeDVARS_inputs():
3534

3635
for key, metadata in list(input_map.items()):
3736
for metakey, value in list(metadata.items()):
38-
yield assert_equal, getattr(inputs.traits()[key], metakey), value
37+
assert getattr(inputs.traits()[key], metakey) == value
3938

4039

4140
def test_ComputeDVARS_outputs():
@@ -54,4 +53,4 @@ def test_ComputeDVARS_outputs():
5453

5554
for key, metadata in list(output_map.items()):
5655
for metakey, value in list(metadata.items()):
57-
yield assert_equal, getattr(outputs.traits()[key], metakey), value
56+
assert getattr(outputs.traits()[key], metakey) == value

nipype/algorithms/tests/test_auto_ComputeMeshWarp.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2-
from ...testing import assert_equal
32
from ..mesh import ComputeMeshWarp
43

54

@@ -24,7 +23,7 @@ def test_ComputeMeshWarp_inputs():
2423

2524
for key, metadata in list(input_map.items()):
2625
for metakey, value in list(metadata.items()):
27-
yield assert_equal, getattr(inputs.traits()[key], metakey), value
26+
assert getattr(inputs.traits()[key], metakey) == value
2827

2928

3029
def test_ComputeMeshWarp_outputs():
@@ -36,4 +35,4 @@ def test_ComputeMeshWarp_outputs():
3635

3736
for key, metadata in list(output_map.items()):
3837
for metakey, value in list(metadata.items()):
39-
yield assert_equal, getattr(outputs.traits()[key], metakey), value
38+
assert getattr(outputs.traits()[key], metakey) == value

nipype/algorithms/tests/test_auto_CreateNifti.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2-
from ...testing import assert_equal
32
from ..misc import CreateNifti
43

54

@@ -17,7 +16,7 @@ def test_CreateNifti_inputs():
1716

1817
for key, metadata in list(input_map.items()):
1918
for metakey, value in list(metadata.items()):
20-
yield assert_equal, getattr(inputs.traits()[key], metakey), value
19+
assert getattr(inputs.traits()[key], metakey) == value
2120

2221

2322
def test_CreateNifti_outputs():
@@ -27,4 +26,4 @@ def test_CreateNifti_outputs():
2726

2827
for key, metadata in list(output_map.items()):
2928
for metakey, value in list(metadata.items()):
30-
yield assert_equal, getattr(outputs.traits()[key], metakey), value
29+
assert getattr(outputs.traits()[key], metakey) == value

nipype/algorithms/tests/test_auto_Distance.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2-
from ...testing import assert_equal
32
from ..misc import Distance
43

54

@@ -19,7 +18,7 @@ def test_Distance_inputs():
1918

2019
for key, metadata in list(input_map.items()):
2120
for metakey, value in list(metadata.items()):
22-
yield assert_equal, getattr(inputs.traits()[key], metakey), value
21+
assert getattr(inputs.traits()[key], metakey) == value
2322

2423

2524
def test_Distance_outputs():
@@ -32,4 +31,4 @@ def test_Distance_outputs():
3231

3332
for key, metadata in list(output_map.items()):
3433
for metakey, value in list(metadata.items()):
35-
yield assert_equal, getattr(outputs.traits()[key], metakey), value
34+
assert getattr(outputs.traits()[key], metakey) == value

0 commit comments

Comments
 (0)