Skip to content

Commit c86c328

Browse files
authored
Merge pull request #818 from effigies/fix/pathnames
FIX: Test names of paths when calling path.iterdir()
2 parents 53ccf79 + e7268b8 commit c86c328

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

niworkflows/interfaces/norm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ def _get_settings(self):
169169
data_dir = load_data()
170170
# Get a list of settings files that match the flavor.
171171
filenames = [
172-
i for i in data_dir.iterdir() if i.startswith(filestart) and i.endswith(".json")
172+
path.name
173+
for path in data_dir.iterdir()
174+
if path.name.startswith(filestart) and path.name.endswith(".json")
173175
]
174176
# Return the settings files.
175177
return [str(data_dir / f) for f in sorted(filenames)]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
#
4+
# Copyright 2021 The NiPreps Developers <[email protected]>
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# We support and encourage derived works from this project, please read
19+
# about our expectations at
20+
#
21+
# https://www.nipreps.org/community/licensing/
22+
#
23+
from ..norm import SpatialNormalization
24+
25+
26+
def test_get_settings():
27+
norm = SpatialNormalization(moving='T1w', flavor='fast')
28+
settings = norm._get_settings()
29+
assert len(settings) == 1
30+
assert settings[0].split('/')[-1] == 't1w-mni_registration_fast_000.json'
31+
32+
norm = SpatialNormalization(moving='T1w', flavor='testing')
33+
settings = norm._get_settings()
34+
assert len(settings) == 3

0 commit comments

Comments
 (0)