Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
conda
installer
Commits
1a60aedb
Commit
1a60aedb
authored
Oct 25, 2021
by
Paul McCarthy
🚵
Browse files
TEST: run tests in tempdir to avoid writing/clobbering files in cwd
parent
dcd212f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
test/test_installer.py
View file @
1a60aedb
...
...
@@ -160,58 +160,63 @@ def check_install(homedir, destdir, version):
def
test_installer_normal_interactive_usage
():
with
installer_server
()
as
srv
:
with
mock
.
patch
(
'fslinstaller.FSL_INSTALLER_MANIFEST'
,
'{}/manifest.json'
.
format
(
srv
.
url
)):
# accept rel/abs paths
for
i
in
range
(
3
):
with
inst
.
tempdir
()
as
cwd
:
dests
=
[
'fsl'
,
op
.
join
(
'.'
,
'fsl'
),
op
.
abspath
(
'fsl'
)]
dest
=
dests
[
i
]
with
mock_input
(
dest
):
inst
.
main
([
'--homedir'
,
cwd
])
check_install
(
cwd
,
dest
,
'6.2.0'
)
shutil
.
rmtree
(
dest
)
with
inst
.
tempdir
():
with
installer_server
()
as
srv
:
with
mock
.
patch
(
'fslinstaller.FSL_INSTALLER_MANIFEST'
,
'{}/manifest.json'
.
format
(
srv
.
url
)):
# accept rel/abs paths
for
i
in
range
(
3
):
with
inst
.
tempdir
()
as
cwd
:
dests
=
[
'fsl'
,
op
.
join
(
'.'
,
'fsl'
),
op
.
abspath
(
'fsl'
)]
dest
=
dests
[
i
]
with
mock_input
(
dest
):
inst
.
main
([
'--homedir'
,
cwd
])
check_install
(
cwd
,
dest
,
'6.2.0'
)
shutil
.
rmtree
(
dest
)
def
test_installer_list_versions
():
platform
=
inst
.
Context
.
identify_platform
()
with
installer_server
()
as
srv
:
with
mock
.
patch
(
'fslinstaller.FSL_INSTALLER_MANIFEST'
,
'{}/manifest.json'
.
format
(
srv
.
url
)):
with
inst
.
tempdir
()
as
cwd
:
with
CaptureStdout
()
as
cap
:
with
pytest
.
raises
(
SystemExit
)
as
e
:
inst
.
main
([
'--listversions'
])
assert
e
.
value
.
code
==
0
with
inst
.
tempdir
():
with
installer_server
()
as
srv
:
with
mock
.
patch
(
'fslinstaller.FSL_INSTALLER_MANIFEST'
,
'{}/manifest.json'
.
format
(
srv
.
url
)):
with
inst
.
tempdir
()
as
cwd
:
with
CaptureStdout
()
as
cap
:
with
pytest
.
raises
(
SystemExit
)
as
e
:
inst
.
main
([
'--listversions'
])
assert
e
.
value
.
code
==
0
out
=
strip_ansi_escape_sequences
(
cap
.
stdout
)
lines
=
out
.
split
(
'
\n
'
)
out
=
strip_ansi_escape_sequences
(
cap
.
stdout
)
lines
=
out
.
split
(
'
\n
'
)
assert
'6.1.0'
in
lines
assert
'6.2.0'
in
lines
assert
' {} {}/env-6.1.0.yml'
.
format
(
platform
,
srv
.
url
)
in
lines
assert
' {} {}/env-6.2.0.yml'
.
format
(
platform
,
srv
.
url
)
in
lines
assert
'6.1.0'
in
lines
assert
'6.2.0'
in
lines
assert
' {} {}/env-6.1.0.yml'
.
format
(
platform
,
srv
.
url
)
in
lines
assert
' {} {}/env-6.2.0.yml'
.
format
(
platform
,
srv
.
url
)
in
lines
def
test_installer_normal_cli_usage
():
with
installer_server
()
as
srv
:
with
mock
.
patch
(
'fslinstaller.FSL_INSTALLER_MANIFEST'
,
'{}/manifest.json'
.
format
(
srv
.
url
)):
# accept rel/abs paths
for
i
in
range
(
3
):
with
inst
.
tempdir
():
with
installer_server
()
as
srv
:
with
mock
.
patch
(
'fslinstaller.FSL_INSTALLER_MANIFEST'
,
'{}/manifest.json'
.
format
(
srv
.
url
)):
# accept rel/abs paths
for
i
in
range
(
3
):
with
inst
.
tempdir
()
as
cwd
:
dests
=
[
'fsl'
,
op
.
join
(
'.'
,
'fsl'
),
op
.
abspath
(
'fsl'
)]
dest
=
dests
[
i
]
inst
.
main
([
'--homedir'
,
cwd
,
'--dest'
,
dest
])
check_install
(
cwd
,
dest
,
'6.2.0'
)
shutil
.
rmtree
(
dest
)
# install specific version
with
inst
.
tempdir
()
as
cwd
:
dests
=
[
'fsl'
,
op
.
join
(
'.'
,
'fsl'
),
op
.
abspath
(
'fsl'
)]
dest
=
dests
[
i
]
inst
.
main
([
'--homedir'
,
cwd
,
'--dest'
,
dest
])
check_install
(
cwd
,
dest
,
'6.2.0'
)
shutil
.
rmtree
(
dest
)
# install specific version
with
inst
.
tempdir
()
as
cwd
:
inst
.
main
([
'--homedir'
,
cwd
,
'--dest'
,
'fsl'
,
'--fslversion'
,
'6.1.0'
])
check_install
(
cwd
,
'fsl'
,
'6.1.0'
)
shutil
.
rmtree
(
'fsl'
)
inst
.
main
([
'--homedir'
,
cwd
,
'--dest'
,
'fsl'
,
'--fslversion'
,
'6.1.0'
])
check_install
(
cwd
,
'fsl'
,
'6.1.0'
)
shutil
.
rmtree
(
'fsl'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment