|
4 | 4 |
|
5 | 5 | import os |
6 | 6 | from tempfile import mkstemp, mkdtemp |
| 7 | +import warnings |
7 | 8 |
|
8 | 9 | from nipype.testing import assert_equal, assert_true, assert_false, TempFATFS |
9 | 10 | from nipype.utils.filemanip import (save_json, load_json, |
@@ -173,21 +174,29 @@ def test_copyfallback(): |
173 | 174 | orig_img, orig_hdr = _temp_analyze_files() |
174 | 175 | pth, imgname = os.path.split(orig_img) |
175 | 176 | pth, hdrname = os.path.split(orig_hdr) |
176 | | - with TempFATFS() as fatdir: |
177 | | - tgt_img = os.path.join(fatdir, imgname) |
178 | | - tgt_hdr = os.path.join(fatdir, hdrname) |
179 | | - for copy in (True, False): |
180 | | - for use_hardlink in (True, False): |
181 | | - copyfile(orig_img, tgt_img, copy=copy, |
182 | | - use_hardlink=use_hardlink) |
183 | | - yield assert_true, os.path.exists(tgt_img) |
184 | | - yield assert_true, os.path.exists(tgt_hdr) |
185 | | - yield assert_false, os.path.islink(tgt_img) |
186 | | - yield assert_false, os.path.islink(tgt_hdr) |
187 | | - yield assert_false, os.path.samefile(orig_img, tgt_img) |
188 | | - yield assert_false, os.path.samefile(orig_hdr, tgt_hdr) |
189 | | - os.unlink(tgt_img) |
190 | | - os.unlink(tgt_hdr) |
| 177 | + try: |
| 178 | + fatfs = TempFATFS() |
| 179 | + except IOError: |
| 180 | + warnings.warn('Fuse mount failed. copyfile fallback tests skipped.') |
| 181 | + else: |
| 182 | + with fatfs as fatdir: |
| 183 | + tgt_img = os.path.join(fatdir, imgname) |
| 184 | + tgt_hdr = os.path.join(fatdir, hdrname) |
| 185 | + for copy in (True, False): |
| 186 | + for use_hardlink in (True, False): |
| 187 | + copyfile(orig_img, tgt_img, copy=copy, |
| 188 | + use_hardlink=use_hardlink) |
| 189 | + yield assert_true, os.path.exists(tgt_img) |
| 190 | + yield assert_true, os.path.exists(tgt_hdr) |
| 191 | + yield assert_false, os.path.islink(tgt_img) |
| 192 | + yield assert_false, os.path.islink(tgt_hdr) |
| 193 | + yield assert_false, os.path.samefile(orig_img, tgt_img) |
| 194 | + yield assert_false, os.path.samefile(orig_hdr, tgt_hdr) |
| 195 | + os.unlink(tgt_img) |
| 196 | + os.unlink(tgt_hdr) |
| 197 | + finally: |
| 198 | + os.unlink(orig_img) |
| 199 | + os.unlink(orig_hdr) |
191 | 200 |
|
192 | 201 |
|
193 | 202 | def test_filename_to_list(): |
|
0 commit comments