better error messages if option doesn't exists
This commit is contained in:
parent
cfb4eb3b3c
commit
0dc298dedc
14
tests/test_simple.py
Normal file
14
tests/test_simple.py
Normal 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()")
|
@ -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(_(f'option "{subpath}" inconnue dans l\'optiondescription "{current_subpath}"'))
|
||||
current_subpath = subpath
|
||||
return schema
|
||||
|
||||
def isleader(self,
|
||||
|
Loading…
Reference in New Issue
Block a user