Skip to content

Commit 0ebb301

Browse files
authored
Merge pull request #1757 from satra/fix/misc_test_fixes
Fix/misc test fixes
2 parents fa866eb + 75300a5 commit 0ebb301

Some content is hidden

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

42 files changed

+266
-1159
lines changed

.coveragerc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ source = nipype
44
include = */nipype/*
55
omit =
66
*/nipype/external/*
7-
*/nipype/workflows/*
87
*/nipype/fixes/*
98
*/setup.py

.travis.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,10 @@ install:
3636
conda install -y nipype &&
3737
rm -r /home/travis/miniconda/lib/python${TRAVIS_PYTHON_VERSION}/site-packages/nipype* &&
3838
pip install -r requirements.txt &&
39-
pip install -e .[$NIPYPE_EXTRAS] &&
40-
export COVERAGE_PROCESS_START=$(pwd)/.coveragerc &&
41-
export COVERAGE_DATA_FILE=$(pwd)/.coverage &&
42-
echo "data_file = ${COVERAGE_DATA_FILE}" >> ${COVERAGE_PROCESS_START}; }
39+
pip install -e .[$NIPYPE_EXTRAS]; }
4340
- travis_retry inst
4441
script:
45-
- py.test --doctest-modules --cov=nipype nipype
46-
after_success:
47-
- bash <(curl -s https://codecov.io/bash) -t ac172a50-8e66-42e5-8822-5373fcf54686 -cF unittests
42+
- py.test --doctest-modules nipype
4843
deploy:
4944
provider: pypi
5045
user: satra

doc/users/config_file.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Execution
134134
*poll_sleep_duration*
135135
This controls how long the job submission loop will sleep between submitting
136136
all pending jobs and checking for job completion. To be nice to cluster
137-
schedulers the default is set to 60 seconds.
137+
schedulers the default is set to 2 seconds.
138138

139139
*xvfb_max_wait*
140140
Maximum time (in seconds) to wait for Xvfb to start, if the _redirect_x parameter of an Interface is True.

nipype/__init__.py

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
STATUS as __status__,
1212
__version__)
1313
from .utils.config import NipypeConfig
14-
from .fixes.numpy.testing import nosetester
1514
from .utils.logger import Logging
1615
from .refs import due
16+
from .pkg_info import get_pkg_info as _get_pkg_info
1717

1818
try:
1919
import faulthandler
@@ -25,48 +25,26 @@
2525
logging = Logging(config)
2626

2727

28-
class _NoseTester(nosetester.NoseTester):
29-
""" Subclass numpy's NoseTester to add doctests by default
30-
"""
31-
32-
def _get_custom_doctester(self):
33-
return None
34-
35-
def test(self, label='fast', verbose=1, extra_argv=['--exe'],
36-
doctests=True, coverage=False):
37-
"""Run the full test suite
28+
class NipypeTester(object):
29+
def __call__(self, doctests=True):
30+
try:
31+
import pytest
32+
except:
33+
raise RuntimeError('py.test not installed, run: pip install pytest')
34+
params = {'args': []}
35+
if doctests:
36+
params['args'].append('--doctest-modules')
37+
nipype_path = os.path.dirname(__file__)
38+
params['args'].extend(['-x', '--ignore={}/external'.format(nipype_path),
39+
nipype_path])
40+
pytest.main(**params)
3841

39-
Examples
40-
--------
41-
This will run the test suite and stop at the first failing
42-
example
43-
>>> from nipype import test
44-
>>> test(extra_argv=['--exe', '-sx']) # doctest: +SKIP
45-
"""
46-
return super(_NoseTester, self).test(label=label,
47-
verbose=verbose,
48-
extra_argv=extra_argv,
49-
doctests=doctests,
50-
coverage=coverage)
51-
52-
try:
53-
test = _NoseTester(raise_warnings="release").test
54-
except TypeError:
55-
# Older versions of numpy do not have a raise_warnings argument
56-
test = _NoseTester().test
57-
del nosetester
42+
test = NipypeTester()
5843

59-
# Set up package information function
60-
from .pkg_info import get_pkg_info as _get_pkg_info
61-
get_info = lambda: _get_pkg_info(os.path.dirname(__file__))
62-
63-
# If this file is exec after being imported, the following lines will
64-
# fail
65-
try:
66-
del Tester
67-
except:
68-
pass
6944

45+
def get_info():
46+
"""Returns package information"""
47+
return _get_pkg_info(os.path.dirname(__file__))
7048

