From f7fc421283450934f34a57448c7f4add0b6e4f4b Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Wed, 8 Jan 2025 18:23:40 +0100 Subject: [PATCH] fix --- lib/spack/spack/schema/__init__.py | 1 + lib/spack/spack/test/schema.py | 21 +++++++++------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/spack/spack/schema/__init__.py b/lib/spack/spack/schema/__init__.py index f8f050a4143..0215e58bebb 100644 --- a/lib/spack/spack/schema/__init__.py +++ b/lib/spack/spack/schema/__init__.py @@ -7,6 +7,7 @@ import jsonschema import jsonschema.exceptions +import jsonschema.validators import llnl.util.lang diff --git a/lib/spack/spack/test/schema.py b/lib/spack/spack/test/schema.py index 010afde80c8..06a6e7e36ab 100644 --- a/lib/spack/spack/test/schema.py +++ b/lib/spack/spack/test/schema.py @@ -105,25 +105,22 @@ def test_schema_validation(meta_schema, config_name): def test_deprecated_properties(module_suffixes_schema): # Test that an error is reported when 'error: True' - msg_fmt = r"{name} is deprecated" module_suffixes_schema["deprecatedProperties"] = [ - {"names": ["tcl"], "message": msg_fmt, "error": True} + {"names": ["tcl"], "message": r"{name} is deprecated", "error": True} ] - v = spack.schema.Validator(module_suffixes_schema) data = {"tcl": {"all": {"suffixes": {"^python": "py"}}}} - expected_match = "tcl is deprecated" - with pytest.raises(jsonschema.ValidationError, match=expected_match): - v.validate(data) + with pytest.raises(jsonschema.ValidationError, match="tcl is deprecated") as e: + assert not isinstance(e, spack.schema.NonFatalValidationError) + spack.schema.Validator(module_suffixes_schema).validate(data) - # Test that just a warning is reported when 'error: False' + # Test that just a non fatal error is reported when 'error: False' module_suffixes_schema["deprecatedProperties"] = [ - {"names": ["tcl"], "message": msg_fmt, "error": False} + {"names": ["tcl"], "message": r"{name} is deprecated", "error": False} ] - v = spack.schema.Validator(module_suffixes_schema) - data = {"tcl": {"all": {"suffixes": {"^python": "py"}}}} - # The next validation doesn't raise anymore - v.validate(data) + + with pytest.raises(spack.schema.NonFatalValidationError, match="tcl is deprecated"): + spack.schema.Validator(module_suffixes_schema).validate(data) def test_ordereddict_merge_order():