simplification
This commit is contained in:
@ -37,16 +37,16 @@ def make_description():
|
||||
return descr
|
||||
|
||||
|
||||
def test_base_config():
|
||||
"""making a :class:`tiramisu.config.Config()` object
|
||||
and a :class:`tiramisu.option.OptionDescription()` object
|
||||
"""
|
||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||
descr = OptionDescription('tiramisu', '', [gcdummy])
|
||||
cfg = Config(descr)
|
||||
assert cfg.dummy is False
|
||||
dm = cfg.unwrap_from_path('dummy')
|
||||
assert dm.impl_getname() == 'dummy'
|
||||
#def test_base_config():
|
||||
# """making a :class:`tiramisu.config.Config()` object
|
||||
# and a :class:`tiramisu.option.OptionDescription()` object
|
||||
# """
|
||||
# gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||
# descr = OptionDescription('tiramisu', '', [gcdummy])
|
||||
# cfg = Config(descr)
|
||||
# assert cfg.dummy is False
|
||||
# dm = cfg.unwrap_from_path('dummy')
|
||||
# assert dm.impl_getname() == 'dummy'
|
||||
|
||||
|
||||
def test_base_config_name():
|
||||
@ -75,29 +75,29 @@ def test_base_path():
|
||||
assert cfg._impl_path is None
|
||||
assert cfg.config._impl_path == 'config'
|
||||
assert cfg.config.tiramisu._impl_path == 'config.tiramisu'
|
||||
|
||||
|
||||
def test_reset_value():
|
||||
descr = make_description()
|
||||
cfg = Config(descr)
|
||||
assert cfg.gc.dummy is False
|
||||
cfg.gc.dummy = True
|
||||
assert cfg.gc.dummy is True
|
||||
|
||||
|
||||
def test_base_config_and_groups():
|
||||
descr = make_description()
|
||||
# overrides the booloption default value
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
assert config.gc.name == 'ref'
|
||||
assert config.bool is False
|
||||
nm = config.unwrap_from_path('gc.name')
|
||||
assert nm.impl_getname() == 'name'
|
||||
gc = config.unwrap_from_path('gc')
|
||||
assert gc.impl_getname() == 'gc'
|
||||
#nm = config.unwrap_from_name('name')
|
||||
#assert nm.impl_getname() == 'name'
|
||||
#
|
||||
#
|
||||
#def test_reset_value():
|
||||
# descr = make_description()
|
||||
# cfg = Config(descr)
|
||||
# assert cfg.gc.dummy is False
|
||||
# cfg.gc.dummy = True
|
||||
# assert cfg.gc.dummy is True
|
||||
#
|
||||
#
|
||||
#def test_base_config_and_groups():
|
||||
# descr = make_description()
|
||||
# # overrides the booloption default value
|
||||
# config = Config(descr)
|
||||
# config.bool = False
|
||||
# assert config.gc.name == 'ref'
|
||||
# assert config.bool is False
|
||||
# nm = config.unwrap_from_path('gc.name')
|
||||
# assert nm.impl_getname() == 'name'
|
||||
# gc = config.unwrap_from_path('gc')
|
||||
# assert gc.impl_getname() == 'gc'
|
||||
# #nm = config.unwrap_from_name('name')
|
||||
# #assert nm.impl_getname() == 'name'
|
||||
|
||||
|
||||
def test_base_config_force_permissive():
|
||||
@ -337,6 +337,7 @@ def test_subconfig():
|
||||
o = OptionDescription('val', '', [i])
|
||||
o2 = OptionDescription('val', '', [o])
|
||||
c = Config(o2)
|
||||
c
|
||||
raises(TypeError, "SubConfig(i, weakref.ref(c))")
|
||||
pass
|
||||
|
||||
|
@ -126,6 +126,31 @@ def test_mandatory_default():
|
||||
assert 'mandatory' in prop
|
||||
|
||||
|
||||
def test_mandatory_delete():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config.read_only()
|
||||
config.str
|
||||
try:
|
||||
config.str1
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
config.read_write()
|
||||
config.str1 = 'yes'
|
||||
config.read_only()
|
||||
assert config.str1 == 'yes'
|
||||
config.cfgimpl_get_settings().remove('frozen')
|
||||
prop = []
|
||||
try:
|
||||
del(config.str1)
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
del(config.str)
|
||||
assert config.str1 == 'yes'
|
||||
|
||||
|
||||
#valeur vide : None, '', u'', ...
|
||||
def test_mandatory_none():
|
||||
descr = make_description()
|
||||
|
@ -62,61 +62,61 @@ def test_option_with_callback():
|
||||
raises(ValueError, "IntOption('test', '', default=1, callback=a_func)")
|
||||
|
||||
|
||||
def test_option_get_information():
|
||||
description = "it's ok"
|
||||
string = 'some informations'
|
||||
i = IntOption('test', description)
|
||||
raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
i.impl_set_information('info', string)
|
||||
assert i.impl_get_information('info') == string
|
||||
raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
assert i.impl_get_information('noinfo', 'default') == 'default'
|
||||
assert i.impl_get_information('doc') == description
|
||||
assert i.impl_getdoc() == description
|
||||
|
||||
|
||||
def test_option_get_information_config():
|
||||
description = "it's ok"
|
||||
string = 'some informations'
|
||||
string
|
||||
i = IntOption('test', description)
|
||||
od = OptionDescription('od', '', [i])
|
||||
Config(od)
|
||||
raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
raises(AttributeError, "i.impl_set_information('info', string)")
|
||||
#def test_option_get_information():
|
||||
# description = "it's ok"
|
||||
# string = 'some informations'
|
||||
# i = IntOption('test', description)
|
||||
# raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
# i.impl_set_information('info', string)
|
||||
# assert i.impl_get_information('info') == string
|
||||
raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
assert i.impl_get_information('noinfo', 'default') == 'default'
|
||||
assert i.impl_get_information('doc') == description
|
||||
assert i.impl_getdoc() == description
|
||||
|
||||
|
||||
def test_option_get_information_config2():
|
||||
description = "it's ok"
|
||||
string = 'some informations'
|
||||
i = IntOption('test', description)
|
||||
i.impl_set_information('info', string)
|
||||
od = OptionDescription('od', '', [i])
|
||||
Config(od)
|
||||
raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
raises(AttributeError, "i.impl_set_information('info', 'hello')")
|
||||
assert i.impl_get_information('info') == string
|
||||
raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
assert i.impl_get_information('noinfo', 'default') == 'default'
|
||||
assert i.impl_get_information('doc') == description
|
||||
assert i.impl_getdoc() == description
|
||||
|
||||
|
||||
def test_optiondescription_get_information():
|
||||
description = "it's ok"
|
||||
string = 'some informations'
|
||||
o = OptionDescription('test', description, [])
|
||||
o.impl_set_information('info', string)
|
||||
assert o.impl_get_information('info') == string
|
||||
raises(ValueError, "o.impl_get_information('noinfo')")
|
||||
assert o.impl_get_information('noinfo', 'default') == 'default'
|
||||
assert o.impl_get_information('doc') == description
|
||||
assert o.impl_getdoc() == description
|
||||
# raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
# assert i.impl_get_information('noinfo', 'default') == 'default'
|
||||
# assert i.impl_get_information('doc') == description
|
||||
# assert i.impl_getdoc() == description
|
||||
#
|
||||
#
|
||||
#def test_option_get_information_config():
|
||||
# description = "it's ok"
|
||||
# string = 'some informations'
|
||||
# string
|
||||
# i = IntOption('test', description)
|
||||
# od = OptionDescription('od', '', [i])
|
||||
# Config(od)
|
||||
# raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
# raises(AttributeError, "i.impl_set_information('info', string)")
|
||||
## assert i.impl_get_information('info') == string
|
||||
# raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
# assert i.impl_get_information('noinfo', 'default') == 'default'
|
||||
# assert i.impl_get_information('doc') == description
|
||||
# assert i.impl_getdoc() == description
|
||||
#
|
||||
#
|
||||
#def test_option_get_information_config2():
|
||||
# description = "it's ok"
|
||||
# string = 'some informations'
|
||||
# i = IntOption('test', description)
|
||||
# i.impl_set_information('info', string)
|
||||
# od = OptionDescription('od', '', [i])
|
||||
# Config(od)
|
||||
# raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
# raises(AttributeError, "i.impl_set_information('info', 'hello')")
|
||||
# assert i.impl_get_information('info') == string
|
||||
# raises(ValueError, "i.impl_get_information('noinfo')")
|
||||
# assert i.impl_get_information('noinfo', 'default') == 'default'
|
||||
# assert i.impl_get_information('doc') == description
|
||||
# assert i.impl_getdoc() == description
|
||||
#
|
||||
#
|
||||
#def test_optiondescription_get_information():
|
||||
# description = "it's ok"
|
||||
# string = 'some informations'
|
||||
# o = OptionDescription('test', description, [])
|
||||
# o.impl_set_information('info', string)
|
||||
# assert o.impl_get_information('info') == string
|
||||
# raises(ValueError, "o.impl_get_information('noinfo')")
|
||||
# assert o.impl_get_information('noinfo', 'default') == 'default'
|
||||
# assert o.impl_get_information('doc') == description
|
||||
# assert o.impl_getdoc() == description
|
||||
|
||||
|
||||
def test_option_multi():
|
||||
|
Reference in New Issue
Block a user