Skip to content

Commit

Permalink
added test for Data
Browse files Browse the repository at this point in the history
  • Loading branch information
pauladkisson committed Sep 9, 2024
1 parent 0ded5a8 commit 6a1e05d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/unit/test_io_hdf5_h5tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3861,8 +3861,30 @@ class MyData(Data):
pass

self.data = MyData("my_data", [1, 2, 3])
self.file_path = get_temp_filepath()

def tearDown(self):
if os.path.exists(self.file_path):
os.remove(self.file_path)

def test_set_data_io(self):
self.data.set_data_io(H5DataIO, dict(chunks=True))
assert isinstance(self.data.data, H5DataIO)
assert self.data.data.io_settings["chunks"]

def test_set_data_io_h5py_dataset(self):
file = File(self.file_path, 'w')
data = file.create_dataset('data', data=[1, 2, 3, 4, 5], chunks=(3,))
class MyData(Data):
pass

my_data = MyData("my_data", data)
my_data.set_data_io(
H5DataIO,
data_io_kwargs=dict(chunks=(2,)),
data_chunk_iterator_class=DataChunkIterator,
)

self.assertIsInstance(my_data.data, H5DataIO)
self.assertEqual(my_data.data.io_settings["chunks"], (2,))
file.close()

0 comments on commit 6a1e05d

Please sign in to comment.