update invalid's message and display all informations when raises
This commit is contained in:
parent
c8a20eefb5
commit
0a83a9261f
|
@ -87,7 +87,7 @@ def test_validator_warning():
|
||||||
cfg.opt2 = 'val'
|
cfg.opt2 = 'val'
|
||||||
assert len(w) == 1
|
assert len(w) == 1
|
||||||
assert w[0].message.opt == opt2
|
assert w[0].message.opt == opt2
|
||||||
assert str(w[0].message) == 'invalid value val for option opt2: error'
|
assert str(w[0].message) == 'invalid value for option opt2: error'
|
||||||
#
|
#
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
cfg.opt3.append('val')
|
cfg.opt3.append('val')
|
||||||
|
@ -97,7 +97,7 @@ def test_validator_warning():
|
||||||
cfg.opt3.append('val1')
|
cfg.opt3.append('val1')
|
||||||
assert len(w) == 1
|
assert len(w) == 1
|
||||||
assert w[0].message.opt == opt3
|
assert w[0].message.opt == opt3
|
||||||
assert str(w[0].message) == 'invalid value val1 for option opt3: error'
|
assert str(w[0].message) == 'invalid value for option opt3: error'
|
||||||
raises(ValueError, "cfg.opt2 = 1")
|
raises(ValueError, "cfg.opt2 = 1")
|
||||||
#
|
#
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
|
@ -105,9 +105,9 @@ def test_validator_warning():
|
||||||
cfg.opt3.append('val')
|
cfg.opt3.append('val')
|
||||||
assert len(w) == 2
|
assert len(w) == 2
|
||||||
assert w[0].message.opt == opt2
|
assert w[0].message.opt == opt2
|
||||||
assert str(w[0].message) == 'invalid value val for option opt2: error'
|
assert str(w[0].message) == 'invalid value for option opt2: error'
|
||||||
assert w[1].message.opt == opt3
|
assert w[1].message.opt == opt3
|
||||||
assert str(w[1].message) == 'invalid value val1 for option opt3: error'
|
assert str(w[1].message) == 'invalid value for option opt3: error'
|
||||||
|
|
||||||
|
|
||||||
def test_validator_warning_master_slave():
|
def test_validator_warning_master_slave():
|
||||||
|
@ -127,29 +127,29 @@ def test_validator_warning_master_slave():
|
||||||
cfg.ip_admin_eth0.netmask_admin_eth0 = ['val1']
|
cfg.ip_admin_eth0.netmask_admin_eth0 = ['val1']
|
||||||
assert len(w) == 1
|
assert len(w) == 1
|
||||||
assert w[0].message.opt == netmask_admin_eth0
|
assert w[0].message.opt == netmask_admin_eth0
|
||||||
assert str(w[0].message) == 'invalid value val1 for option netmask_admin_eth0: error'
|
assert str(w[0].message) == 'invalid value for option netmask_admin_eth0: error'
|
||||||
#
|
#
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
cfg.ip_admin_eth0.ip_admin_eth0 = ['val']
|
cfg.ip_admin_eth0.ip_admin_eth0 = ['val']
|
||||||
assert len(w) == 1
|
assert len(w) == 1
|
||||||
assert w[0].message.opt == ip_admin_eth0
|
assert w[0].message.opt == ip_admin_eth0
|
||||||
assert str(w[0].message) == 'invalid value val for option ip_admin_eth0: error'
|
assert str(w[0].message) == 'invalid value for option ip_admin_eth0: error'
|
||||||
#
|
#
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
cfg.ip_admin_eth0.ip_admin_eth0 = ['val', 'val1', 'val1']
|
cfg.ip_admin_eth0.ip_admin_eth0 = ['val', 'val1', 'val1']
|
||||||
assert len(w) == 1
|
assert len(w) == 1
|
||||||
assert w[0].message.opt == ip_admin_eth0
|
assert w[0].message.opt == ip_admin_eth0
|
||||||
assert str(w[0].message) == 'invalid value val for option ip_admin_eth0: error'
|
assert str(w[0].message) == 'invalid value for option ip_admin_eth0: error'
|
||||||
#
|
#
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
cfg.ip_admin_eth0.ip_admin_eth0 = ['val1', 'val', 'val1']
|
cfg.ip_admin_eth0.ip_admin_eth0 = ['val1', 'val', 'val1']
|
||||||
assert len(w) == 1
|
assert len(w) == 1
|
||||||
assert w[0].message.opt == ip_admin_eth0
|
assert w[0].message.opt == ip_admin_eth0
|
||||||
assert str(w[0].message) == 'invalid value val for option ip_admin_eth0: error'
|
assert str(w[0].message) == 'invalid value for option ip_admin_eth0: error'
|
||||||
#
|
#
|
||||||
warnings.resetwarnings()
|
warnings.resetwarnings()
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
cfg.ip_admin_eth0.ip_admin_eth0 = ['val1', 'val1', 'val']
|
cfg.ip_admin_eth0.ip_admin_eth0 = ['val1', 'val1', 'val']
|
||||||
assert len(w) == 1
|
assert len(w) == 1
|
||||||
assert w[0].message.opt == ip_admin_eth0
|
assert w[0].message.opt == ip_admin_eth0
|
||||||
assert str(w[0].message) == 'invalid value val for option ip_admin_eth0: error'
|
assert str(w[0].message) == 'invalid value for option ip_admin_eth0: error'
|
||||||
|
|
|
@ -925,11 +925,11 @@ class NetmaskOption(Option):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if not make_net:
|
if not make_net:
|
||||||
msg = _("invalid network {0} ({1}) "
|
msg = _("invalid network {0} ({1}) "
|
||||||
"with netmask {2} ({3}),"
|
"with netmask {2},"
|
||||||
" this network is an IP")
|
" this network is an IP")
|
||||||
else:
|
else:
|
||||||
if make_net:
|
if make_net:
|
||||||
msg = _("invalid IP {0} ({1}) with netmask {2} ({3}),"
|
msg = _("invalid IP {0} ({1}) with netmask {2},"
|
||||||
" this IP is a network")
|
" this IP is a network")
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
Loading…
Reference in New Issue