allow None in requirement
This commit is contained in:
parent
fd02a954ca
commit
755b2312c2
|
@ -131,3 +131,20 @@ def test_requires_not_transitive():
|
||||||
assert props == ['disabled']
|
assert props == ['disabled']
|
||||||
#
|
#
|
||||||
c.ip_address_service_web
|
c.ip_address_service_web
|
||||||
|
|
||||||
|
|
||||||
|
def test_requires_None():
|
||||||
|
a = BoolOption('activate_service', '')
|
||||||
|
b = IPOption('ip_address_service', '',
|
||||||
|
requires=[(a, None, 'disabled')])
|
||||||
|
od = OptionDescription('service', '', [a, b])
|
||||||
|
c = Config(od)
|
||||||
|
c.read_write()
|
||||||
|
props = []
|
||||||
|
try:
|
||||||
|
c.ip_address_service
|
||||||
|
except PropertiesOptionError, err:
|
||||||
|
props = err.proptype
|
||||||
|
assert props == ['disabled']
|
||||||
|
c.activate_service = False
|
||||||
|
c.ip_address_service
|
||||||
|
|
|
@ -814,7 +814,7 @@ def validate_requires_arg(requires, name):
|
||||||
if req[0].impl_is_multi():
|
if req[0].impl_is_multi():
|
||||||
raise ValueError(_('malformed requirements option {0} '
|
raise ValueError(_('malformed requirements option {0} '
|
||||||
'should not be a multi').format(name))
|
'should not be a multi').format(name))
|
||||||
if not req[0]._validate(req[1]):
|
if req[1] is not None and not req[0]._validate(req[1]):
|
||||||
raise ValueError(_('malformed requirements second argument '
|
raise ValueError(_('malformed requirements second argument '
|
||||||
'must be valid for option {0}').format(name))
|
'must be valid for option {0}').format(name))
|
||||||
if len(req) == 3:
|
if len(req) == 3:
|
||||||
|
|
Loading…
Reference in New Issue