Skip to content

Commit ae39e06

Browse files
committed
changed nosetools assert_true to assert in test_io.py
1 parent 979b439 commit ae39e06

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

nibabel/freesurfer/tests/test_io.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
from ...tmpdirs import InTemporaryDirectory
1111

12-
from nose.tools import assert_true
12+
13+
import pytest
1314
import numpy as np
1415
from numpy.testing import assert_equal, assert_raises, dec, assert_allclose, assert_array_equal
1516

@@ -92,13 +93,13 @@ def test_geometry():
9293
with clear_and_catch_warnings() as w:
9394
warnings.filterwarnings('always', category=DeprecationWarning)
9495
read_geometry(surf_path, read_metadata=True)
95-
assert_true(any('volume information contained' in str(ww.message)
96+
assert(any('volume information contained' in str(ww.message)
9697
for ww in w))
97-
assert_true(any('extension code' in str(ww.message) for ww in w))
98+
assert(any('extension code' in str(ww.message) for ww in w))
9899
volume_info['head'] = [1, 2]
99100
with clear_and_catch_warnings() as w:
100101
write_geometry(surf_path, coords, faces, create_stamp, volume_info)
101-
assert_true(any('Unknown extension' in str(ww.message) for ww in w))
102+
assert(any('Unknown extension' in str(ww.message) for ww in w))
102103
volume_info['a'] = 0
103104
assert_raises(ValueError, write_geometry, surf_path, coords,
104105
faces, create_stamp, volume_info)
@@ -137,8 +138,8 @@ def test_morph_data():
137138
"""Test IO of morphometry data file (eg. curvature)."""
138139
curv_path = pjoin(data_path, "surf", "%s.%s" % ("lh", "curv"))
139140
curv = read_morph_data(curv_path)
140-
assert_true(-1.0 < curv.min() < 0)
141-
assert_true(0 < curv.max() < 1.0)
141+
assert(-1.0 < curv.min() < 0)
142+
assert(0 < curv.max() < 1.0)
142143
with InTemporaryDirectory():
143144
new_path = 'test'
144145
write_morph_data(new_path, curv)
@@ -177,18 +178,18 @@ def test_annot():
177178
hash_ = _hash_file_content(annot_path)
178179

179180
labels, ctab, names = read_annot(annot_path)
180-
assert_true(labels.shape == (163842, ))
181-
assert_true(ctab.shape == (len(names), 5))
181+
assert(labels.shape == (163842, ))
182+
assert(ctab.shape == (len(names), 5))
182183

183184
labels_orig = None
184185
if a == 'aparc':
185186
labels_orig, _, _ = read_annot(annot_path, orig_ids=True)
186187
np.testing.assert_array_equal(labels == -1, labels_orig == 0)
187188
# Handle different version of fsaverage
188189
if hash_ == 'bf0b488994657435cdddac5f107d21e8':
189-
assert_true(np.sum(labels_orig == 0) == 13887)
190+
assert(np.sum(labels_orig == 0) == 13887)
190191
elif hash_ == 'd4f5b7cbc2ed363ac6fcf89e19353504':
191-
assert_true(np.sum(labels_orig == 1639705) == 13327)
192+
assert(np.sum(labels_orig == 1639705) == 13327)
192193
else:
193194
raise RuntimeError("Unknown freesurfer file. Please report "
194195
"the problem to the maintainer of nibabel.")
@@ -272,7 +273,7 @@ def test_write_annot_fill_ctab():
272273
print(labels)
273274
with clear_and_catch_warnings() as w:
274275
write_annot(annot_path, labels, rgbal, names, fill_ctab=False)
275-
assert_true(
276+
assert(
276277
any('Annotation values in {} will be incorrect'.format(
277278
annot_path) == str(ww.message) for ww in w))
278279
labels2, rgbal2, names2 = read_annot(annot_path, orig_ids=True)
@@ -288,7 +289,7 @@ def test_write_annot_fill_ctab():
288289
rgbal[:, 2] * (2 ** 16))
289290
with clear_and_catch_warnings() as w:
290291
write_annot(annot_path, labels, rgbal, names, fill_ctab=False)
291-
assert_true(
292+
assert(
292293
not any('Annotation values in {} will be incorrect'.format(
293294
annot_path) == str(ww.message) for ww in w))
294295
labels2, rgbal2, names2 = read_annot(annot_path)
@@ -348,13 +349,13 @@ def test_label():
348349
label_path = pjoin(data_path, "label", "lh.cortex.label")
349350
label = read_label(label_path)
350351
# XXX : test more
351-
assert_true(label.min() >= 0)
352-
assert_true(label.max() <= 163841)
353-
assert_true(label.shape[0] <= 163842)
352+
assert(label.min() >= 0)
353+
assert(label.max() <= 163841)
354+
assert(label.shape[0] <= 163842)
354355

355356
labels, scalars = read_label(label_path, True)
356-
assert_true(np.all(labels == label))
357-
assert_true(len(labels) == len(scalars))
357+
assert(np.all(labels == label))
358+
assert(len(labels) == len(scalars))
358359

359360

360361
def test_write_annot_maxstruct():

0 commit comments

Comments
 (0)