Skip to content

Commit 858d2dd

Browse files
committed
TEST: Raise SkipTest when TempFATFS fails
1 parent bfaea0e commit 858d2dd

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

nipype/testing/tests/test_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
import os
88
import warnings
99
import subprocess
10-
from mock import patch, MagicMock
10+
from unittest.mock import patch, MagicMock
11+
from unittest import SkipTest
1112
from nipype.testing.utils import TempFATFS
1213

1314

1415
def test_tempfatfs():
1516
try:
1617
fatfs = TempFATFS()
1718
except (IOError, OSError):
18-
warnings.warn("Cannot mount FAT filesystems with FUSE")
19-
else:
20-
with fatfs as tmp_dir:
21-
assert os.path.exists(tmp_dir)
19+
raise SkipTest("Cannot mount FAT filesystems with FUSE")
20+
with fatfs as tmp_dir:
21+
assert os.path.exists(tmp_dir)
2222

2323

2424
@patch(

nipype/utils/tests/test_filemanip.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import warnings
77
from pathlib import Path
88

9-
import mock
9+
from unittest import mock, SkipTest
1010
import pytest
1111
from ...testing import TempFATFS
1212
from ...utils.filemanip import (
@@ -238,22 +238,22 @@ def test_copyfallback(_temp_analyze_files):
238238
try:
239239
fatfs = TempFATFS()
240240
except (IOError, OSError):
241-
warnings.warn("Fuse mount failed. copyfile fallback tests skipped.")
242-
else:
243-
with fatfs as fatdir:
244-
tgt_img = os.path.join(fatdir, imgname)
245-
tgt_hdr = os.path.join(fatdir, hdrname)
246-
for copy in (True, False):
247-
for use_hardlink in (True, False):
248-
copyfile(orig_img, tgt_img, copy=copy, use_hardlink=use_hardlink)
249-
assert os.path.exists(tgt_img)
250-
assert os.path.exists(tgt_hdr)
251-
assert not os.path.islink(tgt_img)
252-
assert not os.path.islink(tgt_hdr)
253-
assert not os.path.samefile(orig_img, tgt_img)
254-
assert not os.path.samefile(orig_hdr, tgt_hdr)
255-
os.unlink(tgt_img)
256-
os.unlink(tgt_hdr)
241+
raise SkipTest("Fuse mount failed. copyfile fallback tests skipped.")
242+
243+
with fatfs as fatdir:
244+
tgt_img = os.path.join(fatdir, imgname)
245+
tgt_hdr = os.path.join(fatdir, hdrname)
246+
for copy in (True, False):
247+
for use_hardlink in (True, False):
248+
copyfile(orig_img, tgt_img, copy=copy, use_hardlink=use_hardlink)
249+
assert os.path.exists(tgt_img)
250+
assert os.path.exists(tgt_hdr)
251+
assert not os.path.islink(tgt_img)
252+
assert not os.path.islink(tgt_hdr)
253+
assert not os.path.samefile(orig_img, tgt_img)
254+
assert not os.path.samefile(orig_hdr, tgt_hdr)
255+
os.unlink(tgt_img)
256+
os.unlink(tgt_hdr)
257257

258258

259259
def test_get_related_files(_temp_analyze_files):
@@ -295,7 +295,7 @@ def test_ensure_list(filename, expected):
295295

296296

297297
@pytest.mark.parametrize(
298-
"list, expected", [(["foo.nii"], "foo.nii"), (["foo", "bar"], ["foo", "bar"]),]
298+
"list, expected", [(["foo.nii"], "foo.nii"), (["foo", "bar"], ["foo", "bar"])]
299299
)
300300
def test_simplify_list(list, expected):
301301
x = simplify_list(list)

0 commit comments

Comments
 (0)