2012-07-13 09:42:14 +02:00
|
|
|
#this test is much more to test that **it's there** and answers attribute access
|
|
|
|
import autopath
|
|
|
|
from py.test import raises
|
|
|
|
|
2012-07-23 14:52:08 +02:00
|
|
|
from tiramisu.config import *
|
|
|
|
from tiramisu.option import *
|
2012-07-13 09:42:14 +02:00
|
|
|
|
|
|
|
def make_description():
|
|
|
|
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
|
|
|
gcdummy2 = BoolOption('hide', 'dummy', default=True)
|
|
|
|
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)
|
|
|
|
wantframework_option = BoolOption('wantframework', 'Test requires',
|
|
|
|
default=False)
|
2012-11-12 12:06:58 +01:00
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption, gcdummy2])
|
|
|
|
descr = OptionDescription('tiram', '', [gcgroup, booloption, objspaceoption,
|
|
|
|
wantref_option, stroption,
|
|
|
|
wantframework_option,
|
|
|
|
intoption, boolop])
|
|
|
|
return descr
|
|
|
|
|
2012-11-12 12:06:58 +01:00
|
|
|
#def test_base_config_and_groups():
|
|
|
|
# descr = make_description()
|
|
|
|
# # overrides the booloption default value
|
|
|
|
# config = Config(descr, bool=False)
|
|
|
|
# assert config.gc.hide == True
|
2012-07-13 09:42:14 +02:00
|
|
|
|
|
|
|
def test_root_config_answers_ok():
|
|
|
|
"if you hide the root config, the options in this namespace behave normally"
|
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
|
|
|
boolop = BoolOption('boolop', 'Test boolean option op', default=True)
|
|
|
|
descr = OptionDescription('tiramisu', '', [gcdummy, boolop])
|
|
|
|
cfg = Config(descr)
|
2013-02-07 16:20:21 +01:00
|
|
|
settings = cfg.cfgimpl_get_settings()
|
2012-11-19 10:45:03 +01:00
|
|
|
settings.enable_property('hiddend') #cfgimpl_hide()
|
2012-07-13 09:42:14 +02:00
|
|
|
assert cfg.dummy == False
|
|
|
|
assert cfg.boolop == True
|
2013-02-25 11:33:20 +01:00
|
|
|
|
|
|
|
def test_optname_shall_not_start_with_numbers():
|
2013-02-25 16:06:10 +01:00
|
|
|
raises(NameError, "gcdummy = BoolOption('123dummy', 'dummy', default=False)")
|
|
|
|
raises(NameError, "descr = OptionDescription('123tiramisu', '', [])")
|
2013-02-25 11:33:20 +01:00
|
|
|
|
2013-04-03 16:01:53 +02:00
|
|
|
#def test_option_has_an_api_name():
|
|
|
|
# gcdummy = BoolOption('cfgimpl_get_settings', 'dummy', default=False)
|
|
|
|
# boolop = BoolOption('boolop', 'Test boolean option op', default=True)
|
|
|
|
# descr = OptionDescription('tiramisu', '', [gcdummy, boolop])
|
|
|
|
# raises(NameError, "cfg = Config(descr)")
|