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
FS-SC
AsapoWorker
Commits
f3f1378c
Commit
f3f1378c
authored
Dec 10, 2021
by
Tim Schoof
Browse files
Merge branch 'fix_configuration_converters' into 'fix_configuration'
Do not call converters twice See merge request
!38
parents
cb0abc25
f776f5b9
Pipeline
#14434
passed with stage
in 45 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/AsapoWorker/configuration.py
View file @
f3f1378c
...
...
@@ -143,7 +143,9 @@ def create_cli_parser_for_attribute(attribute, parser, prefix, short_prefix):
required
=
False
if
attribute
.
converter
:
typ
=
attribute
.
converter
# Do not convert the type in the parser as that will already be
# done during construction
typ
=
None
else
:
typ
=
attribute
.
type
...
...
tests/test_configuration.py
View file @
f3f1378c
from
collections
import
OrderedDict
import
logging
from
AsapoWorker.configurable
import
Configurable
,
Config
from
AsapoWorker.configuration
import
create_config
,
\
create_yaml_from_configurable_class
,
create_instance_from_configurable
,
\
...
...
@@ -475,6 +476,21 @@ def test_create_instance_overwrite_options_via_kwargs():
assert
instance
.
extern_attribute
is
extern_attribute
def
test_create_cli_parser_type_converter
():
@
Configurable
class
UsesConverter
:
level
=
Config
(
"Log Level"
,
type
=
int
,
converter
=
logging
.
getLevelName
)
parser
=
create_cli_parser_from_configurable_class
(
UsesConverter
)
options
=
parser
.
parse_args
([
"--UsesConverter.level"
,
"DEBUG"
])
instance
=
create_instance_from_configurable
(
UsesConverter
,
parsed_args_to_dict
(
options
)[
"UsesConverter"
])
assert
instance
.
level
==
logging
.
DEBUG
def
test_create_instance_from_configurable_zero
():
@
Configurable
class
Foo
:
...
...
Write
Preview
Supports
Markdown
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