-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54d39b7
commit f8ce558
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from pathlib import Path | ||
import tempfile | ||
|
||
from pynwb import read_nwb | ||
from pynwb.testing.mock.file import mock_NWBFile | ||
from pynwb.testing import TestCase | ||
|
||
import unittest | ||
try: | ||
from hdmf_zarr import NWBZarrIO # noqa f401 | ||
HAVE_NWBZarrIO = True | ||
except ImportError: | ||
HAVE_NWBZarrIO = False | ||
|
||
|
||
class TestReadNWBMethod(TestCase): | ||
""" | ||
Test that H5DataIO functions correctly on round trip with the HDF5IO backend | ||
""" | ||
def setUp(self): | ||
self.nwbfile = mock_NWBFile() | ||
|
||
|
||
def test_read_nwb_hdf5(self): | ||
from pynwb import NWBHDF5IO | ||
|
||
with tempfile.TemporaryDirectory() as temp_dir: | ||
path = Path(temp_dir) / "test.nwb" | ||
with NWBHDF5IO(path, 'w') as io: | ||
io.write(self.nwbfile) | ||
|
||
read_nwbfile = read_nwb(path=path) | ||
self.assertContainerEqual(read_nwbfile, self.nwbfile) | ||
read_nwbfile.get_read_io().close() | ||
|
||
@unittest.skipIf(not HAVE_NWBZarrIO, "NWBZarrIO library not available") | ||
def test_read_zarr(self): | ||
# from pynwb import NWBZarrIO | ||
from hdmf_zarr import NWBZarrIO | ||
|
||
with tempfile.TemporaryDirectory() as temp_dir: | ||
path = Path(temp_dir) / "test.nwb" | ||
with NWBZarrIO(path, 'w') as io: | ||
io.write(self.nwbfile) | ||
|
||
read_nwbfile = read_nwb(path=path) | ||
self.assertContainerEqual(read_nwbfile, self.nwbfile) | ||
read_nwbfile.get_read_io().close() |