From e488cf3dcef8dfaa07dcb1a3efb48e1bbd663add Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Tue, 27 Aug 2024 17:55:00 -0700 Subject: [PATCH] test --- tests/unit/test_io_hdf5_h5tools.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/unit/test_io_hdf5_h5tools.py b/tests/unit/test_io_hdf5_h5tools.py index 4dece7398..56f0ea21b 100644 --- a/tests/unit/test_io_hdf5_h5tools.py +++ b/tests/unit/test_io_hdf5_h5tools.py @@ -791,6 +791,26 @@ def test_roundtrip_basic(self): self.assertListEqual(foofile.buckets['bucket1'].foos['foo1'].my_data, read_foofile.buckets['bucket1'].foos['foo1'].my_data[:].tolist()) + def test_roundtrip_basic_append(self): + # Setup all the data we need + foo1 = Foo('foo1', [1, 2, 3, 4, 5], "I am foo1", 17, 3.14) + foobucket = FooBucket('bucket1', [foo1]) + foofile = FooFile(buckets=[foobucket]) + + with HDF5IO(self.path, manager=self.manager, mode='w') as io: + io.write(foofile) + + with HDF5IO(self.path, manager=self.manager, mode='a') as io: + read_foofile = io.read() + data = read_foofile.buckets['bucket1'].foos['foo1'].my_data + shape = list(data.shape) + shape[0] += 1 + data.resize(shape) + data[-1] = 6 + self.assertListEqual(read_foofile.buckets['bucket1'].foos['foo1'].my_data[:].tolist(), + [1, 2, 3, 4, 5, 6]) + + def test_roundtrip_empty_dataset(self): foo1 = Foo('foo1', [], "I am foo1", 17, 3.14) foobucket = FooBucket('bucket1', [foo1])