if we delete all reference to a Config and we have reference to old SubConfig, Values, Multi or Settings, make a ConfigError instead of AttributError on NoneType object
This commit is contained in:
@ -9,7 +9,7 @@ from py.test import raises
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import IntOption, FloatOption, StrOption, ChoiceOption, \
|
||||
BoolOption, UnicodeOption, OptionDescription
|
||||
from tiramisu.error import ConflictError
|
||||
from tiramisu.error import ConflictError, ConfigError
|
||||
|
||||
|
||||
def make_description():
|
||||
@ -273,4 +273,24 @@ def test_no_validation():
|
||||
setting.append('validator')
|
||||
raises(ValueError, 'c.test1')
|
||||
del(c.test1)
|
||||
assert c.test1 == None
|
||||
assert c.test1 is None
|
||||
|
||||
|
||||
def test_delete_config_with_subconfig():
|
||||
test = IntOption('test', '')
|
||||
multi = IntOption('multi', '', multi=True)
|
||||
od = OptionDescription('od', '', [test, multi])
|
||||
odroot = OptionDescription('odroot', '', [od])
|
||||
c = Config(odroot)
|
||||
sub = c.od
|
||||
val = c.cfgimpl_get_values()
|
||||
setting = c.cfgimpl_get_settings()
|
||||
val[test]
|
||||
val[multi]
|
||||
setting[test]
|
||||
sub.make_dict()
|
||||
del(c)
|
||||
raises(ConfigError, 'val[test]')
|
||||
raises(ConfigError, 'val[multi]')
|
||||
raises(ConfigError, 'setting[test]')
|
||||
raises(ConfigError, 'sub.make_dict()')
|
||||
|
Reference in New Issue
Block a user