diff --git a/tests/test_leadership.py b/tests/test_leadership.py index 3f21331..c4da041 100644 --- a/tests/test_leadership.py +++ b/tests/test_leadership.py @@ -186,6 +186,34 @@ def test_leadership_modif_follower_bool_false(json): assert config.value.dict() == output +def test_leadership_modif_follower_bool_true_fullname(json): + output = {'leader.leader': ['192.168.0.1'], + 'leader.follower': [None], + 'leader.follower_boolean': [True], + 'leader.follower_choice': [None], + 'leader.follower_integer': [None], + 'leader.follower_submulti': [[]]} + + config = get_config(json) + parser = TiramisuCmdlineParser(config, 'prog.py', fullpath=False) + parser.parse_args(['--follower_boolean', '0']) + assert config.value.dict() == output + + +def test_leadership_modif_follower_bool_false_fullname(json): + output = {'leader.leader': ['192.168.0.1'], + 'leader.follower': [None], + 'leader.follower_boolean': [False], + 'leader.follower_choice': [None], + 'leader.follower_integer': [None], + 'leader.follower_submulti': [[]]} + + config = get_config(json) + parser = TiramisuCmdlineParser(config, 'prog.py', fullpath=False) + parser.parse_args(['--no-follower_boolean', '0']) + assert config.value.dict() == output + + def test_leadership_modif_follower_choice(json): output = {'leader.leader': ['192.168.0.1'], 'leader.follower': [None], diff --git a/tiramisu_cmdline_parser/api.py b/tiramisu_cmdline_parser/api.py index ae8879b..eda2c21 100644 --- a/tiramisu_cmdline_parser/api.py +++ b/tiramisu_cmdline_parser/api.py @@ -20,7 +20,7 @@ from gettext import gettext as _ try: from tiramisu import Config from tiramisu.error import PropertiesOptionError, RequirementError, LeadershipError -except ModuleNotFoundError: +except (ModuleNotFoundError, ImportError): Config = None from tiramisu_api.error import PropertiesOptionError RequirementError = PropertiesOptionError @@ -164,10 +164,12 @@ class _BuildKwargs: is_short_name = self.cmdlineparser._is_short_name(name, 'longargument' in self.properties) if self.force_no: ga_name = self.gen_argument_name(name, is_short_name) - self.cmdlineparser.namespace.list_force_no[ga_name] = option.path() + ga_path = self.gen_argument_name(option.path(), is_short_name) + self.cmdlineparser.namespace.list_force_no[ga_path] = option.path() elif self.force_del: ga_name = self.gen_argument_name(name, is_short_name) - self.cmdlineparser.namespace.list_force_del[ga_name] = option.path() + ga_path = self.gen_argument_name(option.path(), is_short_name) + self.cmdlineparser.namespace.list_force_del[ga_path] = option.path() else: ga_name = name self.kwargs['dest'] = self.gen_argument_name(option.path(), False)