3 Commits

5 changed files with 23 additions and 5 deletions

14
tests/test_simple.py Normal file
View File

@ -0,0 +1,14 @@
from json import loads
from tiramisu_api import Config
from pytest import raises
def test_list_option():
filename = 'tests/data/boolean1.json'
with open(filename, 'r') as fh:
json = loads(fh.read())
#
config = Config(json)
opts = []
raises(AttributeError, "config.option('unknown').value.get()")
raises(AttributeError, "config.option('options.unknown').value.get()")

View File

@ -811,12 +811,16 @@ class Config:
subpaths = path.split('.')[len(root):]
else:
subpaths = path.split('.')
current_subpath = 'root'
for subpath in subpaths:
if root_path:
root_path += '.' + subpath
else:
root_path = subpath
schema = schema['properties'][root_path]
schema = schema['properties'].get(root_path)
if schema is None:
raise AttributeError(_('option "{0}" inconnue dans l\'optiondescription "{1}"').format(subpath, current_subpath))
current_subpath = subpath
return schema
def isleader(self,

View File

@ -1,6 +1,6 @@
try:
from tiramisu.error import APIError, ValueWarning, ValueOptionError, ValueErrorWarning, PropertiesOptionError, ConfigError, display_list
except ModuleNotFoundError:
except ImportError:
import weakref
from .i18n import _
@ -130,7 +130,7 @@ except ModuleNotFoundError:
if self.msg:
return self.msg
if self._option_bag is None:
return "unknown error"
return "option désactivée"
req = self._settings.apply_requires(self._option_bag,
True)
# if req != {} or self._orig_opt is not None:

View File

@ -1,6 +1,6 @@
try:
from tiramisu.i18n import _
except ModuleNotFoundError:
except ImportError:
# FIXME
def _(val):
return val

View File

@ -1,6 +1,6 @@
try:
from tiramisu.setting import undefined
except ModuleNotFoundError:
except ImportError:
class Undefined(object):
def __str__(self):
return 'Undefined'