Skip to content

Commit bc6df5b

Browse files
authored
Merge pull request #2469 from effigies/ci/parallel_pytest
TEST: Parallelize pytest
2 parents 41a5583 + 6d2c325 commit bc6df5b

Some content is hidden

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

96 files changed

+28
-658
lines changed

nipype/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@
2525

2626

2727
class NipypeTester(object):
28-
def __call__(self, doctests=True):
28+
def __call__(self, doctests=True, parallel=True):
2929
try:
3030
import pytest
3131
except:
3232
raise RuntimeError(
3333
'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(
39-
['-x', '--ignore={}/external'.format(nipype_path), nipype_path])
40-
pytest.main(**params)
34+
args = []
35+
if not doctests:
36+
args.extend(['-p', 'no:doctest'])
37+
if not parallel:
38+
args.append('-n0')
39+
args.append(os.path.dirname(__file__))
40+
pytest.main(args=args)
4141

4242

4343
test = NipypeTester()

nipype/algorithms/confounds.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
# vi: set ft=python sts=4 ts=4 sw=4 et:
44
'''
55
Algorithms to compute confounds in :abbr:`fMRI (functional MRI)`
6-
7-
Change directory to provide relative paths for doctests
8-
>>> import os
9-
>>> filepath = os.path.dirname(os.path.realpath(__file__))
10-
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
11-
>>> os.chdir(datadir)
12-
136
'''
147
from __future__ import (print_function, division, unicode_literals,
158
absolute_import)

nipype/algorithms/mesh.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
# vi: set ft=python sts=4 ts=4 sw=4 et:
44
"""
55
Miscellaneous algorithms for 2D contours and 3D triangularized meshes handling
6-
7-
.. testsetup::
8-
# Change directory to provide relative paths for doctests
9-
>>> import os
10-
>>> filepath = os.path.dirname(os.path.realpath( __file__ ))
11-
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
12-
>>> os.chdir(datadir)
13-
146
"""
157
from __future__ import (print_function, division, unicode_literals,
168
absolute_import)

nipype/algorithms/metrics.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
'''
55
Image assessment algorithms. Typical overlap and error computation
66
measures to evaluate results from other processing units.
7-
8-
Change directory to provide relative paths for doctests
9-
>>> import os
10-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
11-
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
12-
>>> os.chdir(datadir)
13-
147
'''
158
from __future__ import (print_function, division, unicode_literals,
169
absolute_import)

nipype/algorithms/misc.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
# vi: set ft=python sts=4 ts=4 sw=4 et:
44
'''
55
Miscellaneous algorithms
6-
7-
Change directory to provide relative paths for doctests
8-
>>> import os
9-
>>> filepath = os.path.dirname(os.path.realpath(__file__))
10-
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
11-
>>> os.chdir(datadir)
12-
136
'''
147
from __future__ import (print_function, division, unicode_literals,
158
absolute_import)

nipype/algorithms/modelgen.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@
1010
These functions include:
1111
1212
* SpecifyModel: allows specification of sparse and non-sparse models
13-
14-
Change directory to provide relative paths for doctests
15-
>>> import os
16-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
17-
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
18-
>>> os.chdir(datadir)
19-
2013
"""
2114
from __future__ import (print_function, division, unicode_literals,
2215
absolute_import)

nipype/algorithms/rapidart.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
1212
* StimulusCorrelation: determines correlation between stimuli
1313
schedule and movement/intensity parameters
14-
15-
Change directory to provide relative paths for doctests
16-
>>> import os
17-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
18-
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
19-
>>> os.chdir(datadir)
2014
"""
2115
from __future__ import (print_function, division, unicode_literals,
2216
absolute_import)

nipype/caching/memory.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
"""
33
Using nipype with persistence and lazy recomputation but without explicit
44
name-steps pipeline: getting back scope in command-line based programming.
5-
6-
Change directory to provide relative paths for doctests
7-
>>> import os
8-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
9-
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
10-
>>> os.chdir(datadir)
115
"""
126
from __future__ import (print_function, division, unicode_literals,
137
absolute_import)

