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()
|
||||
|
||||
|
||||
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():
|
||||
b1 = BoolOption("b1", "", properties=('test',))
|
||||
descr = OptionDescription("opt", "", [OptionDescription("sub", "", [b1])])
|
||||
|
@ -835,11 +835,13 @@ class TiramisuContextProperty(TiramisuContext):
|
||||
context)
|
||||
del self.config_bag.properties
|
||||
|
||||
def reset(self):
|
||||
def reset(self,
|
||||
all=False):
|
||||
"""remove configuration properties"""
|
||||
context = self.config_bag.context
|
||||
context.cfgimpl_get_settings().reset(None,
|
||||
context)
|
||||
context,
|
||||
all_properties=all)
|
||||
del self.config_bag.properties
|
||||
|
||||
def exportation(self):
|
||||
|
@ -657,19 +657,20 @@ class Settings(object):
|
||||
|
||||
def reset(self,
|
||||
option_bag,
|
||||
context):
|
||||
context,
|
||||
all_properties=False):
|
||||
if option_bag is None:
|
||||
opt = None
|
||||
else:
|
||||
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():
|
||||
raise TypeError(_("can't reset properties to the symlinkoption \"{}\""
|
||||
"").format(opt.impl_get_display_name()))
|
||||
#if all_properties and (path or opt):
|
||||
# raise ValueError(_('opt and all_properties must not be set '
|
||||
# 'together in reset'))
|
||||
#if all_properties:
|
||||
# self._p_.reset_all_properties()
|
||||
if all_properties:
|
||||
self._p_.reset_all_properties()
|
||||
else:
|
||||
if opt is not None:
|
||||
path = option_bag.path
|
||||
|
Loading…
Reference in New Issue
Block a user