regression: permissive for option is apply every time, not only when global permissive is set

This commit is contained in:
Emmanuel Garette 2014-01-16 09:49:37 +01:00
parent 40ecddf242
commit 9d92ab84d7
2 changed files with 11 additions and 15 deletions

View File

@ -120,7 +120,7 @@ def test_permissive_option():
config.u1
except PropertiesOptionError as err:
props = err.proptype
assert props == ['disabled']
assert props == []
props = []
try:
config.u2
@ -143,7 +143,7 @@ def test_permissive_option():
config.u1
except PropertiesOptionError as err:
props = err.proptype
assert props == ['disabled']
assert props == []
props = []
try:
config.u2
@ -182,20 +182,12 @@ def test_permissive_option_frozen():
setting = config.cfgimpl_get_settings()
config.read_write()
setting.setpermissive(('frozen', 'disabled'), u1)
try:
config.u1 = 1
except PropertiesOptionError as err:
props = err.proptype
assert set(props) == set(['frozen', 'disabled'])
setting.append('permissive')
config.u1 = 1
assert config.u1 == 1
setting.append('permissive')
assert config.u1 == 1
setting.remove('permissive')
try:
config.u1 = 1
except PropertiesOptionError as err:
props = err.proptype
assert set(props) == set(['frozen', 'disabled'])
assert config.u1 == 1
def test_invalid_option_permissive():

View File

@ -248,6 +248,8 @@ class Undefined():
undefined = Undefined()
# ____________________________________________________________
class Property(object):
"a property is responsible of the option's value access rules"
@ -283,6 +285,7 @@ class Property(object):
self._properties.remove(propname)
self._setting._setproperties(self._properties, self._opt,
self._path)
def extend(self, propnames):
"""Extends properties to the existing properties
@ -435,8 +438,9 @@ class Settings(object):
properties = copy(self._getproperties(opt_or_descr, path))
self_properties = copy(self._getproperties())
# remove opt permissive
if force_permissive is True or 'permissive' in self_properties:
properties -= self._p_.getpermissive(path)
# permissive affect option's permission with or without permissive
# global property
properties -= self._p_.getpermissive(path)
# remove global permissive if need
if force_permissive is True or 'permissive' in self_properties:
properties -= self._p_.getpermissive()