nipype/conftest.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
import numpy
33
import os
44

5+
DATADIR = os.path.realpath(
6+
os.path.join(os.path.dirname(__file__), 'testing/data'))
7+
58

69
@pytest.fixture(autouse=True)
710
def add_np(doctest_namespace):
811
doctest_namespace['np'] = numpy
912
doctest_namespace['os'] = os
1013

11-
filepath = os.path.dirname(os.path.realpath(__file__))
12-
datadir = os.path.realpath(os.path.join(filepath, 'testing/data'))
13-
doctest_namespace["datadir"] = datadir
14+
doctest_namespace["datadir"] = DATADIR
15+
16+
17+
@pytest.fixture(autouse=True)
18+
def in_testing(request):
19+
# This seems to be a reliable way to distinguish tests from doctests
20+
if request.function is None:
21+
os.chdir(DATADIR)

nipype/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def get_nipype_gitversion():
153153
if sys.version_info <= (3, 4):
154154
REQUIRES.append('configparser')
155155

156-
TESTS_REQUIRES = ['pytest-cov', 'codecov']
156+
TESTS_REQUIRES = ['pytest-cov', 'codecov', 'pytest-xdist', 'pytest-env']
157157

158158
EXTRA_REQUIRES = {
159159
'doc': ['Sphinx>=1.4', 'numpydoc', 'matplotlib', 'pydotplus', 'pydot>=1.2.3'],

nipype/interfaces/afni/model.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
Examples
77
--------
88
See the docstrings of the individual classes for examples.
9-
.. testsetup::
10-
# Change directory to provide relative paths for doctests
11-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
12-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
13-
>>> os.chdir(datadir)
149
"""
1510
from __future__ import (print_function, division, unicode_literals,
1611
absolute_import)

nipype/interfaces/afni/preprocess.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
33
# vi: set ft=python sts=4 ts=4 sw=4 et:
44
"""AFNI preprocessing interfaces
5-
6-
Change directory to provide relative paths for doctests
7-
>>> import os
8-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
9-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
10-
>>> os.chdir(datadir)
115
"""
126
from __future__ import (print_function, division, unicode_literals,
137
absolute_import)

nipype/interfaces/afni/svm.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
33
# vi: set ft = python sts = 4 ts = 4 sw = 4 et:
44
"""Afni svm interfaces
5-
6-
Change directory to provide relative paths for doctests
7-
>>> import os
8-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
9-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
10-
>>> os.chdir(datadir)
115
"""
126
from __future__ import (print_function, division, unicode_literals,
137
absolute_import)

nipype/interfaces/afni/utils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
Examples
77
--------
88
See the docstrings of the individual classes for examples.
9-
.. testsetup::
10-
# Change directory to provide relative paths for doctests
11-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
12-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
13-
>>> os.chdir(datadir)
149
"""
1510
from __future__ import (print_function, division, unicode_literals,
1611
absolute_import)

nipype/interfaces/ants/legacy.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
# of the antsApplyTransform program. This implementation is here
55
# for backwards compatibility.
66
"""ANTS Apply Transforms interface
7-
8-
Change directory to provide relative paths for doctests
9-
>>> import os
10-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
11-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
12-
>>> os.chdir(datadir)
137
"""
148

159
from builtins import range

nipype/interfaces/ants/registration.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""The ants module provides basic functions for interfacing with ants
33
functions.
4-
5-
Change directory to provide relative paths for doctests
6-
>>> import os
7-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
8-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
9-
>>> os.chdir(datadir)
104
"""
115
from __future__ import (print_function, division, unicode_literals,
126
absolute_import)

nipype/interfaces/ants/resampling.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# -*- coding: utf-8 -*-
22
"""ANTS Apply Transforms interface
3-
4-
Change directory to provide relative paths for doctests
5-
>>> import os
6-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
7-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
8-
>>> os.chdir(datadir)
93
"""
104
from __future__ import (print_function, division, unicode_literals,
115
absolute_import)

nipype/interfaces/ants/segmentation.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# -*- coding: utf-8 -*-
22
"""The ants module provides basic functions for interfacing with ants functions.
3-
4-
Change directory to provide relative paths for doctests
5-
>>> import os
6-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
7-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
8-
>>> os.chdir(datadir)
9-
103
"""
114
from __future__ import (print_function, division, unicode_literals,
125
absolute_import)

nipype/interfaces/ants/utils.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# -*- coding: utf-8 -*-
22
"""ANTS Apply Transforms interface
3-
4-
Change directory to provide relative paths for doctests
5-
>>> import os
6-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
7-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
8-
>>> os.chdir(datadir)
93
"""
104
from __future__ import (print_function, division, unicode_literals,
115
absolute_import)

nipype/interfaces/ants/visualization.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# -*- coding: utf-8 -*-
22
"""The ants visualisation module provides basic functions based on ITK.
3-
Change directory to provide relative paths for doctests
4-
>>> import os
5-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
6-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
7-
>>> os.chdir(datadir)
83
"""
94
from __future__ import (print_function, division, unicode_literals,
105
absolute_import)

nipype/interfaces/bru2nii.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# -*- coding: utf-8 -*-
22
"""The bru2nii module provides basic functions for dicom conversion
3-
4-
Change directory to provide relative paths for doctests
5-
>>> import os
6-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
7-
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
8-
>>> os.chdir(datadir)
93
"""
104
from __future__ import (print_function, division, unicode_literals,
115
absolute_import)

nipype/interfaces/c3.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""The ants module provides basic functions for interfacing with ants
33
functions.
4-
5-
Change directory to provide relative paths for doctests
6-
>>> import os
7-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
8-
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
9-
>>> os.chdir(datadir)
104
"""
115
from __future__ import (print_function, division, unicode_literals,
126
absolute_import)

nipype/interfaces/camino/calib.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
Change directory to provide relative paths for doctests
4-
>>> import os
5-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
6-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
7-
>>> os.chdir(datadir)
8-
9-
"""
102
from __future__ import (print_function, division, unicode_literals,
113
absolute_import)
124

nipype/interfaces/camino/connectivity.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
Change directory to provide relative paths for doctests
4-
>>> import os
5-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
6-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
7-
>>> os.chdir(datadir)
8-
9-
"""
102
from __future__ import (print_function, division, unicode_literals,
113
absolute_import)
124
import os

nipype/interfaces/camino/convert.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
Change directory to provide relative paths for doctests
4-
>>> import os
5-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
6-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
7-
>>> os.chdir(datadir)
8-
9-
"""
102
from __future__ import (print_function, division, unicode_literals,
113
absolute_import)
124

nipype/interfaces/camino/dti.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
Change directory to provide relative paths for doctests
4-
>>> import os
5-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
6-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
7-
>>> os.chdir(datadir)
8-
9-
"""
102
from __future__ import (print_function, division, unicode_literals,
113
absolute_import)
124

nipype/interfaces/camino/odf.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
Change directory to provide relative paths for doctests
4-
>>> import os
5-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
6-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
7-
>>> os.chdir(datadir)
8-
9-
"""
102
from __future__ import (print_function, division, unicode_literals,
113
absolute_import)
124

nipype/interfaces/camino/utils.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
Change directory to provide relative paths for doctests
4-
>>> import os
5-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
6-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
7-
>>> os.chdir(datadir)
8-
9-
"""
102
from __future__ import (print_function, division, unicode_literals,
113
absolute_import)
124
import os

nipype/interfaces/camino2trackvis/convert.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""
33
Provides interfaces to various commands provided by Camino-Trackvis
4-
5-
Change directory to provide relative paths for doctests
6-
>>> import os
7-
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
8-
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
9-
>>> os.chdir(datadir)
10-
114
"""
125
from __future__ import (print_function, division, unicode_literals,
136
absolute_import)

0 commit comments

Comments
 (0)