consistency "not_equal" works now with multi
This commit is contained in:
@ -217,7 +217,7 @@ def test_consistency_not_equal_default_submulti():
|
||||
raises(ConfigError, "a.impl_add_consistency('not_equal', b)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_multi():
|
||||
def test_consistency_not_equal_masterslave():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
@ -233,7 +233,7 @@ def test_consistency_not_equal_multi():
|
||||
c.b = [2]
|
||||
|
||||
|
||||
def test_consistency_not_equal_multi_default():
|
||||
def test_consistency_not_equal_masterslaves_default():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True, default_multi=1)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
@ -247,6 +247,46 @@ def test_consistency_not_equal_multi_default():
|
||||
del(c.a)
|
||||
|
||||
|
||||
def test_consistency_not_equal_multi():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
c = Config(od)
|
||||
assert c.a == []
|
||||
assert c.b == []
|
||||
c.a = [1]
|
||||
del(c.a)
|
||||
c.a = [1]
|
||||
raises(ValueError, "c.b = [1]")
|
||||
c.b = [2]
|
||||
raises(ValueError, "c.b = [2, 1]")
|
||||
raises(ValueError, "c.b.append(1)")
|
||||
c.b.append(3)
|
||||
raises(ValueError, "c.b.append(3)")
|
||||
raises(ValueError, "c.a.append(3)")
|
||||
raises(ValueError, "c.a.append(3)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_multi_default():
|
||||
a = IntOption('a', '', multi=True, default=[1])
|
||||
b = IntOption('b', '', multi=True, default=[1, 2])
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
raises(ValueError, "a.impl_add_consistency('not_equal', b)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_multi_default_modif():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True, default=[1, 2])
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
c = Config(od)
|
||||
assert c.a == []
|
||||
assert c.b == [1, 2]
|
||||
raises(ValueError, 'c.a.append(1)')
|
||||
raises(ValueError, 'c.b.append(1)')
|
||||
|
||||
|
||||
def test_consistency_default():
|
||||
a = IntOption('a', '', 1)
|
||||
b = IntOption('b', '', 1)
|
||||
|
@ -519,7 +519,14 @@ def test_pprint():
|
||||
except Exception, err:
|
||||
pass
|
||||
|
||||
assert str(err) == msg_error.format('option', 'Test string option', 'properties', display_list(['disabled (' + display_list([msg_is.format('string2', 'string'), msg_is.format('Test int option', '1')]) + ')', 'hidden (' + msg_is_not.format('Test int option', display_list([2, 3, 4], 'or')) + ')']))
|
||||
list_disabled_1 = 'disabled (' + display_list([msg_is.format('string2', 'string'), msg_is.format('Test int option', '1')]) + ')'
|
||||
list_disabled_2 = 'disabled (' + display_list([msg_is.format('Test int option', '1'), msg_is.format('string2', 'string')]) + ')'
|
||||
list_hidden = 'hidden (' + msg_is_not.format('Test int option', display_list([2, 3, 4], 'or')) + ')'
|
||||
comp1 = str(err) == msg_error.format('option', 'Test string option', 'properties', display_list([list_disabled_1, list_hidden]))
|
||||
comp2 = str(err) == msg_error.format('option', 'Test string option', 'properties', display_list([list_disabled_2, list_hidden]))
|
||||
comp3 = str(err) == msg_error.format('option', 'Test string option', 'properties', display_list([list_hidden, list_disabled_1]))
|
||||
comp4 = str(err) == msg_error.format('option', 'Test string option', 'properties', display_list([list_hidden, list_disabled_2]))
|
||||
assert comp1 or comp2 or comp3 or comp4
|
||||
|
||||
try:
|
||||
config.options.val2
|
||||
@ -532,8 +539,23 @@ def test_pprint():
|
||||
config.val3
|
||||
except Exception, err:
|
||||
pass
|
||||
msg_1 = msg_is.format('string2', 'string')
|
||||
msg_2 = msg_is.format('Test int option', 1)
|
||||
msg_3 = msg_is_not.format('Test int option', display_list([2, 3, 4], 'or'))
|
||||
|
||||
assert str(err) == msg_error.format('option', 'val3', 'property', 'hidden (' + display_list([msg_is.format('string2', 'string'), msg_is.format('Test int option', 1), msg_is_not.format('Test int option', display_list([2, 3, 4], 'or'))]) + ')')
|
||||
list_hidden = 'hidden (' + display_list([msg_1, msg_2, msg_3]) + ')'
|
||||
comp1 = str(err) == msg_error.format('option', 'val3', 'property', list_hidden)
|
||||
list_hidden = 'hidden (' + display_list([msg_1, msg_3, msg_2]) + ')'
|
||||
comp2 = str(err) == msg_error.format('option', 'val3', 'property', list_hidden)
|
||||
list_hidden = 'hidden (' + display_list([msg_2, msg_1, msg_3]) + ')'
|
||||
comp3 = str(err) == msg_error.format('option', 'val3', 'property', list_hidden)
|
||||
list_hidden = 'hidden (' + display_list([msg_2, msg_3, msg_1]) + ')'
|
||||
comp4 = str(err) == msg_error.format('option', 'val3', 'property', list_hidden)
|
||||
list_hidden = 'hidden (' + display_list([msg_3, msg_1, msg_2]) + ')'
|
||||
comp5 = str(err) == msg_error.format('option', 'val3', 'property', list_hidden)
|
||||
list_hidden = 'hidden (' + display_list([msg_3, msg_2, msg_1]) + ')'
|
||||
comp6 = str(err) == msg_error.format('option', 'val3', 'property', list_hidden)
|
||||
assert comp1 or comp2 or comp3 or comp4 or comp5 or comp6
|
||||
|
||||
try:
|
||||
config.string
|
||||
|
Reference in New Issue
Block a user