2012-07-13 09:42:14 +02:00
|
|
|
import autopath
|
|
|
|
|
|
|
|
from py.test import raises
|
2012-07-23 14:52:08 +02:00
|
|
|
from tiramisu.config import *
|
|
|
|
from tiramisu.option import *
|
2012-12-10 14:10:05 +01:00
|
|
|
from tiramisu.setting import settings, owners
|
2012-07-13 09:42:14 +02:00
|
|
|
|
|
|
|
def make_description():
|
|
|
|
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
2012-12-10 14:10:05 +01:00
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
2012-07-13 09:42:14 +02:00
|
|
|
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)
|
2012-12-10 14:10:05 +01:00
|
|
|
wantref_option = BoolOption('wantref', 'Test requires', default=False)
|
2012-07-13 09:42:14 +02:00
|
|
|
wantframework_option = BoolOption('wantframework', 'Test requires',
|
2012-12-10 14:10:05 +01:00
|
|
|
default=False)
|
|
|
|
|
2012-07-13 09:42:14 +02:00
|
|
|
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
2012-12-10 14:10:05 +01:00
|
|
|
descr = OptionDescription('tiram', '', [gcgroup, booloption, objspaceoption,
|
2012-07-13 09:42:14 +02:00
|
|
|
wantref_option, stroption,
|
|
|
|
wantframework_option,
|
|
|
|
intoption, boolop])
|
|
|
|
return descr
|
|
|
|
|
2012-12-10 14:10:05 +01:00
|
|
|
def test_default_owner():
|
2012-07-13 09:42:14 +02:00
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
2012-12-10 14:10:05 +01:00
|
|
|
descr = OptionDescription('tiramisu', '', [gcdummy])
|
|
|
|
cfg = Config(descr)
|
|
|
|
assert cfg.dummy == False
|
|
|
|
dm = cfg.unwrap_from_path('dummy')
|
|
|
|
assert dm.getowner(cfg) == 'default'
|
|
|
|
dm.setowner(cfg, owners.user)
|
|
|
|
assert dm.getowner(cfg) == owners.user
|
2012-07-13 09:42:14 +02:00
|
|
|
|
2012-12-10 14:10:05 +01:00
|
|
|
def test_owner_is_not_a_string():
|
|
|
|
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
|
|
|
descr = OptionDescription('tiramisu', '', [gcdummy])
|
|
|
|
cfg = Config(descr)
|
|
|
|
assert cfg.dummy == False
|
|
|
|
dm = cfg.unwrap_from_path('dummy')
|
|
|
|
assert dm.getowner(cfg) == owners.default
|
|
|
|
assert dm.getowner(cfg) == 'default'
|
|
|
|
assert isinstance(dm.getowner(cfg), owners.Owner)
|
|
|
|
dm.setowner(cfg, owners.user)
|
2012-09-12 10:38:41 +02:00
|
|
|
|
2012-12-10 14:10:05 +01:00
|
|
|
assert dm.getowner(cfg) == 'user'
|