From f23ed5c6772d6fc56fe27bd847d1f24e360dc692 Mon Sep 17 00:00:00 2001 From: Ryan Ly Date: Sat, 21 Oct 2023 13:58:14 -0700 Subject: [PATCH] Fix validation in NWB testing util classes --- src/pynwb/testing/testh5io.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/pynwb/testing/testh5io.py b/src/pynwb/testing/testh5io.py index b45407bfb..b8055db0d 100644 --- a/src/pynwb/testing/testh5io.py +++ b/src/pynwb/testing/testh5io.py @@ -163,18 +163,14 @@ def getContainer(self, nwbfile): def validate(self): """ Validate the created files """ if os.path.exists(self.filename): - with NWBHDF5IO(self.filename, mode='r') as io: - errors = pynwb_validate(io) - if errors: - for err in errors: - raise Exception(err) + errors = pynwb_validate(paths=[self.filename]) + if errors: + raise Exception("\n".join(errors)) if os.path.exists(self.export_filename): - with NWBHDF5IO(self.filename, mode='r') as io: - errors = pynwb_validate(io) - if errors: - for err in errors: - raise Exception(err) + errors = pynwb_validate(paths=[self.export_filename]) + if errors: + raise Exception("\n".join(errors)) class AcquisitionH5IOMixin(NWBH5IOMixin): @@ -366,13 +362,11 @@ def roundtripExportContainer(self, cache_spec=False): def validate(self): """Validate the created files.""" if os.path.exists(self.filename): - with NWBHDF5IO(self.filename, mode='r') as io: - errors = pynwb_validate(io) - if errors: - raise Exception("\n".join(errors)) + errors = pynwb_validate(paths=[self.filename]) + if errors: + raise Exception("\n".join(errors)) if os.path.exists(self.export_filename): - with NWBHDF5IO(self.filename, mode='r') as io: - errors = pynwb_validate(io) - if errors: - raise Exception("\n".join(errors)) + errors = pynwb_validate(paths=[self.export_filename]) + if errors: + raise Exception("\n".join(errors))