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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Evan Edmond
fslpy
Commits
158db705
Commit
158db705
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Unit test for settings.filePath function
parent
772700d7
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
+23
-0
23 additions, 0 deletions
tests/test_settings.py
with
23 additions
and
0 deletions
tests/test_settings.py
+
23
−
0
View file @
158db705
...
@@ -36,6 +36,7 @@ def test_initialise():
...
@@ -36,6 +36,7 @@ def test_initialise():
assert
settings
.
readFile
(
'
nothing
'
)
is
None
assert
settings
.
readFile
(
'
nothing
'
)
is
None
settings
.
writeFile
(
'
nothing
'
,
'
nothing
'
)
settings
.
writeFile
(
'
nothing
'
,
'
nothing
'
)
settings
.
deleteFile
(
'
nothing
'
)
settings
.
deleteFile
(
'
nothing
'
)
assert
settings
.
filePath
()
is
None
assert
settings
.
readAll
()
==
{}
assert
settings
.
readAll
()
==
{}
assert
settings
.
listFiles
()
==
[]
assert
settings
.
listFiles
()
==
[]
settings
.
clear
()
settings
.
clear
()
...
@@ -339,6 +340,28 @@ def test_listFiles():
...
@@ -339,6 +340,28 @@ def test_listFiles():
assert
list
(
sorted
(
s
.
listFiles
(
'
*/setting1.txt
'
)))
==
list
(
sorted
([
ns1files
[
0
]]
+
[
ns2files
[
0
]]))
assert
list
(
sorted
(
s
.
listFiles
(
'
*/setting1.txt
'
)))
==
list
(
sorted
([
ns1files
[
0
]]
+
[
ns2files
[
0
]]))
def
test_filePath
():
testfiles
=
[
'
file1.txt
'
,
'
dir1/file2.txt
'
,
'
dir1/dir2/file3.txt
'
]
with
tests
.
testdir
()
as
testdir
:
s
=
settings
.
Settings
(
cfgid
=
'
test
'
,
cfgdir
=
testdir
,
writeOnExit
=
False
)
assert
s
.
filePath
(
'
nofile
'
)
==
op
.
join
(
testdir
,
'
nofile
'
)
for
fn
in
testfiles
:
s
.
writeFile
(
fn
,
fn
)
assert
s
.
filePath
(
'
nofile
'
)
==
op
.
join
(
testdir
,
'
nofile
'
)
for
f
in
testfiles
:
assert
s
.
filePath
(
f
)
==
op
.
join
(
testdir
,
f
)
def
test_clear
():
def
test_clear
():
testsettings
=
[(
'
setting1
'
,
'
1
'
),
testsettings
=
[(
'
setting1
'
,
'
1
'
),
...
...
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