Skip to content

Commit 16f830f

Browse files
committed
TEST: Test fallback behavior of copyfile
Attempt to copy and link files from POSIX to FAT, verify we always copy without throwing errors
1 parent 14e8ac4 commit 16f830f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

nipype/utils/tests/test_filemanip.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
from tempfile import mkstemp, mkdtemp
77

8-
from nipype.testing import assert_equal, assert_true, assert_false
8+
from nipype.testing import assert_equal, assert_true, assert_false, TempFATFS
99
from nipype.utils.filemanip import (save_json, load_json,
1010
fname_presuffix, fnames_presuffix,
1111
hash_rename, check_forhash,
@@ -167,6 +167,27 @@ def test_linkchain():
167167
os.unlink(orig_hdr)
168168

169169

170+
def test_copyfallback():
171+
if os.name is not 'posix':
172+
return
173+
orig_img, orig_hdr = _temp_analyze_files()
174+
pth, imgname = os.path.split(orig_img)
175+
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+
190+
170191
def test_filename_to_list():
171192
x = filename_to_list('foo.nii')
172193
yield assert_equal, x, ['foo.nii']

0 commit comments

Comments
 (0)