Commit f41c6afd authored by Tim Schoof's avatar Tim Schoof
Browse files

Allow empty prefix in configuration cli parser

parent f3f1378c
Pipeline #14436 passed with stage
in 43 seconds
......@@ -74,12 +74,12 @@ def create_yaml_for_attribute(attribute, indent):
def create_cli_parser_from_configurable_class(
configurable_class, parser=None, prefix="", short_prefix=None):
configurable_class, parser=None, prefix=None, short_prefix=None):
if not parser:
parser = argparse.ArgumentParser(
prog="Application",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
if not prefix:
if prefix is None:
prefix = configurable_class.__name__ + "."
if short_prefix is None:
......
......@@ -499,3 +499,13 @@ def test_create_instance_from_configurable_zero():
instance = create_instance_from_configurable(Foo, {"i": 0})
assert instance.i == 0
def test_empty_cli_parser_prefix():
parser = create_cli_parser_from_configurable_class(Point, prefix="")
options = parser.parse_args(["--x", "1", "--y", "2"])
instance = create_instance_from_configurable(
Point, parsed_args_to_dict(options))
assert instance.x == 1
assert instance.y == 2
Markdown is supported
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