Skip to content

Commit

Permalink
TEST: Raise SkipTest when TempFATFS fails
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Mar 25, 2020
1 parent bfaea0e commit 858d2dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions nipype/testing/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
import os
import warnings
import subprocess
from mock import patch, MagicMock
from unittest.mock import patch, MagicMock
from unittest import SkipTest
from nipype.testing.utils import TempFATFS


def test_tempfatfs():
try:
fatfs = TempFATFS()
except (IOError, OSError):
warnings.warn("Cannot mount FAT filesystems with FUSE")
else:
with fatfs as tmp_dir:
assert os.path.exists(tmp_dir)
raise SkipTest("Cannot mount FAT filesystems with FUSE")
with fatfs as tmp_dir:
assert os.path.exists(tmp_dir)


@patch(
Expand Down
36 changes: 18 additions & 18 deletions nipype/utils/tests/test_filemanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import warnings
from pathlib import Path

import mock
from unittest import mock, SkipTest
import pytest
from ...testing import TempFATFS
from ...utils.filemanip import (
Expand Down Expand Up @@ -238,22 +238,22 @@ def test_copyfallback(_temp_analyze_files):
try:
fatfs = TempFATFS()
except (IOError, OSError):
warnings.warn("Fuse mount failed. copyfile fallback tests skipped.")
else:
with fatfs as fatdir:
tgt_img = os.path.join(fatdir, imgname)
tgt_hdr = os.path.join(fatdir, hdrname)
for copy in (True, False):
for use_hardlink in (True, False):
copyfile(orig_img, tgt_img, copy=copy, use_hardlink=use_hardlink)
assert os.path.exists(tgt_img)
assert os.path.exists(tgt_hdr)
assert not os.path.islink(tgt_img)
assert not os.path.islink(tgt_hdr)
assert not os.path.samefile(orig_img, tgt_img)
assert not os.path.samefile(orig_hdr, tgt_hdr)
os.unlink(tgt_img)
os.unlink(tgt_hdr)
raise SkipTest("Fuse mount failed. copyfile fallback tests skipped.")

with fatfs as fatdir:
tgt_img = os.path.join(fatdir, imgname)
tgt_hdr = os.path.join(fatdir, hdrname)
for copy in (True, False):
for use_hardlink in (True, False):
copyfile(orig_img, tgt_img, copy=copy, use_hardlink=use_hardlink)
assert os.path.exists(tgt_img)
assert os.path.exists(tgt_hdr)
assert not os.path.islink(tgt_img)
assert not os.path.islink(tgt_hdr)
assert not os.path.samefile(orig_img, tgt_img)
assert not os.path.samefile(orig_hdr, tgt_hdr)
os.unlink(tgt_img)
os.unlink(tgt_hdr)


def test_get_related_files(_temp_analyze_files):
Expand Down Expand Up @@ -295,7 +295,7 @@ def test_ensure_list(filename, expected):


@pytest.mark.parametrize(
"list, expected", [(["foo.nii"], "foo.nii"), (["foo", "bar"], ["foo", "bar"]),]
"list, expected", [(["foo.nii"], "foo.nii"), (["foo", "bar"], ["foo", "bar"])]
)
def test_simplify_list(list, expected):
x = simplify_list(list)
Expand Down

0 comments on commit 858d2dd

Please sign in to comment.