get information with default attribute when information is set to an option

This commit is contained in:
Emmanuel Garette 2019-10-16 07:42:18 +02:00
parent ba5cc57166
commit a7e4399ae5
2 changed files with 16 additions and 1 deletions

View File

@ -66,6 +66,21 @@ def test_option_get_information_config():
assert i.impl_get_information('doc') == description assert i.impl_get_information('doc') == description
def test_option_get_information_default():
description = "it's ok"
string = 'some informations'
string
i = IntOption('test', description)
i.impl_set_information('noinfo', 'optdefault')
od = OptionDescription('od', '', [i])
cfg = Config(od)
#
assert cfg.option('test').information.get('noinfo', 'falsedefault') == 'optdefault'
#
cfg.option('test').information.set('noinfo', 'notdefault')
assert cfg.option('test').information.get('noinfo', 'falsedefault') == 'notdefault'
def test_option_get_information_config2(): def test_option_get_information_config2():
description = "it's ok" description = "it's ok"
string = 'some informations' string = 'some informations'

View File

@ -464,7 +464,7 @@ class TiramisuOptionInformation(CommonTiramisuOption):
path = self._option_bag.path path = self._option_bag.path
values = self._option_bag.config_bag.context.cfgimpl_get_values() values = self._option_bag.config_bag.context.cfgimpl_get_values()
try: try:
return values.get_information(key, default, path=path) return values.get_information(key, path=path)
except ValueError: except ValueError:
option = self._option_bag.option option = self._option_bag.option
return option.impl_get_information(key, default) return option.impl_get_information(key, default)