Skip to content

Commit df0f8ec

Browse files
committed
adopted new test suite
1 parent f9023e1 commit df0f8ec

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

tests/compact.hdf5

-1.38 KB
Binary file not shown.

tests/make_compact.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/test_compact.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
import os
22

33
import numpy as np
4+
import pytest
45
from numpy.testing import assert_array_equal
56

67
import pyfive
8+
import h5py
79

8-
DIRNAME = os.path.dirname(__file__)
9-
DATASET_COMPACT_HDF5_FILE = os.path.join(DIRNAME, 'compact.hdf5')
10-
11-
12-
def test_compact_dataset():
13-
14-
with pyfive.File(DATASET_COMPACT_HDF5_FILE) as hfile:
15-
data = np.array([1, 2, 3, 4], dtype=np.int32)
1610

11+
def test_compact_dataset_hdf5(name, data):
12+
with pyfive.File(name) as hfile:
1713
# check data
1814
dset1 = hfile['compact']
1915
assert_array_equal(dset1[...], data)
16+
17+
18+
@pytest.fixture(scope='module')
19+
def data():
20+
return np.array([1, 2, 3, 4], dtype=np.int32)
21+
22+
23+
@pytest.fixture(scope='module')
24+
def name(data):
25+
name = os.path.join(os.path.dirname(__file__), 'compact.hdf5')
26+
27+
f = h5py.File(name, 'w', libver='earliest')
28+
dtype = h5py.h5t.NATIVE_INT32
29+
space = h5py.h5s.create_simple(data.shape)
30+
dcpl = h5py.h5p.create(h5py.h5p.DATASET_CREATE)
31+
dcpl.set_layout(h5py.h5d.COMPACT)
32+
dset_id = h5py.h5d.create(f.id, b"compact", dtype, space, dcpl=dcpl)
33+
dset_id.write(h5py.h5s.ALL, h5py.h5s.ALL, data)
34+
f.close()
35+
36+
return name

0 commit comments

Comments
 (0)