suppression of the override
This commit is contained in:
@ -18,7 +18,7 @@ def make_description():
|
||||
wantref_option = BoolOption('wantref', 'Test requires', default=False)
|
||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||
default=False)
|
||||
|
||||
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
||||
descr = OptionDescription('tiram', '', [gcgroup, booloption, objspaceoption,
|
||||
wantref_option, stroption,
|
||||
@ -39,27 +39,28 @@ def test_reset_value():
|
||||
cfg = Config(descr)
|
||||
assert cfg.gc.dummy == False
|
||||
cfg.gc.dummy = True
|
||||
assert cfg.gc.dummy == True
|
||||
assert cfg.gc.dummy == True
|
||||
cfg.gc.dummy = None
|
||||
|
||||
|
||||
def test_base_config_and_groups():
|
||||
descr = make_description()
|
||||
# overrides the booloption default value
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
assert config.gc.name == 'ref'
|
||||
assert config.bool == False
|
||||
nm = config.unwrap_from_path('gc.name')
|
||||
assert nm._name == 'name'
|
||||
gc = config.unwrap_from_path('gc')
|
||||
assert gc._name == 'gc'
|
||||
assert gc._name == 'gc'
|
||||
nm = config.unwrap_from_name('name')
|
||||
assert nm._name == 'name'
|
||||
|
||||
|
||||
def test_base_config_in_a_tree():
|
||||
"how options are organized into a tree"
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
assert config.gc.name == 'ref'
|
||||
config.gc.name = 'framework'
|
||||
assert config.gc.name == 'framework'
|
||||
@ -68,7 +69,7 @@ def test_base_config_in_a_tree():
|
||||
assert config.objspace == 'std'
|
||||
config.objspace = 'thunk'
|
||||
assert config.objspace == 'thunk'
|
||||
|
||||
|
||||
assert config.gc.float == 2.3
|
||||
assert config.int == 0
|
||||
config.gc.float = 3.4
|
||||
@ -84,21 +85,24 @@ def test_base_config_in_a_tree():
|
||||
|
||||
raises(AttributeError, 'config.gc.foo = "bar"')
|
||||
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
assert config.gc.name == 'ref'
|
||||
config.wantframework = True
|
||||
|
||||
def test_config_values():
|
||||
"_cfgimpl_values appears to be a simple dict"
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
config.set(dummy=False)
|
||||
assert config.gc._cfgimpl_values == {'dummy': False, 'float': 2.3, 'name': 'ref'}
|
||||
|
||||
def test_cfgimpl_get_home_by_path():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
assert config._cfgimpl_get_home_by_path('gc.dummy')[1] == 'dummy'
|
||||
assert config._cfgimpl_get_home_by_path('dummy')[1] == 'dummy'
|
||||
assert config.getpaths(include_groups=False) == ['gc.name', 'gc.dummy', 'gc.float', 'bool', 'objspace', 'wantref', 'str', 'wantframework', 'int', 'boolop']
|
||||
assert config.getpaths(include_groups=True) == ['gc', 'gc.name', 'gc.dummy', 'gc.float', 'bool', 'objspace', 'wantref', 'str', 'wantframework', 'int', 'boolop']
|
||||
assert config.getpaths(include_groups=True) == ['gc', 'gc.name', 'gc.dummy', 'gc.float', 'bool', 'objspace', 'wantref', 'str', 'wantframework', 'int', 'boolop']
|
||||
|
@ -30,7 +30,8 @@ def test_compare_configs():
|
||||
"config object comparison"
|
||||
descr = make_description()
|
||||
conf1 = Config(descr)
|
||||
conf2 = Config(descr, wantref=True)
|
||||
conf2 = Config(descr)
|
||||
conf2.wantref = True
|
||||
assert conf1 != conf2
|
||||
assert hash(conf1) != hash(conf2)
|
||||
assert conf1.getkey() != conf2.getkey()
|
||||
@ -183,4 +184,4 @@ def test_find_in_config():
|
||||
# assert c.booloption2 is False
|
||||
# c.booloption2 = False
|
||||
# assert c.booloption2 is False
|
||||
#
|
||||
#
|
||||
|
@ -54,16 +54,16 @@ def make_description_duplicates():
|
||||
return descr
|
||||
|
||||
def test_identical_paths():
|
||||
"""If in the schema (the option description) there is something that
|
||||
"""If in the schema (the option description) there is something that
|
||||
have the same name, an exection is raised
|
||||
"""
|
||||
"""
|
||||
descr = make_description_duplicates()
|
||||
raises(ConflictConfigError, "cfg = Config(descr)")
|
||||
|
||||
#def test_identical_for_names():
|
||||
# """if there is something that
|
||||
# """if there is something that
|
||||
# have the same name, an exection is raised
|
||||
# """
|
||||
# """
|
||||
# descr = make_description_duplicates()
|
||||
# raises(ConflictConfigError, "cfg = Config(descr)")
|
||||
|
||||
@ -73,7 +73,7 @@ def make_description2():
|
||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||
|
||||
floatoption = FloatOption('float', 'Test float option', default=2.3)
|
||||
|
||||
|
||||
objspaceoption = ChoiceOption('objspace', 'Object space',
|
||||
['std', 'thunk'], 'std')
|
||||
booloption = BoolOption('bool', 'Test boolean option', default=True)
|
||||
@ -89,7 +89,7 @@ def make_description2():
|
||||
default=False,
|
||||
requires=['boolop'])
|
||||
wantframework_option.enable_multi()
|
||||
|
||||
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption, objspaceoption,
|
||||
wantref_option, stroption,
|
||||
@ -97,20 +97,20 @@ def make_description2():
|
||||
intoption, boolop])
|
||||
return descr
|
||||
|
||||
# FIXME: XXX would you mind putting the multi validations anywhere else
|
||||
# than in the requires !!!
|
||||
# FIXME: XXX would you mind putting the multi validations anywhere else
|
||||
# than in the requires !!!
|
||||
#def test_multi_constraints():
|
||||
# "a multi in a constraint has to have the same length"
|
||||
# descr = make_description2()
|
||||
# cfg = Config(descr)
|
||||
# cfg.boolop = [True, True, False]
|
||||
# cfg.wantframework = [False, False, True]
|
||||
#
|
||||
#
|
||||
#def test_multi_raise():
|
||||
# "a multi in a constraint has to have the same length"
|
||||
# # FIXME fusionner les deux tests, MAIS PROBLEME :
|
||||
# # il ne devrait pas etre necessaire de refaire une config
|
||||
# # si la valeur est modifiee une deuxieme fois ->
|
||||
# # si la valeur est modifiee une deuxieme fois ->
|
||||
# #raises(ConflictConfigError, "cfg.wantframework = [False, False, True]")
|
||||
# # ExceptionFailure: 'DID NOT RAISE'
|
||||
# descr = make_description2()
|
||||
@ -130,12 +130,14 @@ def test_newoption_add_in_subdescr():
|
||||
descr = make_description()
|
||||
newoption = BoolOption('newoption', 'dummy twoo', default=False)
|
||||
descr.gc.add_child(newoption)
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
assert config.gc.newoption == False
|
||||
|
||||
def test_newoption_add_in_config():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
newoption = BoolOption('newoption', 'dummy twoo', default=False)
|
||||
descr.add_child(newoption)
|
||||
config.cfgimpl_update()
|
||||
@ -146,14 +148,14 @@ def make_description_requires():
|
||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||
|
||||
floatoption = FloatOption('float', 'Test float option', default=2.3)
|
||||
|
||||
|
||||
objspaceoption = ChoiceOption('objspace', 'Object space',
|
||||
['std', 'thunk'], 'std')
|
||||
booloption = BoolOption('bool', 'Test boolean option', default=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
stroption = StrOption('str', 'Test string option', default="abc",
|
||||
stroption = StrOption('str', 'Test string option', default="abc",
|
||||
requires=[('int', 1, 'hide')])
|
||||
|
||||
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption, objspaceoption,
|
||||
stroption, intoption])
|
||||
@ -175,15 +177,15 @@ def test_hidden_if_in_with_group():
|
||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||
|
||||
floatoption = FloatOption('float', 'Test float option', default=2.3)
|
||||
|
||||
|
||||
objspaceoption = ChoiceOption('objspace', 'Object space',
|
||||
['std', 'thunk'], 'std')
|
||||
booloption = BoolOption('bool', 'Test boolean option', default=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
stroption = StrOption('str', 'Test string option', default="abc")
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption],
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption],
|
||||
requires=[('int', 1, 'hide')])
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption,
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption,
|
||||
objspaceoption, stroption, intoption])
|
||||
cfg = Config(descr)
|
||||
assert not gcgroup._is_hidden()
|
||||
@ -196,19 +198,18 @@ def test_disabled_with_group():
|
||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||
|
||||
floatoption = FloatOption('float', 'Test float option', default=2.3)
|
||||
|
||||
|
||||
objspaceoption = ChoiceOption('objspace', 'Object space',
|
||||
['std', 'thunk'], 'std')
|
||||
booloption = BoolOption('bool', 'Test boolean option', default=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
stroption = StrOption('str', 'Test string option', default="abc")
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption],
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption],
|
||||
requires=[('int', 1, 'disable')])
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption,
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption,
|
||||
objspaceoption, stroption, intoption])
|
||||
cfg = Config(descr)
|
||||
assert not gcgroup._is_disabled()
|
||||
cfg.int = 1
|
||||
raises(PropertiesOptionError, "cfg.gc.name")
|
||||
assert gcgroup._is_disabled()
|
||||
|
||||
|
@ -21,7 +21,7 @@ def make_description():
|
||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||
default=False,
|
||||
requires=['boolop'])
|
||||
|
||||
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
||||
descr = OptionDescription('tiramisu', '', [gcgroup, booloption, objspaceoption,
|
||||
wantref_option, stroption,
|
||||
@ -60,8 +60,8 @@ def test_mandatory():
|
||||
config.dummy1 = True
|
||||
assert config.dummy1 == True
|
||||
raises(MandatoryError, 'config.dummy2 == None')
|
||||
raises(MandatoryError, "config.override({'dummy2':None})")
|
||||
config.set(dummy2=True)
|
||||
# raises(MandatoryError, "config.override({'dummy2':None})")
|
||||
config.set(dummy2=True)
|
||||
config.dummy2 = False
|
||||
assert config.dummy2 == False
|
||||
|
||||
@ -81,13 +81,13 @@ def test_force_default_on_freeze():
|
||||
|
||||
def test_override_are_defaults():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
config.gc.dummy = True
|
||||
assert config._cfgimpl_values['gc']._cfgimpl_value_owners['dummy'] == 'user'
|
||||
#Options have an available default setting and can give it back
|
||||
assert config._cfgimpl_descr._children[0]._children[1].getdefault() == False
|
||||
config.override({'gc.dummy':True})
|
||||
# config.override({'gc.dummy':True})
|
||||
#assert config.gc.dummy == True
|
||||
#assert config._cfgimpl_descr._children[0]._children[1].getdefault() == True
|
||||
#assert config._cfgimpl_values['gc']._cfgimpl_value_owners['dummy'] == 'default'
|
||||
@ -98,8 +98,8 @@ def test_overrides_changes_option_value():
|
||||
BoolOption("b", "", default=False)])
|
||||
config = Config(descr)
|
||||
config.b = True
|
||||
config.override({'b': False})
|
||||
assert config.b == False
|
||||
# config.override({'b': False})
|
||||
# assert config.b == False
|
||||
#____________________________________________________________
|
||||
# test various option types
|
||||
def test_choice_with_no_default():
|
||||
@ -114,7 +114,7 @@ def test_choice_with_default():
|
||||
ChoiceOption("backend", "", ["c", "cli"], default="cli")])
|
||||
config = Config(descr)
|
||||
assert config.backend == "cli"
|
||||
|
||||
|
||||
def test_arbitrary_option():
|
||||
descr = OptionDescription("top", "", [
|
||||
ArbitraryOption("a", "no help", default=None)
|
||||
@ -132,4 +132,3 @@ def test_arbitrary_option():
|
||||
c1.a.append(1)
|
||||
assert c2.a == []
|
||||
assert c1.a == [1]
|
||||
|
||||
|
@ -48,28 +48,30 @@ def make_description2():
|
||||
intoption, boolop])
|
||||
return descr
|
||||
|
||||
def test_override_are_default_owner():
|
||||
"config.override() implies that the owner is 'default' again"
|
||||
descr = make_description2()
|
||||
config = Config(descr, bool=False)
|
||||
# default
|
||||
assert config.gc._cfgimpl_value_owners['dummy'] == 'default'
|
||||
# user
|
||||
config.gc.dummy = True
|
||||
assert config.gc._cfgimpl_value_owners['dummy'] == 'user'
|
||||
assert config._cfgimpl_values['gc']._cfgimpl_value_owners['dummy'] == 'user'
|
||||
#Options have an available default setting and can give it back
|
||||
assert config._cfgimpl_descr._children[0]._children[1].getdefault() == False
|
||||
config.override({'gc.dummy':True})
|
||||
assert config.gc._cfgimpl_value_owners['dummy'] == 'default'
|
||||
# user again
|
||||
config.gc.dummy = False
|
||||
assert config.gc._cfgimpl_value_owners['dummy'] == 'user'
|
||||
#def test_override_are_default_owner():
|
||||
# "config.override() implies that the owner is 'default' again"
|
||||
# descr = make_description2()
|
||||
# config = Config(descr)
|
||||
# config.bool = False
|
||||
# # default
|
||||
# assert config.gc._cfgimpl_value_owners['dummy'] == 'default'
|
||||
# # user
|
||||
# config.gc.dummy = True
|
||||
# assert config.gc._cfgimpl_value_owners['dummy'] == 'user'
|
||||
# assert config._cfgimpl_values['gc']._cfgimpl_value_owners['dummy'] == 'user'
|
||||
# #Options have an available default setting and can give it back
|
||||
# assert config._cfgimpl_descr._children[0]._children[1].getdefault() == False
|
||||
# config.override({'gc.dummy':True})
|
||||
# assert config.gc._cfgimpl_value_owners['dummy'] == 'default'
|
||||
# # user again
|
||||
# config.gc.dummy = False
|
||||
# assert config.gc._cfgimpl_value_owners['dummy'] == 'user'
|
||||
|
||||
def test_has_callback():
|
||||
descr = make_description()
|
||||
# here the owner is 'default'
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
# because dummy has a callback
|
||||
dummy = config.unwrap_from_path('gc.dummy')
|
||||
config.cfgimpl_freeze()
|
||||
@ -79,7 +81,8 @@ def test_has_callback():
|
||||
#____________________________________________________________
|
||||
def test_freeze_and_has_callback_with_setoption():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
config.cfgimpl_freeze()
|
||||
dummy = config.unwrap_from_path('gc.dummy')
|
||||
dummy.freeze()
|
||||
|
@ -18,7 +18,7 @@ def make_description():
|
||||
boolop = BoolOption('boolop', 'Test boolean option op', default=True)
|
||||
wantref_option = BoolOption('wantref', 'Test requires', default=False)
|
||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||
default=False)
|
||||
default=False)
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
||||
descr = OptionDescription('tiramisu', '', [gcgroup, booloption, objspaceoption,
|
||||
wantref_option, stroption,
|
||||
@ -43,7 +43,7 @@ def test_setitem():
|
||||
print config.string[1]
|
||||
config.string[1] = "titi"
|
||||
print config.string[1]
|
||||
|
||||
|
||||
def test_reset():
|
||||
"if value is None, resets to default owner"
|
||||
s = StrOption("string", "", default="string")
|
||||
@ -52,7 +52,7 @@ def test_reset():
|
||||
config.string = "foo"
|
||||
assert config.string == "foo"
|
||||
assert config._cfgimpl_value_owners['string'] == 'user'
|
||||
config.string = None
|
||||
config.unwrap_from_path("string").reset(config)
|
||||
assert config.string == 'string'
|
||||
assert config._cfgimpl_value_owners['string'] == 'default'
|
||||
|
||||
@ -60,13 +60,15 @@ def test_reset_with_multi():
|
||||
s = StrOption("string", "", default=["string"], default_multi="string" , multi=True)
|
||||
descr = OptionDescription("options", "", [s])
|
||||
config = Config(descr)
|
||||
config.string = []
|
||||
# config.string = []
|
||||
config.unwrap_from_path("string").reset(config)
|
||||
assert config.string == ["string"]
|
||||
assert config._cfgimpl_value_owners['string'] == ['default']
|
||||
config.string = ["eggs", "spam", "foo"]
|
||||
assert config._cfgimpl_value_owners['string'] == ['user', 'user', 'user']
|
||||
config.string = []
|
||||
assert config.string == ["string"]
|
||||
config.unwrap_from_path("string").reset(config)
|
||||
# assert config.string == ["string"]
|
||||
assert config._cfgimpl_value_owners['string'] == ['default']
|
||||
raises(ConfigError, "config.string = None")
|
||||
|
||||
@ -80,7 +82,7 @@ def test_default_with_multi():
|
||||
descr = OptionDescription("options", "", [s])
|
||||
config = Config(descr)
|
||||
assert config.string == []
|
||||
|
||||
|
||||
def test_idontexist():
|
||||
descr = make_description()
|
||||
cfg = Config(descr)
|
||||
@ -124,7 +126,7 @@ def test_access_with_multi_default():
|
||||
def test_multi_with_requires():
|
||||
s = StrOption("string", "", default=["string"], default_multi="string", multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"], default_multi = "abc",
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"], default_multi = "abc",
|
||||
requires=[('int', 1, 'hide')], multi=True)
|
||||
descr = OptionDescription("options", "", [s, intoption, stroption])
|
||||
config = Config(descr)
|
||||
@ -148,7 +150,7 @@ def test_multi_with_requires_in_another_group():
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[('int', 1, 'hide')], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
@ -162,7 +164,7 @@ def test_apply_requires_from_config():
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[('int', 1, 'hide')], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
@ -172,15 +174,15 @@ def test_apply_requires_from_config():
|
||||
try:
|
||||
config.opt.str
|
||||
except:
|
||||
pass
|
||||
pass
|
||||
assert stroption._is_hidden()
|
||||
|
||||
|
||||
|
||||
def test_apply_requires_with_disabled():
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[('int', 1, 'disable')], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
@ -190,14 +192,14 @@ def test_apply_requires_with_disabled():
|
||||
try:
|
||||
config.opt.str
|
||||
except:
|
||||
pass
|
||||
pass
|
||||
assert stroption._is_disabled()
|
||||
|
||||
def test_multi_with_requires_with_disabled_in_another_group():
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
descr = OptionDescription("options", "", [intoption])
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[('int', 1, 'disable')], multi=True)
|
||||
descr = OptionDescription("opt", "", [stroption])
|
||||
descr2 = OptionDescription("opt2", "", [intoption, s, descr])
|
||||
@ -210,7 +212,7 @@ def test_multi_with_requires_with_disabled_in_another_group():
|
||||
def test_multi_with_requires_that_is_multi():
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=[0], multi=True)
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"],
|
||||
requires=[('int', [1, 1], 'hide')], multi=True)
|
||||
descr = OptionDescription("options", "", [s, intoption, stroption])
|
||||
config = Config(descr)
|
||||
@ -307,7 +309,7 @@ def test_set_with_unknown_option():
|
||||
def test_set_symlink_option():
|
||||
boolopt = BoolOption("b", "", default=False)
|
||||
linkopt = SymLinkOption("c", "s1.b")
|
||||
descr = OptionDescription("opt", "",
|
||||
descr = OptionDescription("opt", "",
|
||||
[linkopt, OptionDescription("s1", "", [boolopt])])
|
||||
config = Config(descr)
|
||||
setattr(config, "s1.b", True)
|
||||
@ -320,18 +322,19 @@ def test_set_symlink_option():
|
||||
config.c = False
|
||||
assert config.s1.b == False
|
||||
assert config.c == False
|
||||
|
||||
|
||||
#____________________________________________________________
|
||||
def test_config_impl_values():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
# gcdummy.setoption(config, True, "user")
|
||||
# config.setoption("gc.dummy", True, "user")
|
||||
#config.gc.dummy = True
|
||||
# config.setoption("bool", False, "user")
|
||||
config.set(dummy=False)
|
||||
assert config.gc._cfgimpl_values == {'dummy': False, 'float': 2.3, 'name': 'ref'}
|
||||
## acces to the option object
|
||||
## acces to the option object
|
||||
# config.gc._cfgimpl_descr.dummy.setoption(config, True, "user")
|
||||
assert config.gc.dummy == False
|
||||
# config.set(dummy=True)
|
||||
@ -346,18 +349,18 @@ def test_accepts_multiple_changes_from_option():
|
||||
assert s.getdefault() == "string"
|
||||
assert config.string == "egg"
|
||||
s.setoption(config, 'blah', "default")
|
||||
assert s.getdefault() == "blah"
|
||||
assert s.getdefault() == "string"
|
||||
assert config.string == "blah"
|
||||
s.setoption(config, 'bol', "user")
|
||||
assert config.string == 'bol'
|
||||
config.override({'string': "blurp"})
|
||||
assert config.string == 'blurp'
|
||||
assert s.getdefault() == 'blurp'
|
||||
# config.override({'string': "blurp"})
|
||||
# assert config.string == 'blurp'
|
||||
# assert s.getdefault() == 'blurp'
|
||||
|
||||
def test_allow_multiple_changes_from_config():
|
||||
"""
|
||||
a `setoption` from the config object is much like the attribute access,
|
||||
except the fact that value owner can bet set
|
||||
a `setoption` from the config object is much like the attribute access,
|
||||
except the fact that value owner can bet set
|
||||
"""
|
||||
s = StrOption("string", "", default="string")
|
||||
s2 = StrOption("string2", "", default="string")
|
||||
@ -365,24 +368,25 @@ def test_allow_multiple_changes_from_config():
|
||||
descr = OptionDescription("options", "", [s, suboption])
|
||||
config = Config(descr)
|
||||
config.setoption("string", 'blah', "user")
|
||||
config.setoption("string", "oh", "user")
|
||||
config.setoption("string", "oh", "user")
|
||||
assert config.string == "oh"
|
||||
config.set(string2= 'blah')
|
||||
assert config.bip.string2 == 'blah'
|
||||
# ____________________________________________________________
|
||||
|
||||
def test_overrides_are_defaults():
|
||||
descr = OptionDescription("test", "", [
|
||||
BoolOption("b1", "", default=False),
|
||||
BoolOption("b2", "", default=False),
|
||||
])
|
||||
# overrides here
|
||||
config = Config(descr, b2=True)
|
||||
assert config.b2
|
||||
# test with a require
|
||||
config.b1 = True
|
||||
assert config.b2
|
||||
|
||||
#def test_overrides_are_defaults():
|
||||
# descr = OptionDescription("test", "", [
|
||||
# BoolOption("b1", "", default=False),
|
||||
# BoolOption("b2", "", default=False),
|
||||
# ])
|
||||
# # overrides here
|
||||
# config = Config(descr)
|
||||
# config.b2 = True
|
||||
# assert config.b2
|
||||
# # test with a require
|
||||
# config.b1 = True
|
||||
# assert config.b2
|
||||
|
||||
# ____________________________________________________________
|
||||
# accessing a value by the get method
|
||||
def test_access_by_get():
|
||||
@ -407,4 +411,3 @@ def test_access_by_get_whith_hide():
|
||||
])
|
||||
c = Config(descr)
|
||||
raises(PropertiesOptionError, "c.get('b1')")
|
||||
|
||||
|
@ -19,7 +19,7 @@ def make_description():
|
||||
wantref_option = BoolOption('wantref', 'Test requires', default=False)
|
||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||
default=False)
|
||||
|
||||
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption, gcdummy2])
|
||||
descr = OptionDescription('tiram', '', [gcgroup, booloption, objspaceoption,
|
||||
wantref_option, stroption,
|
||||
@ -27,11 +27,11 @@ def make_description():
|
||||
intoption, boolop])
|
||||
return descr
|
||||
|
||||
def test_base_config_and_groups():
|
||||
descr = make_description()
|
||||
# overrides the booloption default value
|
||||
config = Config(descr, bool=False)
|
||||
assert config.gc.hide == True
|
||||
#def test_base_config_and_groups():
|
||||
# descr = make_description()
|
||||
# # overrides the booloption default value
|
||||
# config = Config(descr, bool=False)
|
||||
# assert config.gc.hide == True
|
||||
|
||||
def test_root_config_answers_ok():
|
||||
"if you hide the root config, the options in this namespace behave normally"
|
||||
@ -42,6 +42,3 @@ def test_root_config_answers_ok():
|
||||
cfg.cfgimpl_enable_property('hiddend') #cfgimpl_hide()
|
||||
assert cfg.dummy == False
|
||||
assert cfg.boolop == True
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user