Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_file_open_close():
""" https://github.com/telegraphic/hickle/issues/20 """
try:
import h5py
f = h5py.File('test.hdf', 'w')
a = np.arange(5)
dump(a, 'test.hkl')
dump(a, 'test.hkl')
dump(a, f, mode='w')
try:
dump(a, f, mode='w')
except hickle.hickle.ClosedFileError:
print("Tests: Closed file exception caught")
finally:
os.remove('test.hdf')
os.remove('test.hkl')
def test_file_open_close():
""" https://github.com/telegraphic/hickle/issues/20 """
import h5py
f = h5py.File('test.hdf', 'w')
a = np.arange(5)
dump(a, 'test.hkl')
dump(a, 'test.hkl')
dump(a, f, mode='w')
f.close()
try:
dump(a, f, mode='w')
except hickle.hickle.ClosedFileError:
print("Tests: Closed file exception caught")