Skip to content

Commit 6dd27a3

Browse files
authored
Merge pull request #1 from effigies/test/pytest_freesurfer
TEST: Some cleanups for #881
2 parents fdd26a2 + eaab253 commit 6dd27a3

File tree

5 files changed

+13
-28
lines changed

5 files changed

+13
-28
lines changed

.azure-pipelines/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
-I test_rstutils ^
101101
-I test_scaling ^
102102
-I test_wrapstruct ^
103-
-I test_io
103+
-I test_io
104104
displayName: 'Nose tests'
105105
condition: and(succeeded(), eq(variables['CHECK_TYPE'], 'nosetests'))
106106
- script: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ doc/source/reference
8585
venv/
8686
.buildbot.patch
8787
.vscode
88+
for_testing/

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ script:
187187
-I test_rstutils \
188188
-I test_scaling \
189189
-I test_wrapstruct \
190-
-I test_io
190+
-I test_io
191191
elif [ "${CHECK_TYPE}" == "test" ]; then
192192
# Change into an innocuous directory and find tests from installation
193193
mkdir for_testing

for_testing/.coveragerc

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

nibabel/freesurfer/tests/test_io.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,12 @@ def test_geometry():
9292
warnings.filterwarnings('always', category=DeprecationWarning)
9393
read_geometry(surf_path, read_metadata=True)
9494

95-
assert(
96-
any('volume information contained' in str(ww.message)
97-
for ww in w))
98-
assert(
99-
any('extension code' in str(ww.message) for ww in w))
95+
assert any('volume information contained' in str(ww.message) for ww in w)
96+
assert any('extension code' in str(ww.message) for ww in w)
10097
volume_info['head'] = [1, 2]
10198
with clear_and_catch_warnings() as w:
10299
write_geometry(surf_path, coords, faces, create_stamp, volume_info)
103-
assert(
104-
any('Unknown extension' in str(ww.message) for ww in w))
100+
assert any('Unknown extension' in str(ww.message) for ww in w)
105101
volume_info['a'] = 0
106102
with pytest.raises(ValueError):
107103
write_geometry(surf_path, coords, faces, create_stamp, volume_info)
@@ -146,7 +142,7 @@ def test_morph_data():
146142
new_path = 'test'
147143
write_morph_data(new_path, curv)
148144
curv2 = read_morph_data(new_path)
149-
assert np.array_equal (curv2, curv)
145+
assert np.array_equal(curv2, curv)
150146

151147

152148
def test_write_morph_data():
@@ -163,7 +159,7 @@ def test_write_morph_data():
163159

164160
with pytest.raises(ValueError):
165161
write_morph_data('test.curv', np.zeros(shape), big_num)
166-
# Windows 32-bit overflows Python int
162+
# Windows 32-bit overflows Python int
167163
if np.dtype(np.int) != np.dtype(np.int32):
168164
with pytest.raises(ValueError):
169165
write_morph_data('test.curv', strided_scalar((big_num,)))
@@ -272,12 +268,10 @@ def test_write_annot_fill_ctab():
272268
# values back.
273269
badannot = (10 * np.arange(nlabels, dtype=np.int32)).reshape(-1, 1)
274270
rgbal = np.hstack((rgba, badannot))
275-
print(labels)
276271
with clear_and_catch_warnings() as w:
277272
write_annot(annot_path, labels, rgbal, names, fill_ctab=False)
278-
assert (
279-
any('Annotation values in {} will be incorrect'.format(
280-
annot_path) == str(ww.message) for ww in w))
273+
assert any('Annotation values in {} will be incorrect'.format(annot_path) == str(ww.message)
274+
for ww in w)
281275
labels2, rgbal2, names2 = read_annot(annot_path, orig_ids=True)
282276
names2 = [n.decode('ascii') for n in names2]
283277
assert np.all(np.isclose(rgbal2[:, :4], rgba))
@@ -291,9 +285,8 @@ def test_write_annot_fill_ctab():
291285
rgbal[:, 2] * (2 ** 16))
292286
with clear_and_catch_warnings() as w:
293287
write_annot(annot_path, labels, rgbal, names, fill_ctab=False)
294-
assert(
295-
not any('Annotation values in {} will be incorrect'.format(
296-
annot_path) == str(ww.message) for ww in w))
288+
assert all('Annotation values in {} will be incorrect'.format(annot_path) != str(ww.message)
289+
for ww in w)
297290
labels2, rgbal2, names2 = read_annot(annot_path)
298291
names2 = [n.decode('ascii') for n in names2]
299292
assert np.all(np.isclose(rgbal2[:, :4], rgba))
@@ -356,7 +349,7 @@ def test_label():
356349
assert label.shape[0] <= 163842
357350

358351
labels, scalars = read_label(label_path, True)
359-
assert (np.all(labels == label))
352+
assert np.all(labels == label)
360353
assert len(labels) == len(scalars)
361354

362355

0 commit comments

Comments
 (0)