def test_file_open_close():
    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 ClosedFileError:
            print "Tests: Closed file exception caught"
        
    finally:
        os.remove('test.hdf')
        os.remove('test.hkl')
https://github.com/telegraphic/hickle/issues/20
dataset/ETHPy150Open telegraphic/hickle/tests/test_hickle.py/test_file_open_close