Skip to content

Commit d57022c

Browse files
committed
fix: improve test so that it raises at the right point [skip ds005][skip ds054][skip ds210][skip tests]
before this change, tests would break because templateflow attempts to use home first, and the docker run command would have mounted it with readonly. now this is implemented separately, and a safe new $HOME mocked. Close #1777.
1 parent 0922287 commit d57022c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ jobs:
226226
no_output_timeout: 2h
227227
command: |
228228
docker run -ti --rm=false \
229-
-e TEST_READONLY_FILESYSTEM=1 -v $HOME:/home/fmriprep:ro \
229+
-e TEST_READONLY_FILESYSTEM=1 -v $HOME:/home/readonly:ro \
230230
--entrypoint="pytest" poldracklab/fmriprep:latest \
231231
/src/fmriprep/fmriprep -svx --doctest-modules
232232

fmriprep/cli/tests/test_version.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,17 @@ def mock_get(*args, **kwargs):
166166

167167
def test_readonly(tmp_path, monkeypatch):
168168
"""Test behavior when $HOME/.cache/fmriprep/latest can't be written out."""
169-
if getenv('TEST_READONLY_FILESYSTEM'):
170-
cachedir = Path(getenv('HOME')) / '.cache'
171-
else:
172-
monkeypatch.setenv('HOME', str(tmp_path))
173-
cachedir = tmp_path / '.cache'
169+
home_path = Path('/home/readonly') if getenv('TEST_READONLY_FILESYSTEM') \
170+
else tmp_path
171+
monkeypatch.setenv('HOME', str(home_path))
172+
cachedir = home_path / '.cache'
173+
174+
if getenv('TEST_READONLY_FILESYSTEM') is None:
174175
cachedir.mkdir(mode=0o555, exist_ok=True)
175176

176177
# Make sure creating the folder will raise the exception.
177178
with pytest.raises(OSError):
178-
(cachedir / 'fmriprep').mkdir()
179+
(cachedir / 'fmriprep').mkdir(parents=True)
179180

180181
# Should not raise
181182
check_latest()

0 commit comments

Comments
 (0)