Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
480211c3
There was a problem fetching the pipeline summary.
Commit
480211c3
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Test case for new removeDuplicates function
parent
90466b63
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_fsl_utils_path.py
+81
-2
81 additions, 2 deletions
tests/test_fsl_utils_path.py
with
81 additions
and
2 deletions
tests/test_fsl_utils_path.py
+
81
−
2
View file @
480211c3
...
@@ -327,6 +327,85 @@ def test_shallowest():
...
@@ -327,6 +327,85 @@ def test_shallowest():
assert
fslpath
.
shallowest
(
path
,
suffixes
)
==
output
assert
fslpath
.
shallowest
(
path
,
suffixes
)
==
output
def
test_removeDuplicates
():
allowedExts
=
fslimage
.
ALLOWED_EXTENSIONS
groups
=
fslimage
.
FILE_GROUPS
# [(files_to_create,
# [([paths], [expected]),
# ...
# ]),
# ...
# ]
allTests
=
[
([
'
file.hdr
'
,
'
file.img
'
],
[
([
'
file
'
],
[
'
file
'
]),
([
'
file.hdr
'
],
[
'
file.hdr
'
]),
([
'
file.img
'
],
[
'
file.img
'
]),
([
'
file.hdr
'
,
'
file.img
'
],
[
'
file.hdr
'
]),
([
'
file.img
'
,
'
file.hdr
'
],
[
'
file.img
'
]),
]),
([
'
file.hdr
'
,
'
file.img
'
,
'
file.blob
'
],
[
([
'
file
'
],
[
'
file
'
]),
([
'
file.hdr
'
],
[
'
file.hdr
'
]),
([
'
file.img
'
],
[
'
file.img
'
]),
([
'
file.hdr
'
,
'
file.img
'
],
[
'
file.hdr
'
]),
([
'
file.img
'
,
'
file.hdr
'
],
[
'
file.img
'
]),
]),
([
'
file.hdr
'
,
'
file.img
'
,
'
file.nii
'
],
[
([
'
file
'
],
[
'
file
'
]),
([
'
file.hdr
'
],
[
'
file.hdr
'
]),
([
'
file.img
'
],
[
'
file.img
'
]),
([
'
file.hdr
'
,
'
file.img
'
],
[
'
file.hdr
'
]),
([
'
file.img
'
,
'
file.hdr
'
],
[
'
file.img
'
]),
]),
([
'
001.hdr
'
,
'
001.img
'
,
'
002.hdr
'
,
'
002.img
'
,
'
003.hdr
'
,
'
003.img
'
],
[
([
'
001
'
,
'
002
'
,
'
003
'
],
[
'
001
'
,
'
002
'
,
'
003
'
]),
([
'
001.hdr
'
,
'
002.hdr
'
,
'
003.hdr
'
],
[
'
001.hdr
'
,
'
002.hdr
'
,
'
003.hdr
'
]),
([
'
001.img
'
,
'
002.img
'
,
'
003.img
'
],
[
'
001.img
'
,
'
002.img
'
,
'
003.img
'
]),
([
'
001.hdr
'
,
'
001.img
'
,
'
002.hdr
'
,
'
002.img
'
,
'
003.img
'
],
[
'
001.hdr
'
,
'
002.hdr
'
,
'
003.img
'
]),
([
'
001.hdr
'
,
'
001.img
'
,
'
002.hdr
'
,
'
002.img
'
,
'
003.hdr
'
,
'
003.img
'
],
[
'
001.hdr
'
,
'
002.hdr
'
,
'
003.hdr
'
]),
([
'
001.img
'
,
'
001.hdr
'
,
'
002.img
'
,
'
002.hdr
'
,
'
003.img
'
,
'
003.hdr
'
],
[
'
001.img
'
,
'
002.img
'
,
'
003.img
'
]),
])
]
workdir
=
tempfile
.
mkdtemp
()
try
:
for
files_to_create
,
tests
in
allTests
:
for
fn
in
files_to_create
:
with
open
(
op
.
join
(
workdir
,
fn
),
'
wt
'
)
as
f
:
f
.
write
(
'
{}
\n
'
.
format
(
fn
))
for
paths
,
expected
in
tests
:
paths
=
[
op
.
join
(
workdir
,
p
)
for
p
in
paths
]
result
=
fslpath
.
removeDuplicates
(
paths
,
allowedExts
,
groups
)
assert
result
==
[
op
.
join
(
workdir
,
e
)
for
e
in
expected
]
for
f
in
files_to_create
:
os
.
remove
(
op
.
join
(
workdir
,
f
))
finally
:
shutil
.
rmtree
(
workdir
)
def
test_getFileGroup
():
def
test_getFileGroup
():
allowedExts
=
fslimage
.
ALLOWED_EXTENSIONS
allowedExts
=
fslimage
.
ALLOWED_EXTENSIONS
...
@@ -571,8 +650,8 @@ def test_imcp_shouldPass(move=False):
...
@@ -571,8 +650,8 @@ def test_imcp_shouldPass(move=False):
src
=
op
.
join
(
indir
,
src
)
src
=
op
.
join
(
indir
,
src
)
if
move
:
fslpath
.
immv
(
src
,
imcp_dest
,
allowedExts
=
allowedExts
,
fileGroups
=
groups
)
if
move
:
fslpath
.
immv
(
src
,
imcp_dest
,
allowedExts
=
allowedExts
,
fileGroups
=
groups
,
overwrite
=
True
)
else
:
fslpath
.
imcp
(
src
,
imcp_dest
,
allowedExts
=
allowedExts
,
fileGroups
=
groups
)
else
:
fslpath
.
imcp
(
src
,
imcp_dest
,
allowedExts
=
allowedExts
,
fileGroups
=
groups
,
overwrite
=
True
)
copied
=
os
.
listdir
(
outdir
)
copied
=
os
.
listdir
(
outdir
)
copied
=
[
f
for
f
in
copied
if
op
.
isfile
(
op
.
join
(
outdir
,
f
))]
copied
=
[
f
for
f
in
copied
if
op
.
isfile
(
op
.
join
(
outdir
,
f
))]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment