|
3 | 3 | from __future__ import division, print_function, absolute_import
|
4 | 4 |
|
5 | 5 | import sys
|
| 6 | +import os |
6 | 7 | import warnings
|
7 | 8 |
|
8 | 9 | import numpy as np
|
9 | 10 |
|
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 |
12 | 12 | from ..testing import (error_warnings, suppress_warnings,
|
13 | 13 | 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) |
15 | 15 |
|
16 | 16 |
|
17 | 17 | def assert_warn_len_equal(mod, n_in_context):
|
@@ -163,3 +163,26 @@ def test_assert_re_in():
|
163 | 163 |
|
164 | 164 | # Shouldn't "match" the empty list
|
165 | 165 | 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