diff --git a/test/auto/test_owner.py b/test/auto/test_owner.py index 678da96..3923715 100644 --- a/test/auto/test_owner.py +++ b/test/auto/test_owner.py @@ -945,37 +945,37 @@ def autocheck_set_owner_permissive(api, pathread, pathwrite, confread, confwrite _check_owner(api, pathread, confread, kwargs, 'new_user1', 'new_user1') -#FIXME @autocheck -#def autocheck_option(api, pathread, pathwrite, confread, confwrite, **kwargs): -# expected_name = pathread.split('.')[-1] -# if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): -# current_name = api.option(pathread).option.name -# assert current_name == api.forcepermissive.option(pathread).option.name -# assert current_name == api.unrestraint.option(pathread).option.name -# doc = api.option(pathread).option.doc() -# assert doc == api.forcepermissive.option(pathread).option.doc() -# assert doc == api.unrestraint.option(pathread).option.doc() -# elif not kwargs.get('propertyerror', False): -# raises(PropertiesOptionError, "api.option(pathread).option.name") -# current_name = api.forcepermissive.option(pathread).option.name -# assert current_name == api.unrestraint.option(pathread).option.name -# raises(PropertiesOptionError, "api.option(pathread).option.doc()") -# doc = api.forcepermissive.option(pathread).option.doc() -# assert doc == api.unrestraint.option(pathread).option.doc() -# else: -# raises(PropertiesOptionError, "api.option(pathread).option.name") -# raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.name") -# current_name = api.unrestraint.option(pathread).option.name -# raises(PropertiesOptionError, "api.option(pathread).option.doc()") -# raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.doc()") -# doc = api.unrestraint.option(pathread).option.doc() -# assert current_name == expected_name -# if expected_name.endswith('val1') or expected_name.endswith('val2'): -# expected_name = expected_name[:-4] -# if kwargs['symlink']: -# assert doc == "{}'s option link".format(expected_name) -# else: -# assert doc == "{}'s option".format(expected_name) +@autocheck +def autocheck_option(api, pathread, pathwrite, confread, confwrite, **kwargs): + expected_name = pathread.split('.')[-1] + if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): + current_name = api.option(pathread).option.name() + assert current_name == api.forcepermissive.option(pathread).option.name() + assert current_name == api.unrestraint.option(pathread).option.name() + doc = api.option(pathread).option.doc() + assert doc == api.forcepermissive.option(pathread).option.doc() + assert doc == api.unrestraint.option(pathread).option.doc() + elif not kwargs.get('propertyerror', False): + raises(PropertiesOptionError, "api.option(pathread).option.name()") + current_name = api.forcepermissive.option(pathread).option.name() + assert current_name == api.unrestraint.option(pathread).option.name() + raises(PropertiesOptionError, "api.option(pathread).option.doc()") + doc = api.forcepermissive.option(pathread).option.doc() + assert doc == api.unrestraint.option(pathread).option.doc() + else: + raises(PropertiesOptionError, "api.option(pathread).option.name()") + raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.name()") + current_name = api.unrestraint.option(pathread).option.name() + raises(PropertiesOptionError, "api.option(pathread).option.doc()") + raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.doc()") + doc = api.unrestraint.option(pathread).option.doc() + assert current_name == expected_name + if expected_name.endswith('val1') or expected_name.endswith('val2'): + expected_name = expected_name[:-4] + if kwargs['symlink']: + assert doc == "{}'s option link".format(expected_name) + else: + assert doc == "{}'s option".format(expected_name) @autocheck diff --git a/tiramisu/api.py b/tiramisu/api.py index c4bdf7b..dd98570 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -86,7 +86,7 @@ class CommonTiramisu(object): def _get_option(self): option = self.config_bag.option if option is None: - option = self.subconfig.cfgimpl_get_description().impl_getchild(self.name, + option = self.subconfig.cfgimpl_get_description().impl_getchild(self._name, self.config_bag, self.subconfig) self.config_bag.option = option @@ -121,7 +121,7 @@ class CommonTiramisuOption(CommonTiramisu): self.path = path self.index = index self.config_bag = config_bag - self.name = name + self._name = name self.subconfig = subconfig if self.slave_need_index: self._test_slave_index() @@ -204,6 +204,11 @@ class TiramisuOptionOption(CommonTiramisuOption): option = self._get_option() return option.impl_get_display_name() + @count + def name(self): + self._get_option() + return self._name + @count def _default(self): option = self._get_option() @@ -437,7 +442,7 @@ class TiramisuOptionValue(CommonTiramisuOption): self._get_option() self._test_slave_index() settings = self.config_bag.config.cfgimpl_get_settings() - value = self.subconfig.getattr(self.name, + value = self.subconfig.getattr(self._name, self.index, self.config_bag) if isinstance(value, Multi): @@ -461,7 +466,7 @@ class TiramisuOptionValue(CommonTiramisuOption): value = values.getdefaultvalue(self.path, self.index, self.config_bag) - self.subconfig.setattr(self.name, + self.subconfig.setattr(self._name, self.index, value, self.config_bag) @@ -531,7 +536,7 @@ class TiramisuOption(CommonTiramisu): subconfig, config_bag): - self.name = name + self._name = name self.subconfig = subconfig self.path = path self.index = index @@ -549,7 +554,7 @@ class TiramisuOption(CommonTiramisu): def __getattr__(self, subfunc): if subfunc in self.registers: - return self.registers[subfunc](self.name, + return self.registers[subfunc](self._name, self.path, self.index, self.subconfig,