From c3aed479f08153ab791cf9eeea1eb85385fcc2b6 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 28 May 2020 14:16:47 -0400 Subject: [PATCH] _SchemaValidator.validate(): use "element" prefix for array elements Otherwise the context's object name would be: `2` property instead of Element 2 for example. Signed-off-by: Philippe Proulx --- barectf/config_parse.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/barectf/config_parse.py b/barectf/config_parse.py index 4c91533..dc1ae95 100644 --- a/barectf/config_parse.py +++ b/barectf/config_parse.py @@ -407,7 +407,15 @@ class _SchemaValidator: except jsonschema.ValidationError as exc: # convert to barectf `ConfigParseError` exception contexts = ['Configuration object'] - contexts += ['`{}` property'.format(p) for p in exc.absolute_path] + + for elem in exc.absolute_path: + if type(elem) is int: + ctx = 'Element {}'.format(elem) + else: + ctx = '`{}` property'.format(elem) + + contexts.append(ctx) + schema_ctx = '' if len(exc.context) > 0: -- 2.34.1