Commit 927f4316 authored by Manuel Günther's avatar Manuel Günther
Browse files

Fixed crash in sub_groups; added more HDF5 tests.

parent 01b2ece8
......@@ -598,7 +598,7 @@ BOB_TRY
PyList_SET_ITEM(retval, i, Py_BuildValue("s", values[i].c_str()));
}
return retval;
return Py_BuildValue("O", retval);
BOB_CATCH_MEMBER(exception_message(self, s_sub_groups.name()).c_str(), 0)
}
......
......@@ -433,3 +433,49 @@ def test_close():
finally:
os.unlink(tmpname)
def test_copy_constructor():
try:
tmpname = test_utils.temporary_filename()
tmpname2 = test_utils.temporary_filename()
hdf5 = HDF5File(tmpname, 'w')
shallow = HDF5File(hdf5)
deep = HDF5File(tmpname2, 'w')
hdf5.copy(deep)
hdf5.create_group("Test")
hdf5.cd("Test")
hdf5.set("Data", numpy.random.random((10,10)))
hdf5.flush()
assert shallow.has_group("/Test")
assert shallow.has_key("/Test/Data")
assert hdf5.filename == shallow.filename
assert hdf5.keys() == shallow.keys()
assert hdf5.cwd == shallow.cwd
assert not deep.has_group("/Test")
assert hdf5.filename != deep.filename
assert hdf5.keys() != deep.keys()
assert hdf5.cwd != deep.cwd
hdf5.cd("..")
assert hdf5.sub_groups() == shallow.sub_groups()
assert hdf5.sub_groups() != deep.sub_groups()
assert hdf5.writable
assert shallow.writable
assert deep.writable
hdf5.close()
deep.close()
def test_filename():
fn = shallow.filename
nose.tools.assert_raises(RuntimeError, test_filename)
finally:
os.unlink(tmpname)
os.unlink(tmpname2)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment