add test to known if has a value + some corrections

This commit is contained in:
Emmanuel Garette 2013-08-24 23:10:35 +02:00
parent e6a183c00d
commit f482737a47
2 changed files with 16 additions and 2 deletions

View File

@ -173,3 +173,17 @@ def test_get_modified_values():
assert config.cfgimpl_get_values().get_modified_values() == {'od.g5': ('user', 'yes')}
config.od.g4 = True
assert config.cfgimpl_get_values().get_modified_values() == {'od.g5': ('user', 'yes'), 'od.g4': ('user', True)}
def test_has_value():
g1 = IntOption('g1', '', 1)
g2 = StrOption('g2', '', 'héhé')
g3 = UnicodeOption('g3', '', u'héhé')
g4 = BoolOption('g4', '', True)
g5 = StrOption('g5', '')
d1 = OptionDescription('od', '', [g1, g2, g3, g4, g5])
root = OptionDescription('root', '', [d1])
config = Config(root)
assert not g5 in config.cfgimpl_get_values()
config.od.g5 = 'yes'
assert g5 in config.cfgimpl_get_values()

View File

@ -92,10 +92,10 @@ class Values(object):
:param opt: the `option.Option()` object
"""
path = self._get_opt_path(opt)
self._contains(path)
return self._contains(path)
def _contains(self, path):
return self._p_.hasvalue('value', path)
return self._p_.hasvalue(path)
def __delitem__(self, opt):
"""overrides the builtins `del()` instructions"""