7149
from .pipeline import Node, MapNode, JoinNode, Workflow
7250
from .interfaces import (DataGrabber, DataSink, SelectFiles,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from ..confounds import ACompCor
3+
4+
5+
def test_ACompCor_inputs():
6+
input_map = dict(components_file=dict(usedefault=True,
7+
),
8+
header=dict(),
9+
ignore_exception=dict(nohash=True,
10+
usedefault=True,
11+
),
12+
mask_file=dict(),
13+
num_components=dict(usedefault=True,
14+
),
15+
realigned_file=dict(mandatory=True,
16+
),
17+
regress_poly_degree=dict(usedefault=True,
18+
),
19+
use_regress_poly=dict(usedefault=True,
20+
),
21+
)
22+
inputs = ACompCor.input_spec()
23+
24+
for key, metadata in list(input_map.items()):
25+
for metakey, value in list(metadata.items()):
26+
assert getattr(inputs.traits()[key], metakey) == value
27+
28+
29+
def test_ACompCor_outputs():
30+
output_map = dict(components_file=dict(),
31+
)
32+
outputs = ACompCor.output_spec()
33+
34+
for key, metadata in list(output_map.items()):
35+
for metakey, value in list(metadata.items()):
36+
assert getattr(outputs.traits()[key], metakey) == value

nipype/algorithms/tests/test_auto_TCompCor.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,22 @@ def test_TCompCor_inputs():
2929

3030

3131
def test_TCompCor_outputs():
32-
output_map = dict(components_file=dict(),
33-
high_variance_mask=dict()
32+
output_map = dict(components_file=dict(usedefault=True,
33+
),
34+
header=dict(),
35+
high_variance_mask=dict(),
36+
ignore_exception=dict(nohash=True,
37+
usedefault=True,
38+
),
39+
mask_file=dict(),
40+
num_components=dict(usedefault=True,
41+
),
42+
realigned_file=dict(mandatory=True,
43+
),
44+
regress_poly_degree=dict(usedefault=True,
45+
),
46+
use_regress_poly=dict(usedefault=True,
47+
),
3448
)
3549
outputs = TCompCor.output_spec()
3650

nipype/algorithms/tests/test_compcor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ def test_compcor_bad_input_shapes(self):
8383
for data_shape in (shape_less_than, shape_more_than):
8484
data_file = utils.save_toy_nii(np.zeros(data_shape), 'temp.nii')
8585
interface = CompCor(realigned_file=data_file, mask_file=self.mask_file)
86-
with pytest.raises_regexp(ValueError, "dimensions"): interface.run()
86+
with pytest.raises(ValueError, message="Dimension mismatch"): interface.run()
8787

8888
def test_tcompcor_bad_input_dim(self):
8989
bad_dims = (2, 2, 2)
9090
data_file = utils.save_toy_nii(np.zeros(bad_dims), 'temp.nii')
9191
interface = TCompCor(realigned_file=data_file)
92-
with pytest.raises_regexp(ValueError, '4-D'): interface.run()
92+
with pytest.raises(ValueError, message='Not a 4D file'): interface.run()
9393

9494
def run_cc(self, ccinterface, expected_components, expected_header='CompCor'):
9595
# run

nipype/algorithms/tests/test_icc_anova.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ def test_ICC_rep_anova():
1919
assert round(icc, 2) == 0.71
2020
assert dfc == 3
2121
assert dfe == 15
22-
assert r_var / (r_var + e_var) == icc
22+
assert np.isclose(r_var / (r_var + e_var), icc)

nipype/algorithms/tests/test_mesh_ops.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ def test_ident_distances(tmpdir):
3434
@pytest.mark.skipif(VTKInfo.no_tvtk(), reason="tvtk is not installed")
3535
def test_trans_distances(tmpdir):
3636
tempdir = str(tmpdir)
37-
os.chdir(tempdir)
38-
3937
from ...interfaces.vtkbase import tvtk
4038

4139
in_surf = example_data('surf01.vtk')
@@ -57,10 +55,10 @@ def test_trans_distances(tmpdir):
5755
dist.inputs.surface2 = warped_surf
5856
dist.inputs.out_file = os.path.join(tempdir, 'distance.npy')
5957
res = dist.run()
60-
npt.assert_almost_equal(res.outputs.distance, np.linalg.norm(inc), 4)
58+
assert np.allclose(res.outputs.distance, np.linalg.norm(inc), 4)
6159
dist.inputs.weighting = 'area'
6260
res = dist.run()
63-
npt.assert_almost_equal(res.outputs.distance, np.linalg.norm(inc), 4)
61+
assert np.allclose(res.outputs.distance, np.linalg.norm(inc), 4)
6462

6563

6664
@pytest.mark.skipif(VTKInfo.no_tvtk(), reason="tvtk is not installed")

nipype/fixes/README.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

nipype/fixes/__init__.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

nipype/fixes/numpy/__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

nipype/fixes/numpy/testing/__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)