values are in value objects now
This commit is contained in:
@ -89,13 +89,13 @@ def test_base_config_in_a_tree():
|
||||
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)
|
||||
config.bool = False
|
||||
config.set(dummy=False)
|
||||
assert config.gc._cfgimpl_values == {'dummy': False, 'float': 2.3, 'name': 'ref'}
|
||||
#def test_config_values():
|
||||
# "_cfgimpl_values appears to be a simple dict"
|
||||
# descr = make_description()
|
||||
# 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()
|
||||
|
@ -3,7 +3,6 @@ from py.test import raises
|
||||
|
||||
from tiramisu.config import *
|
||||
from tiramisu.option import *
|
||||
from tiramisu.setting import settings
|
||||
|
||||
def make_description():
|
||||
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
||||
@ -126,14 +125,14 @@ def test_newoption_add_in_subdescr():
|
||||
config.bool = False
|
||||
assert config.gc.newoption == False
|
||||
|
||||
def test_newoption_add_in_config():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
newoption = BoolOption('newoption', 'dummy twoo', default=False)
|
||||
descr.add_child(newoption)
|
||||
config.cfgimpl_update()
|
||||
assert config.newoption == False
|
||||
#def test_newoption_add_in_config():
|
||||
# descr = make_description()
|
||||
# config = Config(descr)
|
||||
# config.bool = False
|
||||
# newoption = BoolOption('newoption', 'dummy twoo', default=False)
|
||||
# descr.add_child(newoption)
|
||||
# config.cfgimpl_update()
|
||||
# assert config.newoption == False
|
||||
# ____________________________________________________________
|
||||
def make_description_requires():
|
||||
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
||||
@ -236,6 +235,7 @@ def test_has_callback():
|
||||
config.bool = False
|
||||
# because dummy has a callback
|
||||
dummy = config.unwrap_from_path('gc.dummy')
|
||||
settings = config.cfgimpl_get_settings()
|
||||
settings.freeze()
|
||||
dummy.freeze()
|
||||
raises(TypeError, "config.gc.dummy = True")
|
||||
@ -244,6 +244,7 @@ def test_freeze_and_has_callback_with_setoption():
|
||||
descr = make_description_callback()
|
||||
config = Config(descr)
|
||||
config.bool = False
|
||||
settings = config.cfgimpl_get_settings()
|
||||
settings.freeze()
|
||||
dummy = config.unwrap_from_path('gc.dummy')
|
||||
dummy.freeze()
|
||||
|
@ -79,18 +79,18 @@ def test_force_default_on_freeze():
|
||||
assert config.dummy1 == False
|
||||
assert config.dummy2 == False
|
||||
|
||||
def test_override_are_defaults():
|
||||
descr = make_description()
|
||||
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})
|
||||
#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'
|
||||
#def test_override_are_defaults():
|
||||
# descr = make_description()
|
||||
# config = Config(descr)
|
||||
# config.bool = False
|
||||
# config.gc.dummy = True
|
||||
# assert config._cfgimpl_values['gc']._cfgimpl_values.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.dummy == True
|
||||
# #assert config._cfgimpl_descr._children[0]._children[1].getdefault() == True
|
||||
# #assert config._cfgimpl_values['gc']._cfgimpl_value_owners['dummy'] == 'default'
|
||||
|
||||
def test_overrides_changes_option_value():
|
||||
"with config.override(), the default is changed and the value is changed"
|
||||
|
@ -3,7 +3,7 @@ import autopath
|
||||
from py.test import raises
|
||||
from tiramisu.config import *
|
||||
from tiramisu.option import *
|
||||
from tiramisu.setting import settings, owners
|
||||
from tiramisu.setting import owners
|
||||
|
||||
def make_description():
|
||||
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
||||
|
@ -51,10 +51,10 @@ def test_reset():
|
||||
config = Config(descr)
|
||||
config.string = "foo"
|
||||
assert config.string == "foo"
|
||||
assert config._cfgimpl_value_owners['string'] == owners.user
|
||||
assert config._cfgimpl_values.owners[s] == owners.user
|
||||
config.unwrap_from_path("string").reset(config)
|
||||
assert config.string == 'string'
|
||||
assert config._cfgimpl_value_owners['string'] == owners.default
|
||||
assert config._cfgimpl_values.owners[s] == owners.default
|
||||
|
||||
def test_reset_with_multi():
|
||||
s = StrOption("string", "", default=["string"], default_multi="string" , multi=True)
|
||||
@ -63,13 +63,13 @@ def test_reset_with_multi():
|
||||
# config.string = []
|
||||
config.unwrap_from_path("string").reset(config)
|
||||
assert config.string == ["string"]
|
||||
assert config._cfgimpl_value_owners['string'] == 'default'
|
||||
assert config._cfgimpl_values.owners[s] == 'default'
|
||||
config.string = ["eggs", "spam", "foo"]
|
||||
assert config._cfgimpl_value_owners['string'] == 'user'
|
||||
assert config._cfgimpl_values.owners[s] == 'user'
|
||||
config.string = []
|
||||
config.unwrap_from_path("string").reset(config)
|
||||
# assert config.string == ["string"]
|
||||
assert config._cfgimpl_value_owners['string'] == 'default'
|
||||
assert config._cfgimpl_values.owners[s] == 'default'
|
||||
raises(ConfigError, "config.string = None")
|
||||
|
||||
def test_default_with_multi():
|
||||
@ -111,10 +111,10 @@ def test_access_with_multi_default():
|
||||
s = StrOption("string", "", default=["string"], multi=True)
|
||||
descr = OptionDescription("options", "", [s])
|
||||
config = Config(descr)
|
||||
assert config._cfgimpl_value_owners["string"] == 'default'
|
||||
assert config._cfgimpl_values.owners[s] == 'default'
|
||||
config.string = ["foo", "bar"]
|
||||
assert config.string == ["foo", "bar"]
|
||||
assert config._cfgimpl_value_owners["string"] == 'user'
|
||||
assert config._cfgimpl_values.owners[s] == 'user'
|
||||
|
||||
#def test_attribute_access_with_multi2():
|
||||
# s = StrOption("string", "", default="string", multi=True)
|
||||
@ -227,7 +227,7 @@ def test_multi_with_bool():
|
||||
config = Config(descr)
|
||||
assert descr.bool.multi == True
|
||||
config.bool = [True, False]
|
||||
assert config._cfgimpl_values['bool'] == [True, False]
|
||||
assert config._cfgimpl_context._cfgimpl_values[s] == [True, False]
|
||||
assert config.bool == [True, False]
|
||||
|
||||
def test_multi_with_bool_two():
|
||||
@ -323,22 +323,22 @@ def test_set_symlink_option():
|
||||
assert config.s1.b == False
|
||||
assert config.c == False
|
||||
|
||||
#____________________________________________________________
|
||||
def test_config_impl_values():
|
||||
descr = make_description()
|
||||
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
|
||||
# config.gc._cfgimpl_descr.dummy.setoption(config, True, "user")
|
||||
assert config.gc.dummy == False
|
||||
# config.set(dummy=True)
|
||||
# assert config.gc.dummy == True
|
||||
##____________________________________________________________
|
||||
#def test_config_impl_values():
|
||||
# descr = make_description()
|
||||
# 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_context._cfgimpl_values.values == {'dummy': False, 'float': 2.3, 'name': 'ref'}
|
||||
# ## acces to the option object
|
||||
## config.gc._cfgimpl_descr.dummy.setoption(config, True, "user")
|
||||
# assert config.gc.dummy == False
|
||||
## config.set(dummy=True)
|
||||
## assert config.gc.dummy == True
|
||||
|
||||
#____________________________________________________________
|
||||
def test_accepts_multiple_changes_from_option():
|
||||
|
@ -5,7 +5,6 @@ from py.test import raises
|
||||
|
||||
from tiramisu.config import *
|
||||
from tiramisu.option import *
|
||||
from tiramisu.setting import settings
|
||||
|
||||
def make_description():
|
||||
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
||||
@ -64,6 +63,7 @@ def make_description_freeze():
|
||||
def test_freeze_whole_config():
|
||||
descr = make_description_freeze()
|
||||
conf = Config(descr)
|
||||
settings = conf.cfgimpl_get_settings()
|
||||
settings.freeze_everything()
|
||||
assert conf.gc.dummy == False
|
||||
raises(TypeError, "conf.gc.dummy = True")
|
||||
@ -85,6 +85,7 @@ def test_frozen_value():
|
||||
s = StrOption("string", "", default="string")
|
||||
descr = OptionDescription("options", "", [s])
|
||||
config = Config(descr)
|
||||
settings = config.cfgimpl_get_settings()
|
||||
settings.freeze()
|
||||
s.freeze()
|
||||
raises(TypeError, 'config.string = "egg"')
|
||||
@ -93,6 +94,7 @@ def test_freeze():
|
||||
"freeze a whole configuration object"
|
||||
descr = make_description()
|
||||
conf = Config(descr)
|
||||
settings = conf.cfgimpl_get_settings()
|
||||
settings.freeze()
|
||||
name = conf.unwrap_from_path("gc.name")
|
||||
name.freeze()
|
||||
@ -107,9 +109,8 @@ def test_is_hidden():
|
||||
# getattr
|
||||
raises(PropertiesOptionError, "config.gc.dummy")
|
||||
# I want to access to this option anyway
|
||||
path = 'gc.dummy'
|
||||
homeconfig, name = config._cfgimpl_get_home_by_path(path)
|
||||
assert homeconfig._cfgimpl_values[name] == False
|
||||
opt = config.unwrap_from_path("gc.dummy")
|
||||
assert config._cfgimpl_context._cfgimpl_values[opt] == False
|
||||
|
||||
def test_group_is_hidden():
|
||||
descr = make_description()
|
||||
|
@ -4,7 +4,6 @@ from py.test import raises
|
||||
|
||||
from tiramisu.config import *
|
||||
from tiramisu.option import *
|
||||
from tiramisu.setting import settings
|
||||
|
||||
def make_description():
|
||||
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
||||
@ -40,6 +39,7 @@ def test_root_config_answers_ok():
|
||||
boolop = BoolOption('boolop', 'Test boolean option op', default=True)
|
||||
descr = OptionDescription('tiramisu', '', [gcdummy, boolop])
|
||||
cfg = Config(descr)
|
||||
settings = cfg.cfgimpl_get_settings()
|
||||
settings.enable_property('hiddend') #cfgimpl_hide()
|
||||
assert cfg.dummy == False
|
||||
assert cfg.boolop == True
|
||||
|
@ -1,7 +1,7 @@
|
||||
import autopath
|
||||
from py.test import raises
|
||||
#import autopath
|
||||
#from py.test import raises
|
||||
|
||||
from tool import reverse_from_paths
|
||||
#from tool import reverse_from_paths
|
||||
|
||||
#def make_description():
|
||||
# gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
||||
@ -16,7 +16,7 @@ from tool import reverse_from_paths
|
||||
# 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,
|
||||
@ -24,19 +24,19 @@ from tool import reverse_from_paths
|
||||
# intoption, boolop])
|
||||
# return descr
|
||||
|
||||
def test_rebuild():
|
||||
# pouvoir faire une comparaison avec equal
|
||||
d = {"s1.s2.s3.s4.a": True, "int": 43, "s2.b":True, "s3.c": True, "s3.d":[1,2,3]}
|
||||
cfg = reverse_from_paths(d)
|
||||
assert cfg.s1.s2.s3.s4.a == True
|
||||
assert cfg.int == 43
|
||||
assert cfg.s2.b == True
|
||||
assert cfg.s3.c == True
|
||||
assert cfg.s3.d == [1,2,3]
|
||||
|
||||
#def test_rebuild():
|
||||
# # pouvoir faire une comparaison avec equal
|
||||
# d = {"s1.s2.s3.s4.a": True, "int": 43, "s2.b":True, "s3.c": True, "s3.d":[1,2,3]}
|
||||
# cfg = reverse_from_paths(d)
|
||||
# assert cfg.s1.s2.s3.s4.a == True
|
||||
# assert cfg.int == 43
|
||||
# assert cfg.s2.b == True
|
||||
# assert cfg.s3.c == True
|
||||
# assert cfg.s3.d == [1,2,3]
|
||||
|
||||
# assert config.getpaths() == ['gc.name', 'gc.dummy', 'gc.float', 'bool',
|
||||
# 'objspace', 'wantref', 'str', 'wantframework',
|
||||
# 'int', 'boolop']
|
||||
|
||||
# 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']
|
||||
|
Reference in New Issue
Block a user