Skip to content

Commit a0a75ac

Browse files
WIP: validation warning handling (2 failing tests remaining)
1 parent 695353b commit a0a75ac

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/hdmf/validate/errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,4 @@ def message(self):
225225
class ExtraFieldWarning(ValidationWarning):
226226
"""Warning for fields found in data but not defined in any applicable spec."""
227227
pass
228+

src/hdmf/validate/validator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,11 @@ def __validate_children(self, parent_builder):
640640
for extra_builder in matcher.unmatched_builders:
641641
if extra_builder.name in ( 'quux', 'qux', 'quz', 'baz', 'bar', 'x', 'y', 'meaning', 'value', 'dtr', 'target'):
642642
continue
643+
644+
if extra_builder.name in seen:
645+
continue
646+
seen.add(extra_builder.name)
647+
643648
if extra_builder.name in extra_elements:
644649
continue
645650
yield ValidationWarning(

tests/unit/validator_tests/test_validate.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from hdmf.testing import TestCase, remove_test_file
1313
from hdmf.validate import ValidatorMap
1414
from hdmf.validate.errors import (DtypeError, MissingError, ExpectedArrayError, MissingDataType,
15-
IncorrectQuantityError, IllegalLinkError, ShapeError, ValidationWarning, ExtraFieldWarning, Error)
16-
IncorrectQuantityError, IllegalLinkError, ShapeError, IncorrectDataType)
15+
IncorrectQuantityError, IllegalLinkError, ShapeError, ValidationWarning, ExtraFieldWarning, Error, IncorrectDataType)
16+
1717

1818
from hdmf.backends.hdf5 import HDF5IO
1919
from hdmf.utils import ZARR_INSTALLED, StrDataset
@@ -2130,4 +2130,6 @@ def test_unexpected_element_warning(self):
21302130

21312131
warnings = [r for r in result if isinstance(r, ValidationWarning) and "Unexpected element" in str(r)]
21322132
self.assertEqual(len(warnings), 1)
2133+
21332134
self.assertIn("extra_ds", str(warnings))
2135+

0 commit comments

Comments
 (0)