check with option as parameter

This commit is contained in:
2015-09-17 21:25:32 +02:00
parent 5ea92d3460
commit 3aad913868
3 changed files with 19 additions and 9 deletions

View File

@ -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():