Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin committed Dec 12, 2023
1 parent 139a5ab commit e8c4e3d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/integration/hdf5/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
from h5py import File
from pathlib import Path
import tempfile

from pynwb import NWBFile, TimeSeries, get_manager, NWBHDF5IO, validate

Expand All @@ -14,6 +15,7 @@
from pynwb.spec import NWBGroupSpec, NWBDatasetSpec, NWBNamespace
from pynwb.ecephys import ElectricalSeries, LFP
from pynwb.testing import remove_test_file, TestCase
from pynwb.testing.mock.file import mock_NWBFile


class TestHDF5Writer(TestCase):
Expand Down Expand Up @@ -516,3 +518,18 @@ def test_round_trip_with_pathlib_path(self):
with NWBHDF5IO(pathlib_path, 'r') as io:
read_file = io.read()
self.assertContainerEqual(read_file, self.nwbfile)


class TestNWBHDF5IOModes(TestCase):
def test_file_creation_and_deletion(self):
io_modes_that_create_file = ["w", "w-", "x"]

with tempfile.TemporaryDirectory() as temp_dir:
temp_dir = Path(temp_dir)
for io_mode in io_modes_that_create_file:
file_path = temp_dir / f"test_io_mode={io_mode}.nwb"

# Test file creation
nwbfile = mock_NWBFile()
with NWBHDF5IO(str(file_path), io_mode) as io:
io.write(nwbfile)

0 comments on commit e8c4e3d

Please sign in to comment.