Skip to content

Commit 641feaa

Browse files
committed
TEST: Test new test_data function
1 parent c54b696 commit 641feaa

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

nibabel/tests/test_testing.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
from __future__ import division, print_function, absolute_import
44

55
import sys
6+
import os
67
import warnings
78

89
import numpy as np
910

10-
from nose.tools import assert_equal
11-
from nose.tools import assert_raises
11+
from nose.tools import assert_equal, assert_true, assert_false, assert_raises
1212
from ..testing import (error_warnings, suppress_warnings,
1313
clear_and_catch_warnings, assert_allclose_safely,
14-
get_fresh_mod, assert_re_in)
14+
get_fresh_mod, assert_re_in, test_data, data_path)
1515

1616

1717
def assert_warn_len_equal(mod, n_in_context):
@@ -163,3 +163,26 @@ def test_assert_re_in():
163163

164164
# Shouldn't "match" the empty list
165165
assert_raises(AssertionError, assert_re_in, "", [])
166+
167+
168+
def test_test_data():
169+
assert_equal(test_data(), data_path)
170+
assert_equal(test_data(),
171+
os.path.abspath(os.path.join(os.path.dirname(__file__),
172+
'..', 'tests', 'data')))
173+
for subdir in ('nicom', 'gifti', 'externals'):
174+
assert_equal(test_data(subdir), data_path[:-10] + '%s/tests/data' % subdir)
175+
assert_true(os.path.exists(test_data(subdir)))
176+
assert_false(os.path.exists(test_data(subdir, 'doesnotexist')))
177+
178+
for subdir in ('freesurfer', 'doesnotexist'):
179+
with assert_raises(ValueError):
180+
test_data(subdir)
181+
182+
assert_false(os.path.exists(test_data(None, 'doesnotexist')))
183+
184+
for subdir, fname in [('gifti', 'ascii.gii'),
185+
('nicom', '0.dcm'),
186+
('externals', 'example_1.nc'),
187+
(None, 'empty.tck')]:
188+
assert_true(os.path.exists(test_data(subdir, fname)))

0 commit comments

Comments
 (0)