diff --git a/hed/errors/exceptions.py b/hed/errors/exceptions.py index 36164b60..45302f89 100644 --- a/hed/errors/exceptions.py +++ b/hed/errors/exceptions.py @@ -23,7 +23,7 @@ class HedExceptions: SCHEMA_LIBRARY_INVALID = "SCHEMA_LIBRARY_INVALID" BAD_HED_LIBRARY_NAME = 'SCHEMA_LIBRARY_INVALID' BAD_WITH_STANDARD = "SCHEMA_LIBRARY_INVALID" - BAD_WITH_STANDARD_VERSION = "SCHEMA_LIBRARY_INVALID" + BAD_WITH_STANDARD_MULTIPLE_VALUES = "SCHEMA_LOAD_FAILED" ROOTED_TAG_INVALID = "SCHEMA_LIBRARY_INVALID" ROOTED_TAG_HAS_PARENT = "SCHEMA_LIBRARY_INVALID" ROOTED_TAG_DOES_NOT_EXIST = "SCHEMA_LIBRARY_INVALID" @@ -40,13 +40,14 @@ class HedExceptions: WIKI_LINE_START_INVALID = 'WIKI_LINE_START_INVALID' HED_SCHEMA_NODE_NAME_INVALID = 'HED_SCHEMA_NODE_NAME_INVALID' - SCHEMA_DUPLICATE_PREFIX = 'schemaDuplicatePrefix' + SCHEMA_DUPLICATE_PREFIX = 'SCHEMA_LOAD_FAILED' SCHEMA_DUPLICATE_LIBRARY = "SCHEMA_LIBRARY_INVALID" BAD_COLUMN_NAMES = 'BAD_COLUMN_NAMES' SCHEMA_DUPLICATE_NAMES = "SCHEMA_DUPLICATE_NAMES" CANNOT_PARSE_RDF = "CANNOT_PARSE_RDF" + SCHEMA_LOAD_FAILED = "SCHEMA_LOAD_FAILED" class HedFileError(Exception): diff --git a/spec_tests/hed-specification b/spec_tests/hed-specification index 9044516b..2976edd4 160000 --- a/spec_tests/hed-specification +++ b/spec_tests/hed-specification @@ -1 +1 @@ -Subproject commit 9044516b2709523fdcca754105f2ed67e400651f +Subproject commit 2976edd4e4c1e93044e737b9b7af692c15c78e5f diff --git a/spec_tests/test_errors.py b/spec_tests/test_errors.py index 9ee913b7..6d503bdf 100644 --- a/spec_tests/test_errors.py +++ b/spec_tests/test_errors.py @@ -11,7 +11,7 @@ import io import json from hed import HedFileError -from hed.errors import ErrorHandler, get_printable_issue_string +from hed.errors import ErrorHandler, get_printable_issue_string, SchemaWarnings skip_tests = { @@ -46,7 +46,7 @@ def run_single_test(self, test_file): print(f"Skipping {name} test because: {skip_tests[name]}") continue - # if name != "sidecar-braces-invalid-spot": + # if name != "library-invalid-bad_with-standard-version": # continue description = info['description'] schema = info['schema'] @@ -56,8 +56,12 @@ def run_single_test(self, test_file): try: schema = load_schema_version(schema) except HedFileError as e: - print(f"Failed to load schema version {schema} for test, failing test {name}") - self.fail_count.append(name) + issues = e.issues + if not issues: + issues += [{"code": e.code, + "message": e.message}] + self.report_result("fails", issues, error_code, description, name, "dummy", "Schema") + # self.fail_count.append(name) continue definitions = info.get('definitions', None) def_dict = DefinitionDict(definitions, schema) @@ -77,6 +81,8 @@ def run_single_test(self, test_file): self._run_single_schema_test(section, error_code, description, name, error_handler) def report_result(self, expected_result, issues, error_code, description, name, test, test_type): + # Filter out pre-release warnings, we don't care about them. + issues = [issue for issue in issues if issue["code"] != SchemaWarnings.SCHEMA_PRERELEASE_VERSION_USED] if expected_result == "fails": if not issues: print(f"{error_code}: {description}") diff --git a/tests/schema/test_hed_cache.py b/tests/schema/test_hed_cache.py index 0639009f..f9910d15 100644 --- a/tests/schema/test_hed_cache.py +++ b/tests/schema/test_hed_cache.py @@ -8,6 +8,7 @@ from hed.schema import hed_cache from hed import schema import shutil +from hed.errors import HedExceptions class Test(unittest.TestCase): @@ -128,15 +129,15 @@ def test_schema_load_schema_version_invalid(self): with self.assertRaises(HedFileError) as context4: load_schema_version(["8.2.0", "score_1.0.0"]) - self.assertEqual(context4.exception.args[0], 'schemaDuplicatePrefix') + self.assertEqual(context4.exception.args[0], HedExceptions.SCHEMA_DUPLICATE_PREFIX) with self.assertRaises(HedFileError) as context5: load_schema_version(["sc:8.2.0", "sc:score_1.0.0"]) - self.assertEqual(context5.exception.args[0], 'schemaDuplicatePrefix') + self.assertEqual(context5.exception.args[0], HedExceptions.SCHEMA_DUPLICATE_PREFIX) with self.assertRaises(HedFileError) as context6: load_schema_version(["8.1.0", "score_1.0.0"]) - self.assertEqual(context6.exception.args[0], 'schemaDuplicatePrefix') + self.assertEqual(context6.exception.args[0], HedExceptions.SCHEMA_DUPLICATE_PREFIX) with self.assertRaises(HedFileError) as context8: load_schema_version(["8.1.0", "notreallibrary_1.0.0"])