From 653099410205e6b1fff3889e8c6adbab1ea80554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20B=C3=A4ckmark?= Date: Thu, 11 Jan 2024 09:13:40 +0100 Subject: [PATCH] Break out schema check --- test_jsonschema.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test_jsonschema.py b/test_jsonschema.py index d8ff5791..02d885d2 100644 --- a/test_jsonschema.py +++ b/test_jsonschema.py @@ -21,7 +21,7 @@ import pytest # Set up a console logger -logger = logging.getLogger("__Logger__") +logger = logging.getLogger("__name__") console_handler = logging.StreamHandler() formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s", @@ -39,19 +39,22 @@ ) def test_json_schema(filename): with open(filename) as input_file: - event_schema = json.loads(input_file.read()) + event_schema = json.load(input_file) - # Use standard validator for old ActC schemas, to cope with bug https://github.com/eiffel-community/eiffel/issues/376 + # Evaluate which schema validator to use. Use standard validator for old ActC + # schemas, to cope with bug https://github.com/eiffel-community/eiffel/issues/376 + schema_validator = None if ("ActivityCanceled" in filename) and ( event_schema["properties"]["meta"]["properties"]["version"]["default"] in ["1.0.0", "1.1.0", "2.0.0", "3.0.0", "3.1.0", "3.2.0"] ): - jsonschema.Draft4Validator.check_schema(event_schema) + schema_validator = jsonschema.Draft4Validator else: stricter_metaschema = dict( jsonschema.Draft4Validator.META_SCHEMA, additionalProperties=False ) - StrictDraft4Validator = jsonschema.validators.create( + schema_validator = jsonschema.validators.create( stricter_metaschema, jsonschema.Draft4Validator.VALIDATORS, "StrictDraft4" ) - StrictDraft4Validator.check_schema(event_schema) + + schema_validator.check_schema(event_schema)