From 6d8137160c183b6f4feeb4b1cb3a794b1c33e90b Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 15 Apr 2014 21:48:31 +0200 Subject: [PATCH] 'getattr' in optiondescription can return a bound method --- test/test_config.py | 13 +++++++++++++ test/test_dereference.py | 4 +--- tiramisu/config.py | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/test/test_config.py b/test/test_config.py index 9547722..0cefc13 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -331,3 +331,16 @@ def test_config_str(): cfg.read_only() str(cfg) str(cfg.o) + + +def test_config_od_function(): + gcdummy = BoolOption('dummy', 'dummy', default=False) + gcdummy1 = BoolOption('dummy1', 'dummy', default=False, properties=('disabled',)) + o = OptionDescription('o', '', [gcdummy, gcdummy1]) + descr = OptionDescription('tiramisu', '', [o]) + cfg = Config(descr) + try: + print cfg.impl_get_opt_by_path() + except AttributeError, err: + assert str(err) == _('unknown Option {0} in OptionDescription {1}' + '').format('impl_get_opt_by_path', descr._name) diff --git a/test/test_dereference.py b/test/test_dereference.py index 51daa9e..0e59f36 100644 --- a/test/test_dereference.py +++ b/test/test_dereference.py @@ -98,7 +98,6 @@ def test_deref_option_config(): assert w() is None -#FIXME rien a voir mais si je fais un config.impl_get_path_by_opt() ca me retourne la methode ! def test_deref_optiondescription_config(): b = BoolOption('b', '') o = OptionDescription('od', '', [b]) @@ -109,8 +108,7 @@ def test_deref_optiondescription_config(): del(o) assert w() is not None del(c) - #FIXME - #assert w() is None + assert w() is None def test_deref_groupconfig(): diff --git a/tiramisu/config.py b/tiramisu/config.py index 9c0ac2a..fd7e86f 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -234,7 +234,7 @@ class SubConfig(object): name, force_permissive=force_permissive) return homeconfig.getattr(name, force_permissive=force_permissive, validate=validate) - opt_or_descr = getattr(self.cfgimpl_get_description(), name) + opt_or_descr = self.cfgimpl_get_description().__getattr__(name) if self._impl_path is None: subpath = name else: