remove pep8 validation errors
This commit is contained in:
parent
6cc74506fb
commit
44cd618704
|
@ -7,8 +7,8 @@ checkout)
|
||||||
from os.path import dirname, abspath, join, normpath
|
from os.path import dirname, abspath, join, normpath
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
HERE = dirname(abspath(__file__))
|
def do_autopath():
|
||||||
PATH = normpath(join(HERE, '..', 'tiramisu'))
|
HERE = dirname(abspath(__file__))
|
||||||
if PATH not in sys.path:
|
PATH = normpath(join(HERE, '..', 'tiramisu'))
|
||||||
|
if PATH not in sys.path:
|
||||||
sys.path.insert(1, PATH)
|
sys.path.insert(1, PATH)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu import setting
|
from tiramisu import setting
|
||||||
setting.expires_time = 1
|
setting.expires_time = 1
|
||||||
from tiramisu.option import IntOption, OptionDescription
|
from tiramisu.option import IntOption, OptionDescription
|
||||||
|
@ -20,9 +22,10 @@ def make_description():
|
||||||
|
|
||||||
def test_cache_config():
|
def test_cache_config():
|
||||||
od1 = make_description()
|
od1 = make_description()
|
||||||
assert od1.impl_already_build_caches() == False
|
assert od1.impl_already_build_caches() is False
|
||||||
c = Config(od1)
|
c = Config(od1)
|
||||||
assert od1.impl_already_build_caches() == True
|
assert od1.impl_already_build_caches() is True
|
||||||
|
c
|
||||||
|
|
||||||
|
|
||||||
def test_cache():
|
def test_cache():
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import owners
|
from tiramisu.setting import owners
|
||||||
from tiramisu.option import ChoiceOption, StrOption, OptionDescription
|
from tiramisu.option import ChoiceOption, StrOption, OptionDescription
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
"""theses tests are much more to test that config, option description, vs...
|
"""theses tests are much more to test that config, option description, vs...
|
||||||
**it's there** and answers via attribute access"""
|
**it's there** and answers via attribute access"""
|
||||||
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
import autopath
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.config import Config, SubConfig
|
from tiramisu.config import Config, SubConfig
|
||||||
|
@ -165,6 +166,7 @@ def test_config_impl_get_path_by_opt():
|
||||||
dummy = config.unwrap_from_path('gc.dummy')
|
dummy = config.unwrap_from_path('gc.dummy')
|
||||||
boo = config.unwrap_from_path('bool')
|
boo = config.unwrap_from_path('bool')
|
||||||
unknown = IntOption('test', '')
|
unknown = IntOption('test', '')
|
||||||
|
unknown
|
||||||
assert config.cfgimpl_get_description().impl_get_path_by_opt(boo) == 'bool'
|
assert config.cfgimpl_get_description().impl_get_path_by_opt(boo) == 'bool'
|
||||||
assert config.cfgimpl_get_description().impl_get_path_by_opt(dummy) == 'gc.dummy'
|
assert config.cfgimpl_get_description().impl_get_path_by_opt(dummy) == 'gc.dummy'
|
||||||
raises(AttributeError, "config.cfgimpl_get_description().impl_get_path_by_opt(unknown)")
|
raises(AttributeError, "config.cfgimpl_get_description().impl_get_path_by_opt(unknown)")
|
||||||
|
@ -236,11 +238,13 @@ def test_values_not_setitem():
|
||||||
d1 = OptionDescription('od', '', [g1, g2, g3, g4, g5])
|
d1 = OptionDescription('od', '', [g1, g2, g3, g4, g5])
|
||||||
root = OptionDescription('root', '', [d1])
|
root = OptionDescription('root', '', [d1])
|
||||||
config = Config(root)
|
config = Config(root)
|
||||||
|
config
|
||||||
raises(ConfigError, "config.cfgimpl_get_values()[g1] = 2")
|
raises(ConfigError, "config.cfgimpl_get_values()[g1] = 2")
|
||||||
|
|
||||||
|
|
||||||
def test_duplicated_option():
|
def test_duplicated_option():
|
||||||
g1 = IntOption('g1', '', 1)
|
g1 = IntOption('g1', '', 1)
|
||||||
|
g1
|
||||||
#in same OptionDescription
|
#in same OptionDescription
|
||||||
raises(ConflictError, "d1 = OptionDescription('od', '', [g1, g1])")
|
raises(ConflictError, "d1 = OptionDescription('od', '', [g1, g1])")
|
||||||
|
|
||||||
|
@ -250,12 +254,14 @@ def test_duplicated_option_diff_od():
|
||||||
d1 = OptionDescription('od1', '', [g1])
|
d1 = OptionDescription('od1', '', [g1])
|
||||||
#in different OptionDescription
|
#in different OptionDescription
|
||||||
d2 = OptionDescription('od2', '', [g1, d1])
|
d2 = OptionDescription('od2', '', [g1, d1])
|
||||||
|
d2
|
||||||
raises(ConflictError, 'Config(d2)')
|
raises(ConflictError, 'Config(d2)')
|
||||||
|
|
||||||
|
|
||||||
def test_cannot_assign_value_to_option_description():
|
def test_cannot_assign_value_to_option_description():
|
||||||
descr = make_description()
|
descr = make_description()
|
||||||
cfg = Config(descr)
|
cfg = Config(descr)
|
||||||
|
cfg
|
||||||
raises(TypeError, "cfg.gc = 3")
|
raises(TypeError, "cfg.gc = 3")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
"configuration objects global API"
|
"configuration objects global API"
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
|
@ -197,6 +199,7 @@ def test_find_multi():
|
||||||
def test_does_not_find_in_config():
|
def test_does_not_find_in_config():
|
||||||
descr = make_description()
|
descr = make_description()
|
||||||
conf = Config(descr)
|
conf = Config(descr)
|
||||||
|
conf
|
||||||
raises(AttributeError, "conf.find(byname='IDontExist')")
|
raises(AttributeError, "conf.find(byname='IDontExist')")
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,14 +269,21 @@ def test_impl_getpaths():
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_option():
|
def test_invalid_option():
|
||||||
|
ChoiceOption('a', '', ('1', '2'))
|
||||||
raises(TypeError, "ChoiceOption('a', '', [1, 2])")
|
raises(TypeError, "ChoiceOption('a', '', [1, 2])")
|
||||||
raises(TypeError, "ChoiceOption('a', '', 1)")
|
raises(TypeError, "ChoiceOption('a', '', 1)")
|
||||||
raises(ValueError, "ChoiceOption('a', '', (1,), 3)")
|
raises(ValueError, "ChoiceOption('a', '', (1,), 3)")
|
||||||
|
FloatOption('a', '')
|
||||||
raises(ValueError, "FloatOption('a', '', 'string')")
|
raises(ValueError, "FloatOption('a', '', 'string')")
|
||||||
|
UnicodeOption('a', '')
|
||||||
raises(ValueError, "UnicodeOption('a', '', 1)")
|
raises(ValueError, "UnicodeOption('a', '', 1)")
|
||||||
|
u = UnicodeOption('a', '')
|
||||||
|
SymLinkOption('a', u)
|
||||||
raises(ValueError, "SymLinkOption('a', 'string')")
|
raises(ValueError, "SymLinkOption('a', 'string')")
|
||||||
|
IPOption('a', '')
|
||||||
raises(ValueError, "IPOption('a', '', 1)")
|
raises(ValueError, "IPOption('a', '', 1)")
|
||||||
raises(ValueError, "IPOption('a', '', 'string')")
|
raises(ValueError, "IPOption('a', '', 'string')")
|
||||||
|
PortOption('a', '')
|
||||||
raises(ValueError, "PortOption('a', '', 'string')")
|
raises(ValueError, "PortOption('a', '', 'string')")
|
||||||
raises(ValueError, "PortOption('a', '', '11:12:13', allow_range=True)")
|
raises(ValueError, "PortOption('a', '', '11:12:13', allow_range=True)")
|
||||||
raises(ValueError, "PortOption('a', '', 11111111111111111111)")
|
raises(ValueError, "PortOption('a', '', 11111111111111111111)")
|
||||||
|
@ -282,9 +292,13 @@ def test_invalid_option():
|
||||||
raises(ValueError, "PortOption('a', '', allow_zero=True, allow_wellknown=False, allow_registred=False, allow_private=True)")
|
raises(ValueError, "PortOption('a', '', allow_zero=True, allow_wellknown=False, allow_registred=False, allow_private=True)")
|
||||||
raises(ValueError, "PortOption('a', '', allow_zero=True, allow_wellknown=False, allow_registred=True, allow_private=True)")
|
raises(ValueError, "PortOption('a', '', allow_zero=True, allow_wellknown=False, allow_registred=True, allow_private=True)")
|
||||||
raises(ValueError, "PortOption('a', '', allow_zero=False, allow_wellknown=False, allow_registred=False, allow_private=False)")
|
raises(ValueError, "PortOption('a', '', allow_zero=False, allow_wellknown=False, allow_registred=False, allow_private=False)")
|
||||||
|
NetworkOption('a', '')
|
||||||
raises(ValueError, "NetworkOption('a', '', 'string')")
|
raises(ValueError, "NetworkOption('a', '', 'string')")
|
||||||
|
NetmaskOption('a', '')
|
||||||
raises(ValueError, "NetmaskOption('a', '', 'string')")
|
raises(ValueError, "NetmaskOption('a', '', 'string')")
|
||||||
|
BroadcastOption('a', '')
|
||||||
raises(ValueError, "BroadcastOption('a', '', 'string')")
|
raises(ValueError, "BroadcastOption('a', '', 'string')")
|
||||||
|
DomainnameOption('a', '')
|
||||||
raises(ValueError, "DomainnameOption('a', '', 'string')")
|
raises(ValueError, "DomainnameOption('a', '', 'string')")
|
||||||
raises(ValueError, "DomainnameOption('a', '', type_='string')")
|
raises(ValueError, "DomainnameOption('a', '', type_='string')")
|
||||||
raises(ValueError, "DomainnameOption('a', '', allow_ip='string')")
|
raises(ValueError, "DomainnameOption('a', '', allow_ip='string')")
|
||||||
|
|
|
@ -1,258 +0,0 @@
|
||||||
##just a proof of concept with a lot of options and option groups
|
|
||||||
#import autopath
|
|
||||||
#from tiramisu.config import *
|
|
||||||
#from tiramisu.option import *
|
|
||||||
|
|
||||||
#all_modules = ['amon', 'sphynx', 'zephir']
|
|
||||||
|
|
||||||
#example__optiondescription = OptionDescription("objspace", "Object Space Options", [
|
|
||||||
# ChoiceOption("name", "Object Space name",
|
|
||||||
# ["std", "flow", "thunk", "dump", "taint"],
|
|
||||||
# "std"),
|
|
||||||
|
|
||||||
# OptionDescription("opcodes", "opcodes to enable in the interpreter", [
|
|
||||||
# BoolOption("CALL_LIKELY_BUILTIN", "emit a special bytecode for likely calls to builtin functions",
|
|
||||||
# default=False,
|
|
||||||
# requires=[("translation.stackless", False)]),
|
|
||||||
# BoolOption("CALL_METHOD", "emit a special bytecode for expr.name()",
|
|
||||||
# default=False),
|
|
||||||
# ]),
|
|
||||||
|
|
||||||
# BoolOption("nofaking", "disallow faking in the object space",
|
|
||||||
# default=False,
|
|
||||||
# requires=[
|
|
||||||
# ("objspace.usemodules.posix", True),
|
|
||||||
# ("objspace.usemodules.time", True),
|
|
||||||
# ("objspace.usemodules.errno", True)],
|
|
||||||
# ),
|
|
||||||
|
|
||||||
# OptionDescription("usemodules", "Which Modules should be used", [
|
|
||||||
# BoolOption(modname, "use module %s" % (modname, ),
|
|
||||||
# default=True,
|
|
||||||
# requires= [('amon', False)],
|
|
||||||
# )
|
|
||||||
# for modname in all_modules]),
|
|
||||||
|
|
||||||
# BoolOption("allworkingmodules", "use as many working modules as possible",
|
|
||||||
# default=True,
|
|
||||||
# ),
|
|
||||||
|
|
||||||
# BoolOption("translationmodules",
|
|
||||||
# "use only those modules that are needed to run translate.py on pypy",
|
|
||||||
# default=False,
|
|
||||||
# ),
|
|
||||||
|
|
||||||
# BoolOption("geninterp", "specify whether geninterp should be used",
|
|
||||||
# default=True),
|
|
||||||
|
|
||||||
# BoolOption("logbytecodes",
|
|
||||||
# "keep track of bytecode usage",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# BoolOption("usepycfiles", "Write and read pyc files when importing",
|
|
||||||
# default=True),
|
|
||||||
|
|
||||||
# BoolOption("lonepycfiles", "Import pyc files with no matching py file",
|
|
||||||
# default=False,
|
|
||||||
# requires=[("objspace.usepycfiles", True)]),
|
|
||||||
|
|
||||||
# StrOption("soabi",
|
|
||||||
# "Tag to differentiate extension modules built for different Python interpreters",
|
|
||||||
# default=None),
|
|
||||||
|
|
||||||
# BoolOption("honor__builtins__",
|
|
||||||
# "Honor the __builtins__ key of a module dictionary",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# BoolOption("disable_call_speedhacks",
|
|
||||||
# "make sure that all calls go through space.call_args",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# BoolOption("timing",
|
|
||||||
# "timing of various parts of the interpreter (simple profiling)",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# OptionDescription("std", "Standard Object Space Options", [
|
|
||||||
# BoolOption("withtproxy", "support transparent proxies",
|
|
||||||
# default=True),
|
|
||||||
|
|
||||||
# BoolOption("withsmallint", "use tagged integers",
|
|
||||||
# default=False,
|
|
||||||
# requires=[("objspace.std.withprebuiltint", False),
|
|
||||||
# ("translation.taggedpointers", True)]),
|
|
||||||
|
|
||||||
# BoolOption("withprebuiltint", "prebuild commonly used int objects",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# IntOption("prebuiltintfrom", "lowest integer which is prebuilt",
|
|
||||||
# default=-5),
|
|
||||||
|
|
||||||
# IntOption("prebuiltintto", "highest integer which is prebuilt",
|
|
||||||
# default=100),
|
|
||||||
|
|
||||||
# BoolOption("withstrjoin", "use strings optimized for addition",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# BoolOption("withstrslice", "use strings optimized for slicing",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# BoolOption("withstrbuf", "use strings optimized for addition (ver 2)",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# BoolOption("withprebuiltchar",
|
|
||||||
# "use prebuilt single-character string objects",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# BoolOption("sharesmallstr",
|
|
||||||
# "always reuse the prebuilt string objects "
|
|
||||||
# "(the empty string and potentially single-char strings)",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# BoolOption("withrope", "use ropes as the string implementation",
|
|
||||||
# default=False,
|
|
||||||
# requires=[("objspace.std.withstrslice", False),
|
|
||||||
# ("objspace.std.withstrjoin", False),
|
|
||||||
# ("objspace.std.withstrbuf", False)],
|
|
||||||
# ),
|
|
||||||
|
|
||||||
# BoolOption("withropeunicode", "use ropes for the unicode implementation",
|
|
||||||
# default=False,
|
|
||||||
# requires=[("objspace.std.withrope", True)]),
|
|
||||||
|
|
||||||
# BoolOption("withcelldict",
|
|
||||||
# "use dictionaries that are optimized for being used as module dicts",
|
|
||||||
# default=False,
|
|
||||||
# requires=[("objspace.opcodes.CALL_LIKELY_BUILTIN", False),
|
|
||||||
# ("objspace.honor__builtins__", False)]),
|
|
||||||
|
|
||||||
# BoolOption("withdictmeasurement",
|
|
||||||
# "create huge files with masses of information "
|
|
||||||
# "about dictionaries",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# BoolOption("withmapdict",
|
|
||||||
# "make instances really small but slow without the JIT",
|
|
||||||
# default=False,
|
|
||||||
# requires=[("objspace.std.getattributeshortcut", True),
|
|
||||||
# ("objspace.std.withtypeversion", True),
|
|
||||||
# ]),
|
|
||||||
|
|
||||||
# BoolOption("withrangelist",
|
|
||||||
# "enable special range list implementation that does not "
|
|
||||||
# "actually create the full list until the resulting "
|
|
||||||
# "list is mutated",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# BoolOption("withtypeversion",
|
|
||||||
# "version type objects when changing them",
|
|
||||||
# default=False,
|
|
||||||
# # weakrefs needed, because of get_subclasses()
|
|
||||||
# requires=[("translation.rweakref", True)]),
|
|
||||||
|
|
||||||
# BoolOption("withmethodcache",
|
|
||||||
# "try to cache method lookups",
|
|
||||||
# default=False,
|
|
||||||
# requires=[("objspace.std.withtypeversion", True),
|
|
||||||
# ("translation.rweakref", True)]),
|
|
||||||
# BoolOption("withmethodcachecounter",
|
|
||||||
# "try to cache methods and provide a counter in __pypy__. "
|
|
||||||
# "for testing purposes only.",
|
|
||||||
# default=False,
|
|
||||||
# requires=[("objspace.std.withmethodcache", True)]),
|
|
||||||
# IntOption("methodcachesizeexp",
|
|
||||||
# " 2 ** methodcachesizeexp is the size of the of the method cache ",
|
|
||||||
# default=11),
|
|
||||||
# BoolOption("optimized_int_add",
|
|
||||||
# "special case the addition of two integers in BINARY_ADD",
|
|
||||||
# default=False),
|
|
||||||
# BoolOption("optimized_comparison_op",
|
|
||||||
# "special case the comparison of integers",
|
|
||||||
# default=False),
|
|
||||||
# BoolOption("optimized_list_getitem",
|
|
||||||
# "special case the 'list[integer]' expressions",
|
|
||||||
# default=False),
|
|
||||||
# BoolOption("builtinshortcut",
|
|
||||||
# "a shortcut for operations between built-in types",
|
|
||||||
# default=False),
|
|
||||||
# BoolOption("getattributeshortcut",
|
|
||||||
# "track types that override __getattribute__",
|
|
||||||
# default=False),
|
|
||||||
# BoolOption("newshortcut",
|
|
||||||
# "cache and shortcut calling __new__ from builtin types",
|
|
||||||
# default=False),
|
|
||||||
|
|
||||||
# BoolOption("logspaceoptypes",
|
|
||||||
# "a instrumentation option: before exit, print the types seen by "
|
|
||||||
# "certain simpler bytecodes",
|
|
||||||
# default=False),
|
|
||||||
# ChoiceOption("multimethods", "the multimethod implementation to use",
|
|
||||||
# ["doubledispatch", "mrd"],
|
|
||||||
# default="mrd"),
|
|
||||||
# BoolOption("immutable_builtintypes",
|
|
||||||
# "Forbid the changing of builtin types", default=True),
|
|
||||||
# ]),
|
|
||||||
#])
|
|
||||||
|
|
||||||
## ____________________________________________________________
|
|
||||||
|
|
||||||
#def get_combined_translation_config(other_optdescr=None,
|
|
||||||
# existing_config=None,
|
|
||||||
# overrides=None,
|
|
||||||
# translating=False):
|
|
||||||
# if overrides is None:
|
|
||||||
# overrides = {}
|
|
||||||
# d = BoolOption("translating",
|
|
||||||
# "indicates whether we are translating currently",
|
|
||||||
# default=False)
|
|
||||||
# if other_optdescr is None:
|
|
||||||
# children = []
|
|
||||||
# newname = ""
|
|
||||||
# else:
|
|
||||||
# children = [other_optdescr]
|
|
||||||
# newname = other_optdescr._name
|
|
||||||
# descr = OptionDescription("eole", "all options", children)
|
|
||||||
# config = Config(descr, **overrides)
|
|
||||||
# if translating:
|
|
||||||
# config.translating = True
|
|
||||||
# if existing_config is not None:
|
|
||||||
# for child in existing_config._cfgimpl_descr._children:
|
|
||||||
# if child._name == newname:
|
|
||||||
# continue
|
|
||||||
# value = getattr(existing_config, child._name)
|
|
||||||
# config._cfgimpl_values[child._name] = value
|
|
||||||
# return config
|
|
||||||
|
|
||||||
#def get_example_config(overrides=None, translating=False):
|
|
||||||
# return get_combined_translation_config(
|
|
||||||
# example__optiondescription, overrides=overrides,
|
|
||||||
# translating=translating)
|
|
||||||
|
|
||||||
## ____________________________________________________________
|
|
||||||
|
|
||||||
#def test_example_option():
|
|
||||||
# config = get_example_config()
|
|
||||||
# result = ['objspace.name', 'objspace.opcodes.CALL_LIKELY_BUILTIN',
|
|
||||||
# 'objspace.opcodes.CALL_METHOD', 'objspace.nofaking',
|
|
||||||
# 'objspace.usemodules.amon', 'objspace.usemodules.sphynx',
|
|
||||||
# 'objspace.usemodules.zephir', 'objspace.allworkingmodules',
|
|
||||||
# 'objspace.translationmodules', 'objspace.geninterp',
|
|
||||||
# 'objspace.logbytecodes', 'objspace.usepycfiles', 'objspace.lonepycfiles',
|
|
||||||
# 'objspace.soabi', 'objspace.honor__builtins__',
|
|
||||||
# 'objspace.disable_call_speedhacks', 'objspace.timing',
|
|
||||||
# 'objspace.std.withtproxy', 'objspace.std.withsmallint',
|
|
||||||
# 'objspace.std.withprebuiltint', 'objspace.std.prebuiltintfrom',
|
|
||||||
# 'objspace.std.prebuiltintto', 'objspace.std.withstrjoin',
|
|
||||||
# 'objspace.std.withstrslice', 'objspace.std.withstrbuf',
|
|
||||||
# 'objspace.std.withprebuiltchar', 'objspace.std.sharesmallstr',
|
|
||||||
# 'objspace.std.withrope', 'objspace.std.withropeunicode',
|
|
||||||
# 'objspace.std.withcelldict', 'objspace.std.withdictmeasurement',
|
|
||||||
# 'objspace.std.withmapdict', 'objspace.std.withrangelist',
|
|
||||||
# 'objspace.std.withtypeversion', 'objspace.std.withmethodcache',
|
|
||||||
# 'objspace.std.withmethodcachecounter', 'objspace.std.methodcachesizeexp',
|
|
||||||
# 'objspace.std.optimized_int_add', 'objspace.std.optimized_comparison_op',
|
|
||||||
# 'objspace.std.optimized_list_getitem', 'objspace.std.builtinshortcut',
|
|
||||||
# 'objspace.std.getattributeshortcut', 'objspace.std.newshortcut',
|
|
||||||
# 'objspace.std.logspaceoptypes', 'objspace.std.multimethods',
|
|
||||||
# 'objspace.std.immutable_builtintypes']
|
|
||||||
|
|
||||||
# assert config.getpaths(allpaths=True) == result
|
|
|
@ -1,4 +1,6 @@
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
from tiramisu.option import IPOption, NetworkOption, NetmaskOption, \
|
from tiramisu.option import IPOption, NetworkOption, NetmaskOption, \
|
||||||
|
@ -27,6 +29,7 @@ def test_ip():
|
||||||
c = Config(od)
|
c = Config(od)
|
||||||
raises(ValueError, "c.a = '192.000.023.01'")
|
raises(ValueError, "c.a = '192.000.023.01'")
|
||||||
|
|
||||||
|
|
||||||
def test_ip_default():
|
def test_ip_default():
|
||||||
a = IPOption('a', '', '88.88.88.88')
|
a = IPOption('a', '', '88.88.88.88')
|
||||||
od = OptionDescription('od', '', [a])
|
od = OptionDescription('od', '', [a])
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
#from py.test import raises
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.config import Config, GroupConfig, MetaConfig
|
from tiramisu.config import Config, GroupConfig, MetaConfig
|
||||||
from tiramisu.option import BoolOption, IntOption, StrOption, OptionDescription, submulti
|
from tiramisu.option import BoolOption, IntOption, StrOption, OptionDescription, submulti
|
||||||
|
@ -9,6 +9,7 @@ import weakref
|
||||||
|
|
||||||
IS_DEREFABLE = True
|
IS_DEREFABLE = True
|
||||||
|
|
||||||
|
|
||||||
def test_deref_storage():
|
def test_deref_storage():
|
||||||
b = BoolOption('b', '')
|
b = BoolOption('b', '')
|
||||||
o = OptionDescription('od', '', [b])
|
o = OptionDescription('od', '', [b])
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import groups, owners
|
from tiramisu.setting import groups, owners
|
||||||
from tiramisu.option import BoolOption, StrOption, ChoiceOption, IPOption, \
|
from tiramisu.option import BoolOption, StrOption, ChoiceOption, IPOption, \
|
||||||
|
@ -85,6 +86,7 @@ def test_unknown_dyndescription():
|
||||||
od = OptionDescription('od', '', [dod])
|
od = OptionDescription('od', '', [dod])
|
||||||
od2 = OptionDescription('od', '', [od])
|
od2 = OptionDescription('od', '', [od])
|
||||||
cfg = Config(od2)
|
cfg = Config(od2)
|
||||||
|
cfg
|
||||||
raises(AttributeError, "cfg.od.dodval3")
|
raises(AttributeError, "cfg.od.dodval3")
|
||||||
raises(AttributeError, "cfg.od.dodval1.novalue")
|
raises(AttributeError, "cfg.od.dodval1.novalue")
|
||||||
|
|
||||||
|
@ -711,6 +713,7 @@ def test_consistency_external_dyndescription():
|
||||||
st2 = StrOption('st2', '')
|
st2 = StrOption('st2', '')
|
||||||
dod = DynOptionDescription('dod', '', [st1, st2], callback=return_list)
|
dod = DynOptionDescription('dod', '', [st1, st2], callback=return_list)
|
||||||
od = OptionDescription('od', '', [dod, st])
|
od = OptionDescription('od', '', [dod, st])
|
||||||
|
od
|
||||||
raises(ConfigError, "st.impl_add_consistency('not_equal', st2)")
|
raises(ConfigError, "st.impl_add_consistency('not_equal', st2)")
|
||||||
|
|
||||||
|
|
||||||
|
@ -722,6 +725,7 @@ def test_consistency_notsame_dyndescription():
|
||||||
tst2 = StrOption('tst2', '')
|
tst2 = StrOption('tst2', '')
|
||||||
tdod = DynOptionDescription('tdod', '', [tst1, tst2], callback=return_list)
|
tdod = DynOptionDescription('tdod', '', [tst1, tst2], callback=return_list)
|
||||||
od = OptionDescription('od', '', [dod, tdod])
|
od = OptionDescription('od', '', [dod, tdod])
|
||||||
|
od
|
||||||
raises(ConfigError, "st1.impl_add_consistency('not_equal', tst1)")
|
raises(ConfigError, "st1.impl_add_consistency('not_equal', tst1)")
|
||||||
|
|
||||||
|
|
||||||
|
@ -1279,30 +1283,35 @@ def test_invalid_conflict_dyndescription():
|
||||||
st = StrOption('st', '')
|
st = StrOption('st', '')
|
||||||
dod = DynOptionDescription('dod', '', [st], callback=return_list)
|
dod = DynOptionDescription('dod', '', [st], callback=return_list)
|
||||||
dodinvalid = StrOption('dodinvalid', '')
|
dodinvalid = StrOption('dodinvalid', '')
|
||||||
|
dod, dodinvalid
|
||||||
raises(ConflictError, "OptionDescription('od', '', [dod, dodinvalid])")
|
raises(ConflictError, "OptionDescription('od', '', [dod, dodinvalid])")
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_subod_dyndescription():
|
def test_invalid_subod_dyndescription():
|
||||||
st2 = StrOption('st2', '')
|
st2 = StrOption('st2', '')
|
||||||
od1 = OptionDescription('od1', '', [st2])
|
od1 = OptionDescription('od1', '', [st2])
|
||||||
|
od1
|
||||||
raises(ConfigError, "DynOptionDescription('dod', '', [od1], callback=return_list)")
|
raises(ConfigError, "DynOptionDescription('dod', '', [od1], callback=return_list)")
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_subdynod_dyndescription():
|
def test_invalid_subdynod_dyndescription():
|
||||||
st2 = StrOption('st2', '')
|
st2 = StrOption('st2', '')
|
||||||
od1 = DynOptionDescription('od1', '', [st2], callback=return_list)
|
od1 = DynOptionDescription('od1', '', [st2], callback=return_list)
|
||||||
|
od1
|
||||||
raises(ConfigError, "DynOptionDescription('dod', '', [od1], callback=return_list)")
|
raises(ConfigError, "DynOptionDescription('dod', '', [od1], callback=return_list)")
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_symlink_dyndescription():
|
def test_invalid_symlink_dyndescription():
|
||||||
st = StrOption('st', '')
|
st = StrOption('st', '')
|
||||||
st2 = SymLinkOption('st2', st)
|
st2 = SymLinkOption('st2', st)
|
||||||
|
st2
|
||||||
raises(ConfigError, "DynOptionDescription('dod', '', [st, st2], callback=return_list)")
|
raises(ConfigError, "DynOptionDescription('dod', '', [st, st2], callback=return_list)")
|
||||||
|
|
||||||
|
|
||||||
def test_nocallback_dyndescription():
|
def test_nocallback_dyndescription():
|
||||||
st = StrOption('st', '')
|
st = StrOption('st', '')
|
||||||
st2 = StrOption('st2', '')
|
st2 = StrOption('st2', '')
|
||||||
|
st, st2
|
||||||
raises(ConfigError, "DynOptionDescription('dod', '', [st, st2])")
|
raises(ConfigError, "DynOptionDescription('dod', '', [st, st2])")
|
||||||
|
|
||||||
|
|
||||||
|
@ -1311,6 +1320,7 @@ def test_invalid_samevalue_dyndescription():
|
||||||
dod = DynOptionDescription('dod', '', [st], callback=return_same_list)
|
dod = DynOptionDescription('dod', '', [st], callback=return_same_list)
|
||||||
od = OptionDescription('od', '', [dod])
|
od = OptionDescription('od', '', [dod])
|
||||||
cfg = Config(od)
|
cfg = Config(od)
|
||||||
|
cfg
|
||||||
raises(ConfigError, "print cfg")
|
raises(ConfigError, "print cfg")
|
||||||
|
|
||||||
|
|
||||||
|
@ -1319,4 +1329,5 @@ def test_invalid_name_dyndescription():
|
||||||
dod = DynOptionDescription('dod', '', [st], callback=return_wrong_list)
|
dod = DynOptionDescription('dod', '', [st], callback=return_wrong_list)
|
||||||
od = OptionDescription('od', '', [dod])
|
od = OptionDescription('od', '', [dod])
|
||||||
cfg = Config(od)
|
cfg = Config(od)
|
||||||
|
cfg
|
||||||
raises(ValueError, "print cfg")
|
raises(ValueError, "print cfg")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
"frozen and hidden values"
|
"frozen and hidden values"
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import owners
|
from tiramisu.setting import owners
|
||||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
#from py.test import raises
|
#from py.test import raises
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
|
@ -177,6 +178,7 @@ def test_not_meta():
|
||||||
conf2 = Config(od2, name='conf2')
|
conf2 = Config(od2, name='conf2')
|
||||||
conf3 = Config(od2)
|
conf3 = Config(od2)
|
||||||
conf4 = Config(od2, name='conf2')
|
conf4 = Config(od2, name='conf2')
|
||||||
|
conf3, conf4
|
||||||
raises(ValueError, "GroupConfig(conf1)")
|
raises(ValueError, "GroupConfig(conf1)")
|
||||||
#same name
|
#same name
|
||||||
raises(ConflictError, "GroupConfig([conf2, conf4])")
|
raises(ConflictError, "GroupConfig([conf2, conf4])")
|
||||||
|
@ -215,6 +217,7 @@ def test_meta_unconsistent():
|
||||||
conf2 = Config(od2, name='conf2')
|
conf2 = Config(od2, name='conf2')
|
||||||
conf3 = Config(od2, name='conf3')
|
conf3 = Config(od2, name='conf3')
|
||||||
conf4 = Config(od1, name='conf4')
|
conf4 = Config(od1, name='conf4')
|
||||||
|
conf3, conf4
|
||||||
meta = MetaConfig([conf1, conf2])
|
meta = MetaConfig([conf1, conf2])
|
||||||
meta.cfgimpl_get_settings().setowner(owners.meta)
|
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||||
raises(TypeError, 'MetaConfig("string")')
|
raises(TypeError, 'MetaConfig("string")')
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.value import Multi
|
from tiramisu.value import Multi
|
||||||
from tiramisu.option import IntOption, OptionDescription
|
from tiramisu.option import IntOption, OptionDescription
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
|
@ -13,7 +15,7 @@ def test_multi():
|
||||||
i = IntOption('int', '', multi=True)
|
i = IntOption('int', '', multi=True)
|
||||||
o = OptionDescription('od', '', [i])
|
o = OptionDescription('od', '', [i])
|
||||||
c = Config(o)
|
c = Config(o)
|
||||||
multi = Multi([1,2,3], weakref.ref(c), i, 'int')
|
multi = Multi([1, 2, 3], weakref.ref(c), i, 'int')
|
||||||
raises(ValueError, "Multi([1,2,3], c, i, 'int')")
|
raises(ValueError, "Multi([1,2,3], c, i, 'int')")
|
||||||
raises(ValueError, "Multi(multi, weakref.ref(c), i, 'int')")
|
raises(ValueError, "Multi(multi, weakref.ref(c), i, 'int')")
|
||||||
assert c is multi._getcontext()
|
assert c is multi._getcontext()
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
"""these tests are here to create some :class:`tiramisu.option.Option`'s
|
"""these tests are here to create some :class:`tiramisu.option.Option`'s
|
||||||
and to compare them
|
and to compare them
|
||||||
"""
|
"""
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.option import IntOption, OptionDescription
|
from tiramisu.option import IntOption, OptionDescription
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.setting import owners, groups
|
from tiramisu.setting import owners, groups
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
"test all types of option default values for options, add new option in a descr"
|
"test all types of option default values for options, add new option in a descr"
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.setting import owners
|
from tiramisu.setting import owners
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
"config.set() or config.setoption() or option.setoption()"
|
"config.set() or config.setoption() or option.setoption()"
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.setting import owners
|
from tiramisu.setting import owners
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
"frozen and hidden values"
|
"frozen and hidden values"
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
"configuration objects global API"
|
"configuration objects global API"
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#this test is much more to test that **it's there** and answers attribute access
|
#this test is much more to test that **it's there** and answers attribute access
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import groups, owners
|
from tiramisu.setting import groups, owners
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, \
|
from tiramisu.option import ChoiceOption, BoolOption, IntOption, \
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.option import IntOption, OptionDescription
|
from tiramisu.option import IntOption, OptionDescription
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from tiramisu import setting
|
from tiramisu import setting
|
||||||
setting.expires_time = 1
|
setting.expires_time = 1
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
#import autopath
|
|
||||||
#from py.test import raises
|
|
||||||
|
|
||||||
#from tool import reverse_from_paths
|
|
||||||
|
|
||||||
#def make_description():
|
|
||||||
# gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
|
||||||
# gcdummy = BoolOption('dummy', 'dummy', default=False)
|
|
||||||
# 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)
|
|
||||||
#
|
|
||||||
# gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
|
||||||
# descr = OptionDescription('tiram', '', [gcgroup, booloption, objspaceoption,
|
|
||||||
# wantref_option, stroption,
|
|
||||||
# wantframework_option,
|
|
||||||
# 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]
|
|
||||||
|
|
||||||
# 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']
|
|
|
@ -1,5 +1,7 @@
|
||||||
## coding: utf-8
|
## coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from tiramisu.config import Config, SubConfig
|
from tiramisu.config import Config, SubConfig
|
||||||
|
@ -110,6 +112,7 @@ def test_slots_option_readonly_name():
|
||||||
p = DomainnameOption('p', '')
|
p = DomainnameOption('p', '')
|
||||||
q = DomainnameOption('q', '')
|
q = DomainnameOption('q', '')
|
||||||
m = OptionDescription('m', '', [a, b, c, d, e, f, g, h, i, j, k, l, o, p, q])
|
m = OptionDescription('m', '', [a, b, c, d, e, f, g, h, i, j, k, l, o, p, q])
|
||||||
|
m
|
||||||
raises(AttributeError, "a._name = 'a'")
|
raises(AttributeError, "a._name = 'a'")
|
||||||
raises(AttributeError, "b._name = 'b'")
|
raises(AttributeError, "b._name = 'b'")
|
||||||
raises(AttributeError, "c._name = 'c'")
|
raises(AttributeError, "c._name = 'c'")
|
||||||
|
@ -154,6 +157,7 @@ def test_slots_setting():
|
||||||
od2 = OptionDescription('a', '', [od1])
|
od2 = OptionDescription('a', '', [od1])
|
||||||
c = Config(od2)
|
c = Config(od2)
|
||||||
s = c.cfgimpl_get_settings()
|
s = c.cfgimpl_get_settings()
|
||||||
|
s
|
||||||
raises(AttributeError, "s.x = 1")
|
raises(AttributeError, "s.x = 1")
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,4 +166,5 @@ def test_slots_value():
|
||||||
od2 = OptionDescription('a', '', [od1])
|
od2 = OptionDescription('a', '', [od1])
|
||||||
c = Config(od2)
|
c = Config(od2)
|
||||||
v = c.cfgimpl_get_values()
|
v = c.cfgimpl_get_values()
|
||||||
|
v
|
||||||
raises(AttributeError, "v.x = 1")
|
raises(AttributeError, "v.x = 1")
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.option import BoolOption, UnicodeOption, SymLinkOption, \
|
from tiramisu.option import BoolOption, UnicodeOption, SymLinkOption, \
|
||||||
IntOption, IPOption, NetmaskOption, StrOption, OptionDescription, \
|
IntOption, IPOption, NetmaskOption, StrOption, OptionDescription, \
|
||||||
|
@ -53,7 +54,7 @@ def _diff_opt(opt1, opt2):
|
||||||
try:
|
try:
|
||||||
val1 = getattr(opt1, attr)
|
val1 = getattr(opt1, attr)
|
||||||
msg1 = "exists"
|
msg1 = "exists"
|
||||||
except Exception, err:
|
except:
|
||||||
err1 = True
|
err1 = True
|
||||||
msg1 = "not exists"
|
msg1 = "not exists"
|
||||||
|
|
||||||
|
@ -189,6 +190,7 @@ def test_diff_opt():
|
||||||
|
|
||||||
def test_only_optiondescription():
|
def test_only_optiondescription():
|
||||||
b = BoolOption('b', '')
|
b = BoolOption('b', '')
|
||||||
|
b
|
||||||
raises(SystemError, "a = dumps(b)")
|
raises(SystemError, "a = dumps(b)")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
#from py.test import raises
|
#from py.test import raises
|
||||||
|
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.setting import groups, owners
|
from tiramisu.setting import groups, owners
|
||||||
from tiramisu.config import Config
|
from tiramisu.config import Config
|
||||||
from tiramisu.option import StrOption, OptionDescription, submulti
|
from tiramisu.option import StrOption, OptionDescription, submulti
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import autopath
|
from autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
from tiramisu.option import BoolOption, StrOption, SymLinkOption, \
|
from tiramisu.option import BoolOption, StrOption, SymLinkOption, \
|
||||||
OptionDescription
|
OptionDescription
|
||||||
|
@ -109,6 +110,7 @@ def test_symlink_master():
|
||||||
ip_admin_eth0 = SymLinkOption('ip_admin_eth0', a)
|
ip_admin_eth0 = SymLinkOption('ip_admin_eth0', a)
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "", multi=True)
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "", multi=True)
|
||||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
interface1
|
||||||
raises(ValueError, 'interface1.impl_set_group_type(groups.master)')
|
raises(ValueError, 'interface1.impl_set_group_type(groups.master)')
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,4 +119,5 @@ def test_symlink_slaves():
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||||
netmask_admin_eth0 = SymLinkOption('netmask_admin_eth0', a)
|
netmask_admin_eth0 = SymLinkOption('netmask_admin_eth0', a)
|
||||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
interface1
|
||||||
raises(ValueError, 'interface1.impl_set_group_type(groups.master)')
|
raises(ValueError, 'interface1.impl_set_group_type(groups.master)')
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
"options handler global entry point"
|
"options handler global entry point"
|
||||||
import weakref
|
import weakref
|
||||||
from copy import copy
|
|
||||||
|
|
||||||
|
|
||||||
from tiramisu.error import PropertiesOptionError, ConfigError, ConflictError
|
from tiramisu.error import PropertiesOptionError, ConfigError, ConflictError
|
||||||
|
@ -603,9 +602,16 @@ class _CommonConfig(SubConfig):
|
||||||
fake_config = Config(self._impl_descr, persistent=False,
|
fake_config = Config(self._impl_descr, persistent=False,
|
||||||
force_storages=get_storages_validation(),
|
force_storages=get_storages_validation(),
|
||||||
force_settings=self.cfgimpl_get_settings())
|
force_settings=self.cfgimpl_get_settings())
|
||||||
fake_config.cfgimpl_get_values()._p_._values = copy(self.cfgimpl_get_values()._p_.get_modified_values())
|
fake_config.cfgimpl_get_values()._p_._values = self.cfgimpl_get_values()._p_.get_modified_values()
|
||||||
return fake_config
|
return fake_config
|
||||||
|
|
||||||
|
def duplicate(self):
|
||||||
|
config = Config(self._impl_descr)
|
||||||
|
config.cfgimpl_get_values()._p_._values = self.cfgimpl_get_values()._p_.get_modified_values()
|
||||||
|
config.cfgimpl_get_settings()._p_._properties = self.cfgimpl_get_settings()._p_.get_modified_properties()
|
||||||
|
config.cfgimpl_get_settings()._p_._permissives = self.cfgimpl_get_settings()._p_.get_modified_permissives()
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
class Config(_CommonConfig):
|
class Config(_CommonConfig):
|
||||||
|
|
|
@ -302,6 +302,10 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||||
def __getattr__(self, name, context=undefined):
|
def __getattr__(self, name, context=undefined):
|
||||||
if name.startswith('_'): # or name.startswith('impl_'):
|
if name.startswith('_'): # or name.startswith('impl_'):
|
||||||
return object.__getattribute__(self, name)
|
return object.__getattribute__(self, name)
|
||||||
|
if '.' in name:
|
||||||
|
path = name.split('.')[0]
|
||||||
|
subpath = '.'.join(name.split('.')[1:])
|
||||||
|
return self.__getattr__(path, context=context).__getattr__(subpath, context=context)
|
||||||
return self._getattr(name, context=context)
|
return self._getattr(name, context=context)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
|
from copy import copy
|
||||||
from ..util import Cache
|
from ..util import Cache
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,10 +59,10 @@ class Settings(Cache):
|
||||||
"""return all modified settings in a dictionary
|
"""return all modified settings in a dictionary
|
||||||
example: {'path1': set(['prop1', 'prop2'])}
|
example: {'path1': set(['prop1', 'prop2'])}
|
||||||
"""
|
"""
|
||||||
return self._properties
|
return copy(self._properties)
|
||||||
|
|
||||||
def get_modified_permissives(self):
|
def get_modified_permissives(self):
|
||||||
"""return all modified permissives in a dictionary
|
"""return all modified permissives in a dictionary
|
||||||
example: {'path1': set(['perm1', 'perm2'])}
|
example: {'path1': set(['perm1', 'perm2'])}
|
||||||
"""
|
"""
|
||||||
return self._permissives
|
return copy(self._permissives)
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
|
from copy import copy
|
||||||
from ..util import Cache
|
from ..util import Cache
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class Values(Cache):
|
||||||
"""return all values in a dictionary
|
"""return all values in a dictionary
|
||||||
example: {'path1': (owner, 'value1'), 'path2': (owner, 'value2')}
|
example: {'path1': (owner, 'value1'), 'path2': (owner, 'value2')}
|
||||||
"""
|
"""
|
||||||
return self._values
|
return copy(self._values)
|
||||||
|
|
||||||
# owner
|
# owner
|
||||||
def setowner(self, path, owner):
|
def setowner(self, path, owner):
|
||||||
|
|
Loading…
Reference in New Issue