Skip to content

Commit 7a4d5b5

Browse files
committed
RF: centralize import of decorators from numpy.testing
I kept receiving messages that imports from numpy.testing.decorators are deprecated (since 1.5 IIRC), so I found that some places still import them in the test files instead of centraly from nibabel.testing which already provides imports adaptor. So I RFed to avoid such imports, and moved a stub for @slow there too
1 parent ad0b13f commit 7a4d5b5

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

nibabel/nicom/tests/test_csareader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from nose.tools import (assert_true, assert_false, assert_equal, assert_raises)
1414

15-
from numpy.testing.decorators import skipif
15+
from ...testing import skipif
1616

1717
from nibabel.pydicom_compat import dicom_test, pydicom
1818
from .test_dicomwrappers import (IO_DATA_PATH, DATA)

nibabel/testing/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,18 @@
2121
try:
2222
from numpy.testing import dec
2323
skipif = dec.skipif
24+
slow = dec.slow
2425
except ImportError:
2526
from numpy.testing.decorators import skipif
27+
28+
# Recent (1.2) versions of numpy have this decorator
29+
try:
30+
from numpy.testing.decorators import slow
31+
except ImportError:
32+
def slow(t):
33+
t.slow = True
34+
return t
35+
2636
# Allow failed import of nose if not now running tests
2737
try:
2838
from nose.tools import (assert_equal, assert_not_equal,

nibabel/tests/nibabel_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from os import environ, listdir
55
from os.path import dirname, realpath, join as pjoin, isdir, exists
66

7-
from numpy.testing.decorators import skipif
7+
from ..testing import skipif
88

99

1010
def get_nibabel_data():

nibabel/tests/test_processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from numpy.testing import (assert_almost_equal,
3232
assert_array_equal)
33-
from numpy.testing.decorators import skipif
33+
from ..testing import skipif
3434

3535
from nose.tools import (assert_true, assert_false, assert_raises,
3636
assert_equal, assert_not_equal)

nibabel/tests/test_quaternions.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@
1111
import numpy as np
1212
from numpy import pi
1313

14-
# Recent (1.2) versions of numpy have this decorator
15-
try:
16-
from numpy.testing.decorators import slow
17-
except ImportError:
18-
def slow(t):
19-
t.slow = True
20-
return t
21-
14+
from ..testing import slow
2215
from nose.tools import assert_raises, assert_true, assert_false, \
2316
assert_equal
2417

nibabel/tests/test_viewers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ..optpkg import optional_package
1515
from ..viewers import OrthoSlicer3D
1616

17-
from numpy.testing.decorators import skipif
17+
from ..testing import skipif
1818
from numpy.testing import assert_array_equal, assert_equal
1919

2020
from nose.tools import assert_raises, assert_true

0 commit comments

Comments
 (0)