Commit f3f1378c authored by Tim Schoof's avatar 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
......@@ -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
typ = attribute.type
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():
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():
class Foo:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment