can make_dict with disabled suboption
This commit is contained in:
parent
d7b04ebed0
commit
544cd93c73
|
@ -115,6 +115,18 @@ def test_make_dict():
|
||||||
raises(ValueError, 'd2 = config.make_dict(withvalue="3")')
|
raises(ValueError, 'd2 = config.make_dict(withvalue="3")')
|
||||||
|
|
||||||
|
|
||||||
|
def test_make_dict_with_disabled():
|
||||||
|
descr = OptionDescription("opt", "", [
|
||||||
|
OptionDescription("s1", "", [
|
||||||
|
BoolOption("a", "", default=False),
|
||||||
|
BoolOption("b", "", default=False, properties=('disabled',))]),
|
||||||
|
IntOption("int", "", default=42)])
|
||||||
|
config = Config(descr)
|
||||||
|
config.read_only()
|
||||||
|
d = config.make_dict()
|
||||||
|
assert d == {"s1.a": False, "int": 42}
|
||||||
|
|
||||||
|
|
||||||
def test_find_in_config():
|
def test_find_in_config():
|
||||||
"finds option in config"
|
"finds option in config"
|
||||||
descr = make_description()
|
descr = make_description()
|
||||||
|
|
|
@ -448,6 +448,7 @@ class SubConfig(object):
|
||||||
return pathsvalues
|
return pathsvalues
|
||||||
|
|
||||||
def _make_sub_dict(self, opt, path, pathsvalues, _currpath, flatten):
|
def _make_sub_dict(self, opt, path, pathsvalues, _currpath, flatten):
|
||||||
|
try:
|
||||||
if isinstance(opt, OptionDescription):
|
if isinstance(opt, OptionDescription):
|
||||||
pathsvalues += getattr(self, path).make_dict(flatten,
|
pathsvalues += getattr(self, path).make_dict(flatten,
|
||||||
_currpath +
|
_currpath +
|
||||||
|
@ -459,6 +460,8 @@ class SubConfig(object):
|
||||||
else:
|
else:
|
||||||
name = '.'.join(_currpath + [opt._name])
|
name = '.'.join(_currpath + [opt._name])
|
||||||
pathsvalues.append((name, value))
|
pathsvalues.append((name, value))
|
||||||
|
except PropertiesOptionError:
|
||||||
|
pass
|
||||||
|
|
||||||
def cfgimpl_get_path(self):
|
def cfgimpl_get_path(self):
|
||||||
descr = self.cfgimpl_get_description()
|
descr = self.cfgimpl_get_description()
|
||||||
|
|
Loading…
Reference in New Issue