remove all properties
This commit is contained in:
parent
620eaa6461
commit
e6cbcde927
|
@ -421,6 +421,16 @@ def test_reset_properties():
|
||||||
assert api.option('gc.dummy').property.get() == set()
|
assert api.option('gc.dummy').property.get() == set()
|
||||||
|
|
||||||
|
|
||||||
|
def test_reset_properties_all():
|
||||||
|
descr = make_description()
|
||||||
|
api = Config(descr)
|
||||||
|
assert api.option('gc.dummy').property.get() == set()
|
||||||
|
api.option('gc.dummy').property.add('frozen')
|
||||||
|
assert api.option('gc.dummy').property.get() == {'frozen'}
|
||||||
|
api.property.reset(all=True)
|
||||||
|
assert api.option('gc.dummy').property.get() == set()
|
||||||
|
|
||||||
|
|
||||||
def test_properties_cached():
|
def test_properties_cached():
|
||||||
b1 = BoolOption("b1", "", properties=('test',))
|
b1 = BoolOption("b1", "", properties=('test',))
|
||||||
descr = OptionDescription("opt", "", [OptionDescription("sub", "", [b1])])
|
descr = OptionDescription("opt", "", [OptionDescription("sub", "", [b1])])
|
||||||
|
|
|
@ -835,11 +835,13 @@ class TiramisuContextProperty(TiramisuContext):
|
||||||
context)
|
context)
|
||||||
del self.config_bag.properties
|
del self.config_bag.properties
|
||||||
|
|
||||||
def reset(self):
|
def reset(self,
|
||||||
|
all=False):
|
||||||
"""remove configuration properties"""
|
"""remove configuration properties"""
|
||||||
context = self.config_bag.context
|
context = self.config_bag.context
|
||||||
context.cfgimpl_get_settings().reset(None,
|
context.cfgimpl_get_settings().reset(None,
|
||||||
context)
|
context,
|
||||||
|
all_properties=all)
|
||||||
del self.config_bag.properties
|
del self.config_bag.properties
|
||||||
|
|
||||||
def exportation(self):
|
def exportation(self):
|
||||||
|
|
|
@ -657,19 +657,20 @@ class Settings(object):
|
||||||
|
|
||||||
def reset(self,
|
def reset(self,
|
||||||
option_bag,
|
option_bag,
|
||||||
context):
|
context,
|
||||||
|
all_properties=False):
|
||||||
if option_bag is None:
|
if option_bag is None:
|
||||||
opt = None
|
opt = None
|
||||||
else:
|
else:
|
||||||
opt = option_bag.option
|
opt = option_bag.option
|
||||||
|
if all_properties and option_bag:
|
||||||
|
raise ValueError(_('opt and all_properties must not be set '
|
||||||
|
'together in reset'))
|
||||||
if opt and opt.impl_is_symlinkoption():
|
if opt and opt.impl_is_symlinkoption():
|
||||||
raise TypeError(_("can't reset properties to the symlinkoption \"{}\""
|
raise TypeError(_("can't reset properties to the symlinkoption \"{}\""
|
||||||
"").format(opt.impl_get_display_name()))
|
"").format(opt.impl_get_display_name()))
|
||||||
#if all_properties and (path or opt):
|
if all_properties:
|
||||||
# raise ValueError(_('opt and all_properties must not be set '
|
self._p_.reset_all_properties()
|
||||||
# 'together in reset'))
|
|
||||||
#if all_properties:
|
|
||||||
# self._p_.reset_all_properties()
|
|
||||||
else:
|
else:
|
||||||
if opt is not None:
|
if opt is not None:
|
||||||
path = option_bag.path
|
path = option_bag.path
|
||||||
|
|
Loading…
Reference in New Issue