From 0d5c1c32ca19e4e2220e97215c96fe0e79d4dac1 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 12 Mar 2018 11:58:49 +0100 Subject: [PATCH] tests --- test/new_api/test_option_owner.py | 2 +- tiramisu/api.py | 13 +++++++++---- tiramisu/config.py | 2 +- tiramisu/option/optiondescription.py | 8 ++++---- tiramisu/value.py | 6 +++--- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/test/new_api/test_option_owner.py b/test/new_api/test_option_owner.py index 9eafe20..cdf7e4a 100644 --- a/test/new_api/test_option_owner.py +++ b/test/new_api/test_option_owner.py @@ -146,7 +146,7 @@ def test_setowner_symlinkoption(): assert api.option('tiramisu.symdummy').owner.isdefault() api.option('tiramisu.dummy').value.set(True) assert not api.option('tiramisu.symdummy').owner.isdefault() - raises(TypeError, "api.option('tiramisu.symdummy').owner.set('user')") + raises(ConfigError, "api.option('tiramisu.symdummy').owner.set('user')") def test_owner_masterslaves(): diff --git a/tiramisu/api.py b/tiramisu/api.py index 9290335..01c7564 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -380,13 +380,18 @@ class TiramisuOptionPermissive(CommonTiramisuOption): @count def set(self, permissives): if TIRAMISU_VERSION == 2: - permissive = tuple(permissives) + permissives = tuple(permissives) path = self._path + opt = self._opt + self.settings.setpermissive(opt=opt, + path=path, + permissive=permissives) else: path = self.path - self.settings.setpermissive(opt=self._opt, - path=path, - permissive=permissive) + opt = self._get_option() + self.settings.setpermissive(opt=opt, + path=path, + permissives=permissives) @count def reset(self, path): diff --git a/tiramisu/config.py b/tiramisu/config.py index 3dc79f1..5ff07b0 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -236,8 +236,8 @@ class SubConfig(object): nconfig_bag = config_bag.copy('nooption') nconfig_bag.option = opt name = opt.impl_getname() - subpath = self._get_subpath(name) if nconfig_bag.setting_properties is not None: + subpath = self._get_subpath(name) try: context.cfgimpl_get_settings().validate_properties(subpath, None, diff --git a/tiramisu/option/optiondescription.py b/tiramisu/option/optiondescription.py index a670a21..5953dc0 100644 --- a/tiramisu/option/optiondescription.py +++ b/tiramisu/option/optiondescription.py @@ -447,10 +447,10 @@ class OptionDescription(OptionDescriptionWalk): """ if not isinstance(children, list): raise ValueError(_('children in optiondescription "{}" must be a list').format(name)) - super(OptionDescription, self).__init__(name, - doc=doc, - requires=requires, - properties=properties) + super().__init__(name, + doc=doc, + requires=requires, + properties=properties) child_names = [] dynopt_names = [] for child in children: diff --git a/tiramisu/value.py b/tiramisu/value.py index dc6b20e..77207d4 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -531,10 +531,10 @@ class Values(object): """ opt = config_bag.option if opt.impl_is_symlinkoption(): - raise TypeError(_("can't set owner for the SymLinkOption \"{}\"" - "").format(opt.impl_get_display_name())) + raise ConfigError(_("can't set owner for the SymLinkOption \"{}\"" + "").format(opt.impl_get_display_name())) if not isinstance(owner, owners.Owner): - raise TypeError(_("invalid owner {0}").format(str(owner))) + raise ConfigError(_("invalid owner {0}").format(str(owner))) if owner in forbidden_owners: raise ConfigError(_('set owner "{0}" is forbidden').format(str(owner)))