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
51a50880
"git@git.fmrib.ox.ac.uk:fsl/win-pytreat.git" did not exist on "5dc48d4801ec782482a9d06b91c4179eb86e1dd4"
Commit
51a50880
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
makedirs raises OSError, not IOError
parent
6e7e48c0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_settings.py
+19
-19
19 additions, 19 deletions
tests/test_settings.py
with
19 additions
and
19 deletions
tests/test_settings.py
+
19
−
19
View file @
51a50880
...
@@ -18,7 +18,7 @@ try:
...
@@ -18,7 +18,7 @@ try:
# python 2
# python 2
except
:
except
:
import
mock
import
mock
import
pytest
import
pytest
import
tests
import
tests
...
@@ -42,7 +42,7 @@ def test_initialise():
...
@@ -42,7 +42,7 @@ def test_initialise():
settings
.
clear
()
settings
.
clear
()
with
tests
.
testdir
()
as
testdir
:
with
tests
.
testdir
()
as
testdir
:
settings
.
initialise
(
cfgid
=
'
test
'
,
cfgdir
=
testdir
,
writeOnExit
=
False
)
settings
.
initialise
(
cfgid
=
'
test
'
,
cfgdir
=
testdir
,
writeOnExit
=
False
)
assert
settings
.
settings
.
configID
==
'
test
'
assert
settings
.
settings
.
configID
==
'
test
'
...
@@ -56,7 +56,7 @@ def test_initialise():
...
@@ -56,7 +56,7 @@ def test_initialise():
def
test_init_configDir
():
def
test_init_configDir
():
# config dir on linux
# config dir on linux
with
tests
.
testdir
()
as
testdir
,
\
with
tests
.
testdir
()
as
testdir
,
\
mock
.
patch
(
'
fsl.utils.settings.platform.system
'
,
return_value
=
'
linux
'
),
\
mock
.
patch
(
'
fsl.utils.settings.platform.system
'
,
return_value
=
'
linux
'
),
\
mock
.
patch
(
'
fsl.utils.settings.op.expanduser
'
,
return_value
=
testdir
):
mock
.
patch
(
'
fsl.utils.settings.op.expanduser
'
,
return_value
=
testdir
):
...
@@ -96,7 +96,7 @@ def test_init_configDir():
...
@@ -96,7 +96,7 @@ def test_init_configDir():
s
=
settings
.
Settings
(
cfgid
=
'
test
'
,
writeOnExit
=
False
)
s
=
settings
.
Settings
(
cfgid
=
'
test
'
,
writeOnExit
=
False
)
assert
s
.
configDir
==
expected
assert
s
.
configDir
==
expected
def
test_init_configDir_tempdir
():
def
test_init_configDir_tempdir
():
atexit_funcs
=
[]
atexit_funcs
=
[]
...
@@ -105,8 +105,8 @@ def test_init_configDir_tempdir():
...
@@ -105,8 +105,8 @@ def test_init_configDir_tempdir():
atexit_funcs
.
append
((
func
,
args
,
kwargs
))
atexit_funcs
.
append
((
func
,
args
,
kwargs
))
with
mock
.
patch
(
'
fsl.utils.settings.atexit.register
'
,
mock_atexit_register
),
\
with
mock
.
patch
(
'
fsl.utils.settings.atexit.register
'
,
mock_atexit_register
),
\
mock
.
patch
(
'
fsl.utils.settings.os.makedirs
'
,
side_effect
=
I
OError
):
mock
.
patch
(
'
fsl.utils.settings.os.makedirs
'
,
side_effect
=
O
S
Error
):
s
=
settings
.
Settings
(
'
test
'
,
writeOnExit
=
False
)
s
=
settings
.
Settings
(
'
test
'
,
writeOnExit
=
False
)
cfgdir
=
s
.
configDir
cfgdir
=
s
.
configDir
...
@@ -119,7 +119,7 @@ def test_init_configDir_tempdir():
...
@@ -119,7 +119,7 @@ def test_init_configDir_tempdir():
f
(
*
a
,
**
kwa
)
f
(
*
a
,
**
kwa
)
assert
not
op
.
exists
(
cfgdir
)
assert
not
op
.
exists
(
cfgdir
)
def
test_init_writeOnExit
():
def
test_init_writeOnExit
():
...
@@ -167,7 +167,7 @@ def test_init_not_writeOnExit():
...
@@ -167,7 +167,7 @@ def test_init_not_writeOnExit():
assert
len
(
atexit_funcs
)
==
0
assert
len
(
atexit_funcs
)
==
0
def
test_readConfigFile
():
def
test_readConfigFile
():
...
@@ -187,7 +187,7 @@ def test_readConfigFile():
...
@@ -187,7 +187,7 @@ def test_readConfigFile():
for
k
,
v
in
testdata
.
items
():
for
k
,
v
in
testdata
.
items
():
assert
s
.
read
(
k
)
==
v
assert
s
.
read
(
k
)
==
v
def
test_readwrite
():
def
test_readwrite
():
...
@@ -210,15 +210,15 @@ def test_readwrite():
...
@@ -210,15 +210,15 @@ def test_readwrite():
assert
s
.
read
(
'
non-existent
'
)
is
None
assert
s
.
read
(
'
non-existent
'
)
is
None
assert
s
.
read
(
'
non-existent
'
,
'
default
'
)
==
'
default
'
assert
s
.
read
(
'
non-existent
'
,
'
default
'
)
==
'
default
'
def
test_readdefault
():
def
test_readdefault
():
with
tests
.
testdir
()
as
testdir
:
with
tests
.
testdir
()
as
testdir
:
s
=
settings
.
Settings
(
cfgid
=
'
test
'
,
cfgdir
=
testdir
,
writeOnExit
=
False
)
s
=
settings
.
Settings
(
cfgid
=
'
test
'
,
cfgdir
=
testdir
,
writeOnExit
=
False
)
assert
s
.
read
(
'
non-existent
'
)
is
None
assert
s
.
read
(
'
non-existent
'
)
is
None
assert
s
.
read
(
'
non-existent
'
,
'
default
'
)
==
'
default
'
assert
s
.
read
(
'
non-existent
'
,
'
default
'
)
==
'
default
'
def
test_delete
():
def
test_delete
():
...
@@ -226,7 +226,7 @@ def test_delete():
...
@@ -226,7 +226,7 @@ def test_delete():
with
tests
.
testdir
()
as
testdir
:
with
tests
.
testdir
()
as
testdir
:
s
=
settings
.
Settings
(
cfgid
=
'
test
'
,
cfgdir
=
testdir
,
writeOnExit
=
False
)
s
=
settings
.
Settings
(
cfgid
=
'
test
'
,
cfgdir
=
testdir
,
writeOnExit
=
False
)
s
.
delete
(
'
non-existent
'
)
s
.
delete
(
'
non-existent
'
)
assert
s
.
read
(
'
non-existent
'
)
is
None
assert
s
.
read
(
'
non-existent
'
)
is
None
...
@@ -284,13 +284,13 @@ def test_deleteFile():
...
@@ -284,13 +284,13 @@ def test_deleteFile():
f
.
write
(
contents
)
f
.
write
(
contents
)
assert
s
.
readFile
(
path
)
==
contents
assert
s
.
readFile
(
path
)
==
contents
s
.
deleteFile
(
path
)
s
.
deleteFile
(
path
)
assert
s
.
read
(
path
)
is
None
assert
s
.
read
(
path
)
is
None
def
test_readall
():
def
test_readall
():
testsettings
=
[(
'
namespace1.setting1
'
,
'
1
'
),
testsettings
=
[(
'
namespace1.setting1
'
,
'
1
'
),
(
'
namespace1.setting2
'
,
'
2
'
),
(
'
namespace1.setting2
'
,
'
2
'
),
(
'
namespace1.setting3
'
,
'
3
'
),
(
'
namespace1.setting3
'
,
'
3
'
),
...
@@ -311,7 +311,7 @@ def test_readall():
...
@@ -311,7 +311,7 @@ def test_readall():
ns1
=
[(
k
,
v
)
for
k
,
v
in
testsettings
if
k
.
startswith
(
'
namespace1
'
)]
ns1
=
[(
k
,
v
)
for
k
,
v
in
testsettings
if
k
.
startswith
(
'
namespace1
'
)]
ns2
=
[(
k
,
v
)
for
k
,
v
in
testsettings
if
k
.
startswith
(
'
namespace2
'
)]
ns2
=
[(
k
,
v
)
for
k
,
v
in
testsettings
if
k
.
startswith
(
'
namespace2
'
)]
assert
s
.
readAll
(
'
namespace1.*
'
)
==
dict
(
ns1
)
assert
s
.
readAll
(
'
namespace1.*
'
)
==
dict
(
ns1
)
assert
s
.
readAll
(
'
namespace2.*
'
)
==
dict
(
ns2
)
assert
s
.
readAll
(
'
namespace2.*
'
)
==
dict
(
ns2
)
assert
s
.
readAll
(
'
*setting*
'
)
==
dict
(
testsettings
)
assert
s
.
readAll
(
'
*setting*
'
)
==
dict
(
testsettings
)
...
@@ -324,7 +324,7 @@ def test_listFiles():
...
@@ -324,7 +324,7 @@ def test_listFiles():
'
namespace1/setting3.txt
'
]
'
namespace1/setting3.txt
'
]
ns2files
=
[
'
namespace2/setting1.txt
'
,
ns2files
=
[
'
namespace2/setting1.txt
'
,
'
namespace2/setting2.txt
'
,
'
namespace2/setting2.txt
'
,
'
namespace2/setting3.txt
'
]
'
namespace2/setting3.txt
'
]
with
tests
.
testdir
()
as
testdir
:
with
tests
.
testdir
()
as
testdir
:
...
@@ -400,7 +400,7 @@ def test_clear():
...
@@ -400,7 +400,7 @@ def test_clear():
for
k
,
v
in
testsettings
:
for
k
,
v
in
testsettings
:
assert
s
.
read
(
k
)
is
None
assert
s
.
read
(
k
)
is
None
for
p
,
c
in
testfiles
:
for
p
,
c
in
testfiles
:
assert
s
.
readFile
(
p
)
is
None
assert
s
.
readFile
(
p
)
is
None
...
...
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