Skip to content

Commit 35f83b9

Browse files
committed
TEST: Raise SkipTest when TempFATFS fails
1 parent 46b505c commit 35f83b9

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
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 & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
# vi: set ft=python sts=4 ts=4 sw=4 et:
44
import os
55
import time
6-
import warnings
76
from pathlib import Path
87

9-
import mock
8+
from unittest import mock, SkipTest
109
import pytest
1110
from ...testing import TempFATFS
1211
from ...utils.filemanip import (
@@ -238,22 +237,22 @@ def test_copyfallback(_temp_analyze_files):
238237
try:
239238
fatfs = TempFATFS()
240239
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)
240+
raise SkipTest("Fuse mount failed. copyfile fallback tests skipped.")
241+
242+
with fatfs as fatdir:
243+
tgt_img = os.path.join(fatdir, imgname)
244+
tgt_hdr = os.path.join(fatdir, hdrname)
245+
for copy in (True, False):
246+
for use_hardlink in (True, False):
247+
copyfile(orig_img, tgt_img, copy=copy, use_hardlink=use_hardlink)
248+
assert os.path.exists(tgt_img)
249+
assert os.path.exists(tgt_hdr)
250+
assert not os.path.islink(tgt_img)
251+
assert not os.path.islink(tgt_hdr)
252+
assert not os.path.samefile(orig_img, tgt_img)
253+
assert not os.path.samefile(orig_hdr, tgt_hdr)
254+
os.unlink(tgt_img)
255+
os.unlink(tgt_hdr)
257256

258257

259258
def test_get_related_files(_temp_analyze_files):
@@ -295,7 +294,7 @@ def test_ensure_list(filename, expected):
295294

296295

297296
@pytest.mark.parametrize(
298-
"list, expected", [(["foo.nii"], "foo.nii"), (["foo", "bar"], ["foo", "bar"]),]
297+
"list, expected", [(["foo.nii"], "foo.nii"), (["foo", "bar"], ["foo", "bar"])]
299298
)
300299
def test_simplify_list(list, expected):
301300
x = simplify_list(list)

0 commit comments

Comments
 (0)