tiramisu/test/test_slots.py

55 lines
1.5 KiB
Python

# coding: utf-8
import autopath
from py.test import raises
from tiramisu.config import Config, SubConfig
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
StrOption, OptionDescription, SymLinkOption, UnicodeOption
def test_slots_option():
c = BoolOption('a', '')
raises(AttributeError, "c.x = 1")
c = IntOption('a', '')
raises(AttributeError, "c.x = 1")
c = FloatOption('a', '')
raises(AttributeError, "c.x = 1")
c = StrOption('a', '')
raises(AttributeError, "c.x = 1")
c = SymLinkOption('b', c)
raises(AttributeError, "c.x = 1")
c = UnicodeOption('a', '')
raises(AttributeError, "c.x = 1")
c = ChoiceOption('a', '', ('a',))
raises(AttributeError, "c.x = 1")
c = OptionDescription('a', '', [])
raises(AttributeError, "c.x = 1")
def test_slots_config():
od1 = OptionDescription('a', '', [])
od2 = OptionDescription('a', '', [od1])
c = Config(od2)
raises(AttributeError, "c.x = 1")
raises(AttributeError, "c.cfgimpl_x = 1")
sc = c.a
assert isinstance(sc, SubConfig)
raises(AttributeError, "sc.x = 1")
raises(AttributeError, "sc.cfgimpl_x = 1")
def test_slots_setting():
od1 = OptionDescription('a', '', [])
od2 = OptionDescription('a', '', [od1])
c = Config(od2)
s = c.cfgimpl_get_settings()
raises(AttributeError, "s.x = 1")
def test_slots_value():
od1 = OptionDescription('a', '', [])
od2 = OptionDescription('a', '', [od1])
c = Config(od2)
v = c.cfgimpl_get_values()
raises(AttributeError, "v.x = 1")