Skip to content

Commit 1faade2

Browse files
committed
RF: Skip test for python < 2.6 and pydicom < 1.0
Move pydicom import back to top level of module since we need its version info for skipping the test, plus this removes duplicate logic for importing 'pydicom' vs 'dicom'. Updated test_csa_header_read to use the top level import as well.
1 parent 854b817 commit 1faade2

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

nibabel/nicom/tests/test_csareader.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" Testing Siemens CSA header reader
22
"""
3+
import sys
34
from os.path import join as pjoin
45
from copy import deepcopy
56
import gzip
@@ -11,9 +12,12 @@
1112

1213
from nose.tools import (assert_true, assert_false, assert_equal, assert_raises)
1314

15+
from numpy.testing.decorators import skipif
1416

1517
from .test_dicomwrappers import (have_dicom, dicom_test,
1618
IO_DATA_PATH, DATA, DATA_FILE)
19+
if have_dicom:
20+
from .test_dicomwrappers import pydicom
1721

1822
CSA2_B0 = open(pjoin(IO_DATA_PATH, 'csa2_b0.bin'), 'rb').read()
1923
CSA2_B1000 = open(pjoin(IO_DATA_PATH, 'csa2_b1000.bin'), 'rb').read()
@@ -31,11 +35,7 @@ def test_csa_header_read():
3135
assert_true(csa.is_mosaic(hdr))
3236
# Get a shallow copy of the data, lacking the CSA marker
3337
# Need to do it this way because del appears broken in pydicom 0.9.7
34-
try:
35-
from dicom.dataset import Dataset
36-
except ImportError:
37-
from pydicom.dataset import Dataset
38-
data2 = Dataset()
38+
data2 = pydicom.dataset.Dataset()
3939
for element in DATA:
4040
if (element.tag.group, element.tag.elem) != (0x29, 0x10):
4141
data2.add(element)
@@ -132,16 +132,14 @@ def test_ice_dims():
132132

133133

134134
@dicom_test
135+
@skipif(sys.version_info < (2,7) and pydicom.__version__ < '1.0',
136+
'Known issue for python 2.6 and pydicom < 1.0')
135137
def test_missing_csa_elem():
136138
# Test that we get None instead of raising an Exception when the file has
137139
# the PrivateCreator element for the CSA dict but not the element with the
138140
# actual CSA header (perhaps due to anonymization)
139-
try:
140-
from dicom.tag import Tag
141-
except ImportError:
142-
from pydicom.tag import Tag
143141
dcm = deepcopy(DATA)
144-
csa_tag = Tag(0x29, 0x1010)
142+
csa_tag = pydicom.dataset.Tag(0x29, 0x1010)
145143
del dcm[csa_tag]
146144
hdr = csa.get_csa_header(dcm, 'image')
147145
assert_equal(hdr, None)

0 commit comments

Comments
 (0)