default value if option is set to None
This commit is contained in:
parent
166ffc72f7
commit
a80b868cae
3 changed files with 26 additions and 4 deletions
|
@ -330,6 +330,7 @@ class Config(object):
|
||||||
child.setowner(self, ['default' for i in range(len(child.getdefault()))])
|
child.setowner(self, ['default' for i in range(len(child.getdefault()))])
|
||||||
else:
|
else:
|
||||||
child.setowner(self, 'default')
|
child.setowner(self, 'default')
|
||||||
|
self._cfgimpl_values[name] = child.getdefault()
|
||||||
else:
|
else:
|
||||||
child.setowner(self, newowner)
|
child.setowner(self, newowner)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -7,7 +7,28 @@ from error import SpecialOwnersError
|
||||||
|
|
||||||
def make_description():
|
def make_description():
|
||||||
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
||||||
## dummy 1
|
gcdummy = BoolOption('dummy', 'dummy', default=False, callback="toto")
|
||||||
|
objspaceoption = ChoiceOption('objspace', 'Object space',
|
||||||
|
['std', 'thunk'], 'std')
|
||||||
|
booloption = BoolOption('bool', 'Test boolean option', default=True)
|
||||||
|
intoption = IntOption('int', 'Test int option', default=0)
|
||||||
|
floatoption = FloatOption('float', 'Test float option', default=2.3)
|
||||||
|
stroption = StrOption('str', 'Test string option', default="abc")
|
||||||
|
boolop = BoolOption('boolop', 'Test boolean option op', default=True)
|
||||||
|
wantref_option = BoolOption('wantref', 'Test requires', default=False,
|
||||||
|
requires=['boolop'])
|
||||||
|
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||||
|
default=False,
|
||||||
|
requires=['boolop'])
|
||||||
|
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
||||||
|
descr = OptionDescription('constraints', '', [gcgroup, booloption, objspaceoption,
|
||||||
|
wantref_option, stroption,
|
||||||
|
wantframework_option,
|
||||||
|
intoption, boolop])
|
||||||
|
return descr
|
||||||
|
|
||||||
|
def make_description2():
|
||||||
|
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
||||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||||
objspaceoption = ChoiceOption('objspace', 'Object space',
|
objspaceoption = ChoiceOption('objspace', 'Object space',
|
||||||
['std', 'thunk'], 'std')
|
['std', 'thunk'], 'std')
|
||||||
|
@ -30,9 +51,9 @@ def make_description():
|
||||||
|
|
||||||
def test_override_are_default_owner():
|
def test_override_are_default_owner():
|
||||||
"config.override() implies that the owner is 'default' again"
|
"config.override() implies that the owner is 'default' again"
|
||||||
descr = make_description()
|
descr = make_description2()
|
||||||
config = Config(descr, bool=False)
|
config = Config(descr, bool=False)
|
||||||
# defaut
|
# default
|
||||||
assert config.gc._cfgimpl_value_owners['dummy'] == 'default'
|
assert config.gc._cfgimpl_value_owners['dummy'] == 'default'
|
||||||
# user
|
# user
|
||||||
config.gc.dummy = True
|
config.gc.dummy = True
|
||||||
|
|
|
@ -47,7 +47,7 @@ def test_reset():
|
||||||
assert config.string == "foo"
|
assert config.string == "foo"
|
||||||
assert config._cfgimpl_value_owners['string'] == 'user'
|
assert config._cfgimpl_value_owners['string'] == 'user'
|
||||||
config.string = None
|
config.string = None
|
||||||
assert config.string == None
|
assert config.string == 'string'
|
||||||
assert config._cfgimpl_value_owners['string'] == 'default'
|
assert config._cfgimpl_value_owners['string'] == 'default'
|
||||||
|
|
||||||
def test_idontexist():
|
def test_idontexist():
|
||||||
|
|
Loading…
Reference in a new issue