check with option as parameter
This commit is contained in:
@ -14,6 +14,7 @@ from tiramisu.i18n import _
|
||||
def return_true(value, param=None):
|
||||
if value == 'val' and param in [None, 'yes']:
|
||||
return True
|
||||
raise ValueError('error')
|
||||
|
||||
|
||||
def return_false(value, param=None):
|
||||
@ -59,9 +60,13 @@ def test_validator_params_key():
|
||||
|
||||
|
||||
def test_validator_params_option():
|
||||
opt0 = StrOption('opt0', '', default='val')
|
||||
opt0
|
||||
raises(ValueError, "opt1 = StrOption('opt1', '', validator=return_true, validator_params={'': ((opt0, False),)}, default='val')")
|
||||
opt0 = StrOption('opt0', '', default='yes')
|
||||
opt1 = StrOption('opt1', '', validator=return_true, validator_params={'': ((opt0, False),)}, default='val')
|
||||
r = OptionDescription('root', '', [opt0, opt1])
|
||||
cfg = Config(r)
|
||||
cfg.opt1
|
||||
cfg.opt0 = 'val'
|
||||
raises(ValueError, "cfg.opt1")
|
||||
|
||||
|
||||
def test_validator_multi():
|
||||
|
Reference in New Issue
Block a user