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
1699706b
Commit
1699706b
authored
3 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Test that all temp files creatd by wrapper functions are deleted
parent
a55a39e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_wrappers/test_wrapperutils.py
+58
-0
58 additions, 0 deletions
tests/test_wrappers/test_wrapperutils.py
with
58 additions
and
0 deletions
tests/test_wrappers/test_wrapperutils.py
+
58
−
0
View file @
1699706b
...
@@ -876,3 +876,61 @@ def test_cmdwrapper_cmdonly_assert():
...
@@ -876,3 +876,61 @@ def test_cmdwrapper_cmdonly_assert():
assert
func
()[
0
].
strip
()
==
'
hello
'
assert
func
()[
0
].
strip
()
==
'
hello
'
os
.
remove
(
'
file
'
)
os
.
remove
(
'
file
'
)
assert
func
(
cmdonly
=
True
)
==
[
'
echo
'
,
'
hello
'
]
assert
func
(
cmdonly
=
True
)
==
[
'
echo
'
,
'
hello
'
]
def
test_fileOrArray_all_tempfiles_cleared
():
tempfiles
=
[]
@wutils.fileOrArray
(
'
in_
'
,
'
out
'
)
def
array
(
in_
,
out
):
tempfiles
.
extend
((
in_
,
out
))
i
=
np
.
loadtxt
(
in_
)
i
=
i
+
1
np
.
savetxt
(
out
,
i
)
arr
=
np
.
array
([[
1
,
2
],
[
3
,
4
]])
arrout
=
array
(
arr
,
wutils
.
LOAD
).
out
assert
np
.
all
(
np
.
isclose
(
arrout
,
arr
+
1
))
assert
len
(
tempfiles
)
==
2
assert
not
any
(
op
.
exists
(
f
)
for
f
in
tempfiles
)
def
test_fileOrImage_all_tempfiles_cleared
():
tempfiles
=
[]
@wutils.fileOrImage
(
'
in_
'
,
'
out
'
)
def
image
(
in_
,
out
):
tempfiles
.
extend
((
in_
,
out
))
i
=
nib
.
load
(
in_
)
i
=
nib
.
Nifti1Image
(
i
.
get_fdata
()
+
1
,
np
.
eye
(
4
))
i
.
to_filename
(
out
)
arr
=
np
.
array
([[
1
,
2
],
[
3
,
4
]])
img
=
nib
.
nifti1
.
Nifti1Image
(
arr
,
np
.
eye
(
4
))
imgout
=
image
(
img
,
wutils
.
LOAD
).
out
assert
np
.
all
(
np
.
isclose
(
imgout
.
get_fdata
(),
img
.
get_fdata
()
+
1
))
assert
len
(
tempfiles
)
==
2
assert
not
any
(
op
.
exists
(
f
)
for
f
in
tempfiles
)
def
test_fileOrText_all_tempfiles_cleared
():
tempfiles
=
[]
@wutils.fileOrText
(
'
in_
'
,
'
out
'
)
def
text
(
in_
,
out
):
tempfiles
.
extend
((
in_
,
out
))
with
open
(
in_
,
'
rt
'
)
as
inf
,
open
(
out
,
'
wt
'
)
as
outf
:
outf
.
write
(
inf
.
read
())
outf
.
write
(
'
456
'
)
txt
=
'
123
'
txtout
=
text
(
txt
,
wutils
.
LOAD
).
out
assert
txtout
==
'
123456
'
assert
len
(
tempfiles
)
==
2
assert
not
any
(
op
.
exists
(
f
)
for
f
in
tempfiles
)
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