commented code for unicity by name
This commit is contained in:
parent
dc99bbc44e
commit
d8370b008b
@ -42,22 +42,32 @@ def make_description_duplicates():
|
||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||
default=False,
|
||||
requires=['boolop'])
|
||||
# dummy2 (same name)
|
||||
# dummy2 (same path)
|
||||
gcdummy2 = BoolOption('dummy', 'dummy2', default=True)
|
||||
# dummy3 (same name)
|
||||
gcdummy3 = BoolOption('dummy', 'dummy2', default=True)
|
||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, gcdummy2, floatoption])
|
||||
descr = OptionDescription('constraints', '', [gcgroup, booloption, objspaceoption,
|
||||
wantref_option, stroption,
|
||||
wantframework_option,
|
||||
intoption, boolop])
|
||||
intoption, boolop, gcdummy3])
|
||||
return descr
|
||||
|
||||
def test_identical_names():
|
||||
def test_identical_paths():
|
||||
"""If in the schema (the option description) there is something that
|
||||
have the same name, an exection is raised
|
||||
"""
|
||||
descr = make_description_duplicates()
|
||||
raises(ConflictConfigError, "cfg = Config(descr)")
|
||||
|
||||
#def test_identical_for_names():
|
||||
# """if there is something that
|
||||
# have the same name, an exection is raised
|
||||
# """
|
||||
# descr = make_description_duplicates()
|
||||
# raises(ConflictConfigError, "cfg = Config(descr)")
|
||||
|
||||
|
||||
def make_description2():
|
||||
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||
@ -202,4 +212,3 @@ def test_disabled_with_group():
|
||||
raises(PropertiesOptionError, "cfg.gc.name")
|
||||
assert gcgroup._is_disabled()
|
||||
|
||||
|
||||
|
@ -37,6 +37,8 @@ class Config(object):
|
||||
_cfgimpl_frozen = False
|
||||
_cfgimpl_owner = default_owner
|
||||
_cfgimpl_toplevel = None
|
||||
# TODO implement unicity by name
|
||||
# _cfgimpl_unique_names = True
|
||||
|
||||
def __init__(self, descr, parent=None, **overrides):
|
||||
self._cfgimpl_descr = descr
|
||||
@ -61,6 +63,26 @@ class Config(object):
|
||||
raise ConflictConfigError('duplicate option name: '
|
||||
'{0}'.format(dup._name))
|
||||
|
||||
# TODO implement unicity by name
|
||||
# def _validate_duplicates_for_names(self, children):
|
||||
# "validates duplicates names agains the whole config"
|
||||
# rootconfig = self._cfgimpl_get_toplevel()
|
||||
# if self._cfgimpl_unique_names:
|
||||
# for dup in children:
|
||||
# try:
|
||||
# print dup._name
|
||||
# try:
|
||||
# print rootconfig.get(dup._name)
|
||||
# except AttributeError:
|
||||
# pass
|
||||
# raise NotFoundError
|
||||
# #rootconfig.get(dup._name)
|
||||
# except NotFoundError:
|
||||
# pass # no identical names, it's fine
|
||||
# else:
|
||||
# raise ConflictConfigError('duplicate option name: '
|
||||
# '{0}'.format(dup._name))
|
||||
|
||||
def _cfgimpl_build(self, overrides):
|
||||
self._validate_duplicates(self._cfgimpl_descr._children)
|
||||
for child in self._cfgimpl_descr._children:
|
||||
|
Loading…
Reference in New Issue
Block a user