|
|
|
@ -149,14 +149,14 @@ def test_find_in_config():
|
|
|
|
|
conf = Config(descr)
|
|
|
|
|
conf.property.read_only()
|
|
|
|
|
conf.permissive.set(frozenset(['hidden']))
|
|
|
|
|
ret = conf.option.find('dummy')
|
|
|
|
|
ret = list(conf.option.find('dummy'))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.option('gc.dummy').option.get())
|
|
|
|
|
#
|
|
|
|
|
ret = conf.option.find('dummy', first=True).option.get()
|
|
|
|
|
_is_same_opt(ret, conf.option('gc.dummy').option.get())
|
|
|
|
|
#
|
|
|
|
|
ret = conf.option.find('float')
|
|
|
|
|
ret = list(conf.option.find('float'))
|
|
|
|
|
assert len(ret) == 2
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.option('gc.float').option.get())
|
|
|
|
|
_is_same_opt(ret[1].option.get(), conf.option('float').option.get())
|
|
|
|
@ -177,48 +177,49 @@ def test_find_in_config():
|
|
|
|
|
#_is_same_opt(ret[0], conf.unwrap_from_path('gc.name'))
|
|
|
|
|
#_is_same_opt(conf.find_first(byvalue='ref'), conf.unwrap_from_path('gc.name'))
|
|
|
|
|
#
|
|
|
|
|
ret = conf.option.find('prop')
|
|
|
|
|
ret = list(conf.option.find('prop'))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.option('gc.prop').option.get())
|
|
|
|
|
#
|
|
|
|
|
ret = conf.option.find('prop', value=None)
|
|
|
|
|
ret = conf.option.find('prop')
|
|
|
|
|
ret = list(conf.option.find('prop', value=None))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
ret = list(conf.option.find('prop'))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.option('gc.prop').option.get())
|
|
|
|
|
#
|
|
|
|
|
conf.property.read_write()
|
|
|
|
|
raises(AttributeError, "assert conf.option.find('prop').option.get()")
|
|
|
|
|
ret = conf.unrestraint.option.find(name='prop')
|
|
|
|
|
ret = list(conf.unrestraint.option.find(name='prop'))
|
|
|
|
|
assert len(ret) == 2
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.unrestraint.option('gc.gc2.prop').option.get())
|
|
|
|
|
_is_same_opt(ret[1].option.get(), conf.forcepermissive.option('gc.prop').option.get())
|
|
|
|
|
#
|
|
|
|
|
ret = conf.forcepermissive.option.find('prop')
|
|
|
|
|
ret = list(conf.forcepermissive.option.find('prop'))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.forcepermissive.option('gc.prop').option.get())
|
|
|
|
|
#
|
|
|
|
|
_is_same_opt(conf.forcepermissive.option.find('prop', first=True).option.get(), conf.forcepermissive.option('gc.prop').option.get())
|
|
|
|
|
# combinaison of filters
|
|
|
|
|
ret = conf.unrestraint.option.find('prop', type=BoolOption)
|
|
|
|
|
ret = list(conf.unrestraint.option.find('prop', type=BoolOption))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.unrestraint.option('gc.gc2.prop').option.get())
|
|
|
|
|
_is_same_opt(conf.unrestraint.option.find('prop', type=BoolOption, first=True).option.get(), conf.unrestraint.option('gc.gc2.prop').option.get())
|
|
|
|
|
#
|
|
|
|
|
ret = conf.option.find('dummy', value=False)
|
|
|
|
|
ret = list(conf.option.find('dummy', value=False))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.option('gc.dummy').option.get())
|
|
|
|
|
#
|
|
|
|
|
_is_same_opt(conf.option.find('dummy', value=False, first=True).option.get(), conf.option('gc.dummy').option.get())
|
|
|
|
|
#subconfig
|
|
|
|
|
ret = conf.option('gc').find('dummy')
|
|
|
|
|
ret = list(conf.option('gc').find('dummy'))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.option('gc.dummy').option.get())
|
|
|
|
|
#
|
|
|
|
|
ret = conf.option('gc').find('float')
|
|
|
|
|
ret = list(conf.option('gc').find('float'))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.option('gc.float').option.get())
|
|
|
|
|
#
|
|
|
|
|
ret = conf.option('gc').find('bool')
|
|
|
|
|
ret = list(conf.option('gc').find('bool'))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.option('gc.gc2.bool').option.get())
|
|
|
|
|
_is_same_opt(conf.option('gc').find('bool', value=False, first=True).option.get(), conf.option('gc.gc2.bool').option.get())
|
|
|
|
@ -227,13 +228,13 @@ def test_find_in_config():
|
|
|
|
|
#
|
|
|
|
|
raises(AttributeError, "conf.option('gc').find('wantref').option.get()")
|
|
|
|
|
#
|
|
|
|
|
ret = conf.unrestraint.option('gc').find('prop')
|
|
|
|
|
ret = list(conf.unrestraint.option('gc').find('prop'))
|
|
|
|
|
assert len(ret) == 2
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.unrestraint.option('gc.gc2.prop').option.get())
|
|
|
|
|
_is_same_opt(ret[1].option.get(), conf.forcepermissive.option('gc.prop').option.get())
|
|
|
|
|
#
|
|
|
|
|
conf.property.read_only()
|
|
|
|
|
ret = conf.option('gc').find('prop')
|
|
|
|
|
ret = list(conf.option('gc').find('prop'))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
_is_same_opt(ret[0].option.get(), conf.option('gc.prop').option.get())
|
|
|
|
|
# not OptionDescription
|
|
|
|
@ -246,16 +247,16 @@ def test_find_multi():
|
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
|
conf = Config(o)
|
|
|
|
|
#
|
|
|
|
|
raises(AttributeError, "conf.option.find('bool', value=True)")
|
|
|
|
|
raises(AttributeError, "conf.option.find('bool', value=True, first=True)")
|
|
|
|
|
raises(AttributeError, "list(conf.option.find('bool', value=True))")
|
|
|
|
|
raises(AttributeError, "list(conf.option.find('bool', value=True, first=True))")
|
|
|
|
|
conf.option('bool').value.set([False])
|
|
|
|
|
raises(AttributeError, "conf.option.find('bool', value=True)")
|
|
|
|
|
raises(AttributeError, "conf.option.find('bool', value=True, first=True)")
|
|
|
|
|
raises(AttributeError, "list(conf.option.find('bool', value=True))")
|
|
|
|
|
raises(AttributeError, "list(conf.option.find('bool', value=True, first=True))")
|
|
|
|
|
conf.option('bool').value.set([False, False])
|
|
|
|
|
raises(AttributeError, "conf.option.find('bool', value=True)")
|
|
|
|
|
raises(AttributeError, "conf.option.find('bool', value=True, first=True)")
|
|
|
|
|
raises(AttributeError, "list(conf.option.find('bool', value=True))")
|
|
|
|
|
raises(AttributeError, "list(conf.option.find('bool', value=True, first=True))")
|
|
|
|
|
conf.option('bool').value.set([False, False, True])
|
|
|
|
|
ret = conf.option.find('bool', value=True)
|
|
|
|
|
ret = list(conf.option.find('bool', value=True))
|
|
|
|
|
assert len(ret) == 1
|
|
|
|
|
_is_same_opt(ret[0].option.get(), b)
|
|
|
|
|
_is_same_opt(conf.option.find('bool', value=True, first=True).option.get(), b)
|
|
|
|
@ -264,7 +265,7 @@ def test_find_multi():
|
|
|
|
|
def test_does_not_find_in_config():
|
|
|
|
|
descr = make_description()
|
|
|
|
|
conf = Config(descr)
|
|
|
|
|
raises(AttributeError, "conf.option.find('IDontExist')")
|
|
|
|
|
raises(AttributeError, "list(conf.option.find('IDontExist'))")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_filename():
|
|
|
|
@ -341,7 +342,11 @@ def test_help():
|
|
|
|
|
od1 = OptionDescription('o', '', [stro])
|
|
|
|
|
od2 = OptionDescription('o', '', [od1])
|
|
|
|
|
cfg = Config(od2)
|
|
|
|
|
cfg.help(_display=False, _valid=True)
|
|
|
|
|
cfg.help(_display=False)
|
|
|
|
|
cfg.config.help(_display=False)
|
|
|
|
|
cfg.option.help(_display=False)
|
|
|
|
|
cfg.option('o').help(_display=False)
|
|
|
|
|
cfg.option('o.s').help(_display=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_config_reset():
|
|
|
|
|