def test_multiple_jsonlines(): a, b = '_test_a1.json', '_test_a2.json' try: with ignoring(OSError): os.remove(a) with ignoring(OSError): os.remove(b) with open(a, 'w') as f: json.dump(dat, f) with open(b'_test_a2.json', 'w') as f: json.dump(dat, f) r = resource('_test_a*.json') result = convert(list, r) assert len(result) == len(dat) * 2 finally: with ignoring(OSError): os.remove(a) with ignoring(OSError): os.remove(b)
def tmpbcolz(*args, **kwargs): fn = '.%s.bcolz' % str(uuid.uuid1()) r = resource(fn, *args, **kwargs) try: yield r finally: with ignoring(Exception): r.flush() if os.path.exists(fn): shutil.rmtree(fn)
def test_drop_group(): with tmpfile('.hdf5') as fn: f = h5py.File(fn) try: f.create_dataset('/group/data', data=x, chunks=True, maxshape=(None,) + x.shape[1:]) drop(f['/group']) assert '/group' not in f.keys() finally: with ignoring(Exception): f.close()
def file(x): with tmpfile('.hdf5') as fn: f = h5py.File(fn) data = f.create_dataset('/data', data=x, chunks=True, maxshape=(None,) + x.shape[1:]) try: yield fn, f, data finally: with ignoring(Exception): f.close()
def test_discover_on_data_with_object_in_record_name(): data = np.array([(u'a', 1), (u'b', 2)], dtype=[('lrg_object', unicode_dtype), ('an_int', 'int64')]) with tmpfile('.hdf5') as fn: f = h5py.File(fn) try: f.create_dataset('/data', data=data) except: raise else: assert (discover(f['data']) == datashape.dshape('2 * {lrg_object: string, an_int: int64}')) finally: with ignoring(Exception): f.close()