consistencies can make a warning instead of raises
for that, you have to set something like: a.impl_add_consistency('not_equal', b, warnings_only=True) warning product now adapted message
This commit is contained in:
@ -5,7 +5,8 @@ from tiramisu.setting import owners, groups
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import IPOption, NetworkOption, NetmaskOption, IntOption,\
|
||||
BroadcastOption, SymLinkOption, OptionDescription
|
||||
from tiramisu.error import ConfigError
|
||||
from tiramisu.error import ConfigError, ValueWarning
|
||||
import warnings
|
||||
|
||||
|
||||
def test_consistency():
|
||||
@ -19,6 +20,19 @@ def test_consistency():
|
||||
raises(ConfigError, "a.impl_add_consistency('not_equal', 'a')")
|
||||
|
||||
|
||||
def test_consistency_warnings_only():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
a.impl_add_consistency('not_equal', b, warnings_only=True)
|
||||
c = Config(od)
|
||||
c.a = 1
|
||||
warnings.simplefilter("always", ValueWarning)
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
c.b = 1
|
||||
assert w != []
|
||||
|
||||
|
||||
def test_consistency_not_equal():
|
||||
a = IntOption('a', '')
|
||||
b = IntOption('b', '')
|
||||
|
Reference in New Issue
Block a user