Skip to content

TEST: Ignore atime in test_filemanip.test_recopy #1634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions nipype/utils/tests/test_filemanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
import numpy as np


def _ignore_atime(stat):
return stat[:7] + stat[8:]


def test_split_filename():
res = split_filename('foo.nii')
yield assert_equal, res, ('', 'foo', '.nii')
Expand Down Expand Up @@ -192,27 +196,33 @@ def test_recopy():
# tick
if copy and not use_hardlink and hashmethod == 'timestamp':
continue

copyfile(orig_img, new_img, **kwargs)
img_stat = os.stat(new_img)
hdr_stat = os.stat(new_hdr)
img_stat = _ignore_atime(os.stat(new_img))
hdr_stat = _ignore_atime(os.stat(new_hdr))
copyfile(orig_img, new_img, **kwargs)
err_msg = "Regular - OS: {}; Copy: {}; Hardlink: {}".format(
os.name, copy, use_hardlink)
yield assert_equal, img_stat, os.stat(new_img), err_msg
yield assert_equal, hdr_stat, os.stat(new_hdr), err_msg
yield (assert_equal, img_stat, _ignore_atime(os.stat(new_img)),
err_msg)
yield (assert_equal, hdr_stat, _ignore_atime(os.stat(new_hdr)),
err_msg)
os.unlink(new_img)
os.unlink(new_hdr)

copyfile(img_link, new_img, **kwargs)
img_stat = os.stat(new_img)
hdr_stat = os.stat(new_hdr)
img_stat = _ignore_atime(os.stat(new_img))
hdr_stat = _ignore_atime(os.stat(new_hdr))
copyfile(img_link, new_img, **kwargs)
err_msg = "Symlink - OS: {}; Copy: {}; Hardlink: {}".format(
os.name, copy, use_hardlink)
yield assert_equal, img_stat, os.stat(new_img), err_msg
yield assert_equal, hdr_stat, os.stat(new_hdr), err_msg
yield (assert_equal, img_stat, _ignore_atime(os.stat(new_img)),
err_msg)
yield (assert_equal, hdr_stat, _ignore_atime(os.stat(new_hdr)),
err_msg)
os.unlink(new_img)
os.unlink(new_hdr)

os.unlink(img_link)
os.unlink(hdr_link)
os.unlink(orig_img)
Expand Down