Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
clapper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
software
clapper
Commits
addae657
Commit
addae657
authored
2 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Fix style
parent
dd0eda61
No related branches found
No related tags found
No related merge requests found
Pipeline
#64816
passed
2 years ago
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
expose/click.py
+2
-2
2 additions, 2 deletions
expose/click.py
expose/rc.py
+3
-3
3 additions, 3 deletions
expose/rc.py
tests/test_rc.py
+16
-25
16 additions, 25 deletions
tests/test_rc.py
with
21 additions
and
30 deletions
expose/click.py
+
2
−
2
View file @
addae657
...
@@ -10,8 +10,8 @@ import typing
...
@@ -10,8 +10,8 @@ import typing
from
importlib.metadata
import
EntryPoint
from
importlib.metadata
import
EntryPoint
import
tomli
import
click
import
click
import
tomli
from
click.core
import
ParameterSource
from
click.core
import
ParameterSource
...
@@ -643,7 +643,7 @@ def user_defaults_group(
...
@@ -643,7 +643,7 @@ def user_defaults_group(
try
:
try
:
del
config
[
key
]
del
config
[
key
]
config
.
write
()
config
.
write
()
except
KeyError
as
e
:
except
KeyError
:
logger
.
error
(
logger
.
error
(
f
"
Cannot delete object named `
{
key
}
'
at `
{
config
.
path
}
'"
,
f
"
Cannot delete object named `
{
key
}
'
at `
{
config
.
path
}
'"
,
exc_info
=
True
,
exc_info
=
True
,
...
...
This diff is collapsed.
Click to expand it.
expose/rc.py
+
3
−
3
View file @
addae657
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
"""
Implements a global configuration system setup and readout.
"""
"""
Implements a global configuration system setup and readout.
"""
import
os
import
collections.abc
import
io
import
io
import
json
import
json
import
typing
import
logging
import
logging
import
os
import
pathlib
import
pathlib
import
collections.abc
import
typing
import
tomli
import
tomli
import
tomli_w
import
tomli_w
...
...
This diff is collapsed.
Click to expand it.
tests/test_rc.py
+
16
−
25
View file @
addae657
import
os
import
shutil
import
filecmp
import
filecmp
import
logging
import
logging
import
os
import
shutil
import
pytest
import
pytest
from
click.testing
import
CliRunner
from
click.testing
import
CliRunner
from
expose.click
import
user_defaults_group
from
expose.click
import
user_defaults_group
...
@@ -17,10 +18,10 @@ def _check_userdefaults_ex1_contents(rc):
...
@@ -17,10 +18,10 @@ def _check_userdefaults_ex1_contents(rc):
assert
rc
[
"
string
"
]
==
"
this is a string
"
assert
rc
[
"
string
"
]
==
"
this is a string
"
assert
rc
[
"
integer
"
]
==
42
assert
rc
[
"
integer
"
]
==
42
assert
rc
[
"
float
"
]
==
3.14
assert
rc
[
"
float
"
]
==
3.14
assert
rc
[
"
boolean
"
]
==
True
assert
rc
[
"
boolean
"
]
is
True
assert
rc
[
"
array
"
]
==
[
"
abc
"
,
2
,
2.78
]
assert
rc
[
"
array
"
]
==
[
"
abc
"
,
2
,
2.78
]
assert
rc
[
"
bar
"
][
"
boolean
"
]
==
False
assert
rc
[
"
bar
"
][
"
boolean
"
]
is
False
assert
rc
[
"
bar.boolean
"
]
==
False
assert
rc
[
"
bar.boolean
"
]
is
False
def
test_rc_basic_loading
(
datadir
):
def
test_rc_basic_loading
(
datadir
):
...
@@ -68,14 +69,14 @@ def test_rc_write(tmp_path):
...
@@ -68,14 +69,14 @@ def test_rc_write(tmp_path):
# checks contents before writing
# checks contents before writing
assert
rc
[
"
section1
"
][
"
an_int
"
]
==
15
assert
rc
[
"
section1
"
][
"
an_int
"
]
==
15
assert
rc
[
"
section1
"
][
"
a_bool
"
]
==
True
assert
rc
[
"
section1
"
][
"
a_bool
"
]
is
True
assert
rc
[
"
section1
"
][
"
a_float
"
]
==
3.1415
assert
rc
[
"
section1
"
][
"
a_float
"
]
==
3.1415
assert
rc
[
"
section1
"
][
"
baz
"
]
==
"
fun
"
assert
rc
[
"
section1
"
][
"
baz
"
]
==
"
fun
"
assert
rc
[
"
section1
"
][
"
bar
"
]
==
"
Python
"
assert
rc
[
"
section1
"
][
"
bar
"
]
==
"
Python
"
# checks contents before writing - different way
# checks contents before writing - different way
assert
rc
[
"
section1.an_int
"
]
==
15
assert
rc
[
"
section1.an_int
"
]
==
15
assert
rc
[
"
section1.a_bool
"
]
==
True
assert
rc
[
"
section1.a_bool
"
]
is
True
assert
rc
[
"
section1.a_float
"
]
==
3.1415
assert
rc
[
"
section1.a_float
"
]
==
3.1415
assert
rc
[
"
section1.baz
"
]
==
"
fun
"
assert
rc
[
"
section1.baz
"
]
==
"
fun
"
assert
rc
[
"
section1.bar
"
]
==
"
Python
"
assert
rc
[
"
section1.bar
"
]
==
"
Python
"
...
@@ -88,8 +89,8 @@ def test_rc_write(tmp_path):
...
@@ -88,8 +89,8 @@ def test_rc_write(tmp_path):
assert
len
(
rc2
)
==
1
assert
len
(
rc2
)
==
1
assert
rc
[
"
section1
"
][
"
an_int
"
]
==
15
assert
rc
[
"
section1
"
][
"
an_int
"
]
==
15
assert
rc
[
"
section1.an_int
"
]
==
15
assert
rc
[
"
section1.an_int
"
]
==
15
assert
rc
[
"
section1
"
][
"
a_bool
"
]
==
True
assert
rc
[
"
section1
"
][
"
a_bool
"
]
is
True
assert
rc
[
"
section1.a_bool
"
]
==
True
assert
rc
[
"
section1.a_bool
"
]
is
True
assert
rc
[
"
section1
"
][
"
a_float
"
]
==
3.1415
assert
rc
[
"
section1
"
][
"
a_float
"
]
==
3.1415
assert
rc
[
"
section1.a_float
"
]
==
3.1415
assert
rc
[
"
section1.a_float
"
]
==
3.1415
assert
rc
[
"
section1
"
][
"
baz
"
]
==
"
fun
"
assert
rc
[
"
section1
"
][
"
baz
"
]
==
"
fun
"
...
@@ -110,7 +111,7 @@ def test_rc_delete(tmp_path):
...
@@ -110,7 +111,7 @@ def test_rc_delete(tmp_path):
rc
[
"
section1.bar
"
]
=
"
Python
"
rc
[
"
section1.bar
"
]
=
"
Python
"
assert
rc
[
"
an_int
"
]
==
15
assert
rc
[
"
an_int
"
]
==
15
assert
rc
[
"
a_bool
"
]
==
True
assert
rc
[
"
a_bool
"
]
is
True
assert
rc
[
"
a_float
"
]
==
3.1415
assert
rc
[
"
a_float
"
]
==
3.1415
assert
rc
[
"
section1.baz
"
]
==
"
fun
"
assert
rc
[
"
section1.baz
"
]
==
"
fun
"
assert
rc
[
"
section1.bar
"
]
==
"
Python
"
assert
rc
[
"
section1.bar
"
]
==
"
Python
"
...
@@ -272,24 +273,18 @@ def test_rc_click_writing(datadir, tmp_path):
...
@@ -272,24 +273,18 @@ def test_rc_click_writing(datadir, tmp_path):
result
=
runner
.
invoke
(
cli
,
[
"
rm
"
,
"
new-section.date
"
])
result
=
runner
.
invoke
(
cli
,
[
"
rm
"
,
"
new-section.date
"
])
result
=
runner
.
invoke
(
cli
,
[
"
get
"
,
"
new-section.date
"
])
result
=
runner
.
invoke
(
cli
,
[
"
get
"
,
"
new-section.date
"
])
assert
result
.
exit_code
!=
0
assert
result
.
exit_code
!=
0
assert
(
assert
"
Error: Cannot find object named `new-section.date
'"
in
result
.
output
"
Error: Cannot find object named `new-section.date
'"
in
result
.
output
)
result
=
runner
.
invoke
(
cli
,
[
"
rm
"
,
"
new-section
"
])
result
=
runner
.
invoke
(
cli
,
[
"
rm
"
,
"
new-section
"
])
result
=
runner
.
invoke
(
cli
,
[
"
get
"
,
"
new-section
"
])
result
=
runner
.
invoke
(
cli
,
[
"
get
"
,
"
new-section
"
])
assert
result
.
exit_code
!=
0
assert
result
.
exit_code
!=
0
assert
(
assert
"
Error: Cannot find object named `new-section
'"
in
result
.
output
"
Error: Cannot find object named `new-section
'"
in
result
.
output
)
result
=
runner
.
invoke
(
cli
,
[
"
rm
"
,
"
bar
"
])
result
=
runner
.
invoke
(
cli
,
[
"
rm
"
,
"
bar
"
])
assert
result
.
exit_code
==
0
assert
result
.
exit_code
==
0
result
=
runner
.
invoke
(
cli
,
[
"
get
"
,
"
bar
"
])
result
=
runner
.
invoke
(
cli
,
[
"
get
"
,
"
bar
"
])
assert
result
.
exit_code
!=
0
assert
result
.
exit_code
!=
0
assert
(
assert
"
Error: Cannot find object named `bar
'"
in
result
.
output
"
Error: Cannot find object named `bar
'"
in
result
.
output
)
def
test_rc_click_no_directory
(
datadir
,
tmp_path
):
def
test_rc_click_no_directory
(
datadir
,
tmp_path
):
...
@@ -333,9 +328,7 @@ def test_rc_click_cannot_set(tmp_path):
...
@@ -333,9 +328,7 @@ def test_rc_click_cannot_set(tmp_path):
result
=
runner
.
invoke
(
cli
,
[
"
set
"
,
"
bar.boolean.error
"
,
"
50
"
])
result
=
runner
.
invoke
(
cli
,
[
"
set
"
,
"
bar.boolean.error
"
,
"
50
"
])
assert
result
.
exit_code
!=
0
assert
result
.
exit_code
!=
0
assert
(
assert
"
Error: Cannot set object named `bar.boolean.error
'"
in
result
.
output
"
Error: Cannot set object named `bar.boolean.error
'"
in
result
.
output
)
def
test_rc_click_cannot_delete
(
tmp_path
):
def
test_rc_click_cannot_delete
(
tmp_path
):
...
@@ -358,9 +351,7 @@ def test_rc_click_cannot_delete(tmp_path):
...
@@ -358,9 +351,7 @@ def test_rc_click_cannot_delete(tmp_path):
result
=
runner
.
invoke
(
cli
,
[
"
rm
"
,
"
new-section
"
])
result
=
runner
.
invoke
(
cli
,
[
"
rm
"
,
"
new-section
"
])
assert
result
.
exit_code
!=
0
assert
result
.
exit_code
!=
0
assert
(
assert
"
Error: Cannot delete object named `new-section
'"
in
result
.
output
"
Error: Cannot delete object named `new-section
'"
in
result
.
output
)
# the existing section should still work
# the existing section should still work
result
=
runner
.
invoke
(
cli
,
[
"
rm
"
,
"
bar
"
])
result
=
runner
.
invoke
(
cli
,
[
"
rm
"
,
"
bar
"
])
...
...
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