Skip to content

Commit 0d9ff3d

Browse files
committed
TEST: Copy fallback tests optional
Should pass on at least one CI server, but a hard FUSE requirement is probably too much to demand just to test nipype.
1 parent 5a382ac commit 0d9ff3d

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

nipype/utils/tests/test_filemanip.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import os
66
from tempfile import mkstemp, mkdtemp
7+
import warnings
78

89
from nipype.testing import assert_equal, assert_true, assert_false, TempFATFS
910
from nipype.utils.filemanip import (save_json, load_json,
@@ -173,21 +174,29 @@ def test_copyfallback():
173174
orig_img, orig_hdr = _temp_analyze_files()
174175
pth, imgname = os.path.split(orig_img)
175176
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)
191200

192201

193202
def test_filename_to_list():

0 commit comments

Comments
 (0)