[h5py] 363/455: Add more tests
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:51 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.
commit b69bcac204dd0ab5fe4319ce6bc0561f2defb20c
Author: andrewcollette <andrew.collette at gmail.com>
Date: Fri Jan 15 03:22:41 2010 +0000
Add more tests
---
h5py/tests/__init__.py | 17 ++++-
h5py/tests/high/test_file.py | 6 +-
h5py/tests/high/test_group.py | 153 ++++++++++++++++++++++++++++++++++---
h5py/tests/low/test_h5a.py | 4 +-
h5py/tests/low/test_h5i.py | 87 +++++++++++++++++++++
h5py/tests/low/test_h5r.py | 57 ++++++++++++++
h5py/tests/test_group.py | 173 ------------------------------------------
h5py/tests/test_h5.py | 17 -----
h5py/tests/test_h5i.py | 58 --------------
h5py/tests/test_h5r.py | 58 --------------
10 files changed, 306 insertions(+), 324 deletions(-)
diff --git a/h5py/tests/__init__.py b/h5py/tests/__init__.py
index c646127..9e6e5e4 100644
--- a/h5py/tests/__init__.py
+++ b/h5py/tests/__init__.py
@@ -12,6 +12,7 @@
import unittest
import h5py
+import numpy as np
config = h5py.h5.get_config()
@@ -31,9 +32,12 @@ def autotest():
except:
sys.exit(2)
-def fixme(func):
- print "FIXME: ", func.__doc__
- return None
+def fixme(desc=""):
+
+ def wrap(func):
+ print "FIXME: %s [%s]" % (func.__doc__, desc)
+ return None
+ return wrap
def require(api=None, os=None, unicode=None):
""" Decorator to enable/disable tests """
@@ -143,3 +147,10 @@ class HTest(unittest.TestCase):
if not len(a) == len(b) and set(a) == set(b):
raise AssertionError("contents don't match: %s vs %s" % (list(a), list(b)))
+ def assertIsNone(self, what):
+
+ if what is not None:
+ raise AssertionError("%r is not None" % what)
+
+
+
diff --git a/h5py/tests/high/test_file.py b/h5py/tests/high/test_file.py
index 19e4f08..c322fb4 100644
--- a/h5py/tests/high/test_file.py
+++ b/h5py/tests/high/test_file.py
@@ -107,14 +107,14 @@ class TestCore(FileBase):
def test_create(self):
""" (File) Create with core driver """
- f = h5py.File('a', 'w', driver='core')
+ f = h5py.File('a', 'w', driver='core', backing_store=False)
self.assert_(f)
self.assertEqual(f.driver, 'core')
f.close()
@tests.require(api=18)
def test_open(self):
- """ (File) Open with core driver """
+ """ (File) Open with core driver on 1.8 """
self.name = mktemp()
self.f = h5py.File(self.name, 'w')
self.f.create_group('g')
@@ -143,7 +143,7 @@ class TestCore(FileBase):
def test_blocksize(self):
""" (File) Block size argument for core driver """
- self.f = h5py.File('a', 'w', driver='core', block_size=1024)
+ self.f = h5py.File('a', 'w', driver='core', block_size=1024, backing_store=False)
self.assert_(self.f)
class TestOps(tests.HTest):
diff --git a/h5py/tests/high/test_group.py b/h5py/tests/high/test_group.py
index 904df01..3a85368 100644
--- a/h5py/tests/high/test_group.py
+++ b/h5py/tests/high/test_group.py
@@ -1,4 +1,5 @@
+import numpy as np
from tempfile import mktemp
from h5py import tests
import h5py
@@ -17,8 +18,10 @@ class GroupBase(tests.HTest):
class TestCreate(GroupBase):
+ """ Creating groups """
+
def test_create(self):
- """ (Group) Create group """
+ """ (Group) Create with create_group() """
self.f.create_group('new')
self.assert_('new' in self.f)
g = self.f['new']
@@ -43,33 +46,53 @@ class TestCreate(GroupBase):
ds = self.f.create_dataset('new', (1,), 'f')
self.assertRaises(TypeError, self.f.require_group, 'new')
+class TestDel(GroupBase):
+
+ """ Deleting objects """
+
def test_del(self):
- """ (Group) del """
+ """ (Group) del unlinks group """
self.f.create_group('new')
self.assert_('new' in self.f)
del self.f['new']
self.assert_('new' not in self.f)
- @tests.fixme
+ @tests.fixme("KeyError on 1.6, SymbolError on 1.8")
def test_del_exc(self):
""" (Group) del raises KeyError for missing item """
self.assertRaises(KeyError, self.f.__delitem__, 'new')
+class TestSpecial(GroupBase):
+
+ """ Misc HL object protocol """
+
def test_repr(self):
- """ (Group) repr() """
+ """ (Group) repr() returns string """
g = self.f.create_group('new')
- repr(g)
+ self.assertIsInstance(repr(g), basestring)
g.id._close()
- repr(g)
+ self.assertIsInstance(repr(g), basestring)
def test_bool(self):
- """ (Group) nonzero() """
+ """ (Group) nonzero() tracks object validity """
g = self.f.create_group('new')
self.assert_(g)
g.id._close()
self.assert_(not g)
-class TestDict2(GroupBase):
+class TestDataset(GroupBase):
+
+ """ Creating datasets """
+
+ def test_dataset(self):
+ """ (Group) Create dataset via create_dataset """
+ ds = self.f.create_dataset("Dataset", shape=(10,10), dtype='<i4')
+ self.assertIsInstance(ds, h5py.Dataset)
+ self.assert_("Dataset" in self.f)
+
+class TestDict(GroupBase):
+
+ """ Dictionary API """
def setUp(self):
GroupBase.setUp(self)
@@ -78,13 +101,13 @@ class TestDict2(GroupBase):
self.f.create_group(x)
def test_len(self):
- """ (Group) len() """
+ """ (Group) len() tracks group contents """
self.assertEqual(len(self.f), len(self.groups))
self.f.create_group('e')
self.assertEqual(len(self.f), len(self.groups)+1)
def test_contains(self):
- """ (Group) __contains__ for absolute and relative paths"""
+ """ (Group) __contains__ works for absolute and relative paths"""
self.assert_(not 'new' in self.f)
g = self.f.create_group('new')
self.assert_('new' in self.f)
@@ -116,5 +139,115 @@ class TestDict2(GroupBase):
self.assertEqualContents(self.f.iterkeys(), self.f)
self.assertEqualContents(self.f.itervalues(), [self.f[x] for x in self.groups])
+class TestAutoCreate(GroupBase):
+
+ """ __setitem__ for scalars, sequences & datatypes """
+
+ def test_scalar(self):
+ """ (Group) Store scalar -> rank-0 dataset """
+ self.f['x'] = 42
+ x = self.f['x']
+ self.assertIsInstance(x, h5py.Dataset)
+ self.assertEqual(x.shape, ())
+ self.assertEqual(x[()], 42)
+
+ def test_sequence(self):
+ """ (Group) Store sequence -> dataset """
+ self.f['x'] = [1,2,3,4,5]
+ x = self.f['x']
+ self.assertIsInstance(x, h5py.Dataset)
+ self.assertEqual(x.shape, (5,))
+ self.assertArrayEqual(x, np.array([1,2,3,4,5]))
+
+ def test_fortran(self):
+ """ (Group) Assign Fortran array """
+ a = np.array([[1,2,3],[4,5,6]], order='f')
+ self.f['x'] = a
+ x = self.f['x']
+ self.assertArrayEqual(x, a)
+
+ def test_dtype(self):
+ """ (Group) Store dtype -> named type """
+ dt = np.dtype('f')
+ self.f['x'] = dt
+ x = self.f['x']
+ self.assertIsInstance(x, h5py.Datatype)
+ self.assertEqual(x.dtype, dt)
+
+ def test_hardlink(self):
+ """ (Group) Store HLObject -> hard link """
+ g = self.f.create_group('foo')
+ self.f['x'] = g
+ x = self.f['x']
+ self.assertIsInstance(x, h5py.Group)
+ self.assertEqual(x, g)
+
+ def test_exc(self):
+ """ (Group) Assign with non-string key raises TypeError """
+ self.assertRaises(TypeError, self.f.__setitem__, 42, 42)
+
+ def test_exc1(self):
+ """ (Group) Assign with existing key raises ValueError """
+ self.f.create_group('foo')
+ self.assertRaises(ValueError, self.f.__setitem__, 'foo', 42)
+
+class TestVisit(GroupBase):
+
+ def setUp(self):
+ GroupBase.setUp(self)
+ self.groups = ['grp1', 'grp1/sg1', 'grp1/sg2', 'grp2', 'grp2/sg1', 'grp2/sg1/ssg1']
+ for x in self.groups:
+ self.f.create_group(x)
+
+ @tests.require(api=16)
+ def test_visit_16(self):
+ """ (Group) visit() on 1.6 raises NotImplementedError """
+ l = []
+ self.assertRaises(NotImplementedError, self.f.visit, l.append)
+
+ @tests.require(api=18)
+ def test_visit_18(self):
+ """ (Group) visit() on 1.8 iterates over all names """
+ l = []
+ self.f.visit(l.append)
+ self.assertEqualContents(l, self.groups)
+
+ @tests.require(api=16)
+ def test_visititems_16(self):
+ """ (Group) visititems() on 1.6 raises NotImplementedError """
+ l = []
+ self.assertRaises(NotImplementedError, self.f.visititems, lambda x, y: l.append((x,y)))
+
+ @tests.require(api=18)
+ def test_visititems_18(self):
+ """ (Group) visititems() on 1.8 iterates over all names, values """
+ l = []
+ comp = [(x, self.f[x]) for x in self.groups]
+ self.f.visititems(lambda x, y: l.append((x,y)))
+ self.assertEqualContents(comp, l)
+
+ @tests.require(api=18)
+ def test_short(self):
+ """ (Group) visit(), visititems() honor short-circuit return value """
+ x = self.f.visit(lambda x: x)
+ self.assertEqual(x, self.groups[0])
+ x = self.f.visititems(lambda x, y: (x,y))
+ self.assertEqual(x, (self.groups[0], self.f[self.groups[0]]))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/h5py/tests/low/test_h5a.py b/h5py/tests/low/test_h5a.py
index a7ab24e..faa04b3 100644
--- a/h5py/tests/low/test_h5a.py
+++ b/h5py/tests/low/test_h5a.py
@@ -43,7 +43,7 @@ class TestCreate(tests.HTest):
obj_name='subgroup', lapl=lapl)
self.assert_(isattr(aid))
- @tests.fixme
+ @tests.fixme()
def test_exc_1(self):
""" (H5A) Existing name causes ValueError """
h5a.create(self.fid, 'name', h5t.STD_I32LE, self.sid)
@@ -104,7 +104,7 @@ class TestOpenExists(tests.HTest):
""" (H5A) Open with wrong name causes KeyError """
self.assertRaises(KeyError, h5a.open, self.fid, 'missing')
- @tests.fixme
+ @tests.fixme()
def test_exc_2(self):
""" (H5A) Open with wrong index causes ValueError """
self.assertRaises(ValueError, h5a.open, self.fid, index=2)
diff --git a/h5py/tests/low/test_h5i.py b/h5py/tests/low/test_h5i.py
new file mode 100644
index 0000000..78be445
--- /dev/null
+++ b/h5py/tests/low/test_h5i.py
@@ -0,0 +1,87 @@
+
+from h5py import tests
+from h5py import *
+
+class Base(tests.HTest):
+
+ def setUp(self):
+ self.fid, self.name = tests.gettemp()
+
+ def tearDown(self):
+ import os
+ self.fid.close()
+ os.unlink(self.name)
+
+class TestType(Base):
+
+ def test_type(self):
+ """ (H5I) get_type() returns typecode """
+ x = h5i.get_type(self.fid)
+ self.assertEqual(x, h5i.FILE)
+
+ def test_exc(self):
+ """ (H5I) get_type() returns BADID for closed object """
+ g = h5g.open(self.fid, '/')
+ g._close()
+ self.assertEqual(h5i.get_type(g), h5i.BADID)
+
+class TestName(Base):
+
+ def test_name(self):
+ """ (H5I) get_name() returns string name """
+ g = h5g.create(self.fid, '/foobar')
+ self.assertEqual(h5i.get_name(g), '/foobar')
+
+ def test_noname(self):
+ """ (H5I) get_name() returns None for unnamed & invalid objects """
+ sid = h5s.create_simple((10,10))
+ g = h5g.open(self.fid, '/')
+ g._close()
+ self.assertIsNone(h5i.get_name(sid))
+ self.assertIsNone(h5i.get_name(g))
+
+ @tests.fixme("Inconsistent")
+ def test_ref(self):
+ """ (H5I) get_name() returns None for dereferenced objects """
+ g = h5g.create(self.fid, '/foobar')
+ ref = h5r.create(g, '.', h5r.OBJECT)
+ g._close()
+ deref = h5r.dereference(ref, self.fid)
+ self.assertIsNone(h5i.get_name(deref))
+
+class TestFID(Base):
+
+ def test_fid(self):
+ """ (H5I) get_file_id() returns FID, with increased refcount """
+ g = h5g.create(self.fid, '/foobar')
+ x = h5i.get_file_id(g)
+ self.assertIsInstance(x, h5f.FileID)
+ self.assertEqual(x, self.fid)
+ self.assertEqual(h5i.get_ref(x), 2)
+
+ def test_exc(self):
+ """ (H5I) get_file_id() on closed object raises ValueError """
+ g = h5g.open(self.fid, '/')
+ g._close()
+ self.assertRaises(ValueError, h5i.get_file_id, g)
+
+class TestRefs(tests.HTest):
+
+ def test_refs(self):
+ """ (H5I) get_ref, inc_ref, dec_ref are consistent """
+ sid = h5s.create_simple((10,10))
+ self.assertEqual(h5i.get_ref(sid), 1)
+
+ h5i.inc_ref(sid)
+ self.assertEqual(h5i.get_ref(sid), 2)
+
+ h5i.dec_ref(sid)
+ self.assertEqual(h5i.get_ref(sid), 1)
+
+
+
+
+
+
+
+
diff --git a/h5py/tests/low/test_h5r.py b/h5py/tests/low/test_h5r.py
new file mode 100644
index 0000000..312efbb
--- /dev/null
+++ b/h5py/tests/low/test_h5r.py
@@ -0,0 +1,57 @@
+#+
+#
+# This file is part of h5py, a low-level Python interface to the HDF5 library.
+#
+# Copyright (C) 2008 Andrew Collette
+# http://h5py.alfven.org
+# License: BSD (See LICENSE.txt for full license)
+#
+# $Date$
+#
+#-
+
+from h5py import tests
+from h5py import *
+
+class TestBasic(tests.HTest):
+
+ def setUp(self):
+ self.fid, self.name = tests.gettemp()
+ self.id = h5g.open(self.fid, '/')
+ sid = h5s.create_simple((10,10))
+ self.did = h5d.create(self.fid, 'ds', h5t.STD_I32LE, sid)
+
+ def tearDown(self):
+ import os
+ self.fid.close()
+ os.unlink(self.name)
+
+ def test_obj(self):
+ """ (H5R) Object reference round-trip """
+ ref = h5r.create(self.id, '/', h5r.OBJECT)
+ self.assertIsInstance(ref, h5r.Reference)
+ self.assertEqual(h5r.dereference(ref, self.fid), self.id)
+
+ def test_reg(self):
+ """ (H5R) Region reference round-trip """
+ sid = self.did.get_space()
+ ref = h5r.create(self.did, '.', h5r.DATASET_REGION, sid)
+ self.assertIsInstance(ref, h5r.RegionReference)
+ self.assertEqual(h5r.dereference(ref, self.fid), self.did)
+ sid2 = h5r.get_region(ref, self.id)
+ self.assertIsInstance(sid, h5s.SpaceID)
+ self.assertEqual(sid2.get_select_bounds(), sid.get_select_bounds())
+
+ @tests.fixme("segfaults")
+ def test_create_exc(self):
+ """ (H5R) RegionReference w/no dataspace raises ValueError """
+ self.assertRaises(ValueError, h5r.create, self.did, '.', h5r.DATASET_REGION)
+
+ @tests.require(api=18)
+ def test_obj(self):
+ """ (H5R) get_name() on object reference """
+ ref = h5r.create(self.id, '/', h5r.OBJECT)
+ self.assertEqual(h5r.get_name(ref, self.fid), '/')
+
+
+
diff --git a/h5py/tests/test_group.py b/h5py/tests/test_group.py
index 029843d..83efc00 100644
--- a/h5py/tests/test_group.py
+++ b/h5py/tests/test_group.py
@@ -31,130 +31,6 @@ class GroupBase(TestCasePlus):
self.assertEqual(set(a), set(b))
self.assertEqual(len(a), len(b))
-class TestInit(GroupBase):
-
- """ Group creation """
-
- def test_Group_init(self):
- """ Group constructor """
-
- grp = h5py.Group(self.f, "NewGroup", create=True)
- self.assert_("NewGroup" in self.f)
- grp2 = h5py.Group(self.f, "NewGroup")
-
- self.assertEqual(grp.name, "/NewGroup")
-
- def test_Group_create_dataset(self):
-
- ds = self.f.create_dataset("Dataset", shape=(10,10), dtype='<i4')
- self.assert_(isinstance(ds, h5py.Dataset))
- self.assert_("Dataset" in self.f)
-
-class TestSetItem(GroupBase):
-
- """ Behavior of Group.__setitem__ """
-
- def test_ndarray(self):
- """ Assignment of an ndarray to a Group object """
-
- shapes = [(), (1,), (10,10)]
- types = ['i', 'f']#, [('a','i'), ('b','f')]]
- types = [np.dtype(t) for t in types]
-
- for shape in shapes:
- for dt in types:
- msg = "Assign ndarray %s %s" % (dt, shape)
-
- arr = np.ones(shape, dtype=dt)
- self.f['DS'] = arr
- dset = self.f['DS']
- self.assertEqual(dset.shape, arr.shape)
- self.assertEqual(dset.dtype, arr.dtype)
-
- self.assertArrayEqual(dset[()], arr[()], msg)
-
- del self.f['DS']
-
- def test_dtype(self):
- """ Assignment of a dtype to a Group object """
-
- types = ['i', 'f', [('a','i'), ('b','f')]]
- types = [np.dtype(t) for t in types]
-
- for dt in types:
- msg = "Assign dtype %s" % (dt,)
-
- self.f['TYPE'] = dt
- htype = self.f['TYPE']
- self.assert_(isinstance(htype, h5py.Datatype), msg)
- self.assertEqual(htype.dtype, dt)
-
- del self.f['TYPE']
-
- def test_hardlink(self):
- """ Hard-linking by direct assignment to Group """
-
- grp1 = self.f.create_group('grp1')
- self.f['grp2'] = grp1
- grp2 = self.f['grp2']
-
- self.assert_(grp1 is not grp2)
- self.assert_(grp1 == grp2)
- self.assert_(hash(grp1) == hash(grp2))
-
- def test_array_autocreate(self):
- """ Auto-creation of dataset from sequence """
-
- seq = [1,-42,2,3,4,5,10]
- arr = np.array(seq)
-
- self.f['DS'] = seq
- self.assert_(np.all(self.f['DS'][...] == arr))
-
- # test scalar -> 0-d dataset
- self.f["DS_SC"] = 42
- harr = self.f["DS_SC"]
- self.assert_(isinstance(harr, Dataset))
- self.assertEqual(harr.shape, ())
- self.assertEqual(harr.value, 42)
-
- # test assignment of out-of-order arrays
- arr = np.array(numpy.arange(100).reshape((10,10)), order='F')
- self.f['FORTRAN'] = arr
- dset = self.f['FORTRAN']
- self.assert_(np.all(dset[:] == arr))
- self.assert_(dset[:].flags['C_CONTIGUOUS'])
-
- def test_exceptions(self):
- """ Exceptions from __setitem__ """
-
- self.f.create_group('grp')
- self.assertRaises(ValueError, self.f.create_group, 'grp')
-
-def TestGetItem(GroupBase):
-
- def test_get(self):
-
- grp = self.f.create_group("grp")
- dset = self.f.create_dataset("ds", (1,), 'f')
- dtype = np.dtype('f')
- self.f['type'] = dtype
- htype = self.f['type']
-
- self.assert_(isinstance(self.f['grp'], h5py.Group))
- self.assert_(self.f['grp'] == grp)
-
- self.assert_(isinstance(self.f['ds'], h5py.Dataset))
- self.assert_(self.f['ds'] == dset)
-
- self.assert_(isinstance(self.f['type'], h5py.Datatype))
- self.assert_(self.f['type'].dtype == dtype)
-
- def test_exceptions(self):
-
- self.assertRaises(TypeError, self.f,__getitem__, 42)
- self.assertRaises(KeyError, self.f.__getitem__, 'missing')
-
## -----
from h5py import Group, Dataset, Datatype, File
@@ -205,52 +81,3 @@ class TestOther(GroupBase):
self.assert_('new' in self.f)
self.assert_('new/bar' in self.f)
- @api_16
- def test_visit_16(self):
-
- for x in ['grp1','grp2']:
- self.f.create_group(x)
-
- grplist = []
- self.assertRaises(NotImplementedError, self.f.visit, grplist.append)
-
- self.assertRaises(NotImplementedError, self.f.visititems, lambda x,y: grplist.append((x,y)))
-
- @api_18
- def test_visit_18(self):
-
- groups = ['grp1', 'grp1/sg1', 'grp1/sg2', 'grp2', 'grp2/sg1', 'grp2/sg1/ssg1']
-
- for x in groups:
- self.f.create_group(x)
-
- group_visit = []
- self.f.visit(group_visit.append)
-
- self.assert_equal_contents(groups, group_visit)
-
- grp_items = [(x, self.f[x]) for x in groups]
-
- group_visit = []
- self.f.visititems(lambda x, y: group_visit.append((x,y)))
-
- self.assert_equal_contents(grp_items, group_visit)
-
- # Test short-circuit return
-
- group_visit = []
- def visitor(name, obj=None):
- group_visit.append(name)
- if name.find('grp2/sg1') >= 0:
- return name
- return None
-
- result = self.f.visit(visitor)
- self.assert_(result.find('grp2/sg1') >= 0)
- self.assert_(not any(x.find('grp2/sg1/ssg1') >= 0 for x in group_visit))
-
- del group_visit[:]
-
- result = self.f.visititems(visitor)
- self.assert_(result.find('grp2/sg1') >= 0)
- self.assert_(not any(x.find('grp2/sg1/ssg1') >= 0 for x in group_visit))
diff --git a/h5py/tests/test_h5.py b/h5py/tests/test_h5.py
deleted file mode 100644
index f5b6bd6..0000000
--- a/h5py/tests/test_h5.py
+++ /dev/null
@@ -1,17 +0,0 @@
-#+
-#
-# This file is part of h5py, a low-level Python interface to the HDF5 library.
-#
-# Copyright (C) 2008 Andrew Collette
-# http://h5py.alfven.org
-# License: BSD (See LICENSE.txt for full license)
-#
-# $Date$
-#
-#-
-import unittest
-
-from h5py import h5
-
-class TestH5(unittest.TestCase):
- pass
diff --git a/h5py/tests/test_h5i.py b/h5py/tests/test_h5i.py
deleted file mode 100644
index 8fbc134..0000000
--- a/h5py/tests/test_h5i.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#+
-#
-# This file is part of h5py, a low-level Python interface to the HDF5 library.
-#
-# Copyright (C) 2008 Andrew Collette
-# http://h5py.alfven.org
-# License: BSD (See LICENSE.txt for full license)
-#
-# $Date$
-#
-#-
-
-from common import TestCasePlus
-
-from h5py import *
-
-HDFNAME = 'attributes.hdf5'
-OBJECTNAME = 'Group'
-
-class TestH5I(TestCasePlus):
-
-
- def setUp(self):
- self.setup_fid(HDFNAME)
- self.obj = h5g.open(self.fid, OBJECTNAME)
-
- def tearDown(self):
- self.obj._close()
- self.teardown_fid()
-
- def test_get_type(self):
- self.assertEqual(h5i.get_type(self.fid), h5i.FILE)
- self.assertEqual(h5i.get_type(self.obj), h5i.GROUP)
-
- def test_get_name(self):
- self.assertEqual(h5i.get_name(self.obj), '/Group')
- self.assertEqual(h5i.get_name(h5t.STD_I8LE), None)
-
- def test_get_file_id(self):
- nfid = h5i.get_file_id(self.obj)
- self.assertEqual(nfid, self.fid)
-
- def test_refs(self):
- refcnt = h5i.get_ref(self.obj)
- self.assert_(refcnt >= 0)
-
- h5i.inc_ref(self.obj)
- self.assertEqual(h5i.get_ref(self.obj), refcnt+1)
-
- h5i.dec_ref(self.obj)
- self.assertEqual(h5i.get_ref(self.obj), refcnt)
-
-
-
-
-
-
-
diff --git a/h5py/tests/test_h5r.py b/h5py/tests/test_h5r.py
deleted file mode 100644
index b914c80..0000000
--- a/h5py/tests/test_h5r.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#+
-#
-# This file is part of h5py, a low-level Python interface to the HDF5 library.
-#
-# Copyright (C) 2008 Andrew Collette
-# http://h5py.alfven.org
-# License: BSD (See LICENSE.txt for full license)
-#
-# $Date$
-#
-#-
-
-import unittest
-import tempfile
-import os
-import numpy
-
-from h5py import *
-
-
-class TestH5R(unittest.TestCase):
-
- def setUp(self):
- self.fname = tempfile.mktemp('.hdf5')
- self.f = File(self.fname, 'w')
- self.dset = self.f.create_dataset("ds", (100,))
- self.grp = self.f.create_group("grp")
-
- def tearDown(self):
- self.f.close()
- os.unlink(self.fname)
-
- def test_objref(self):
- ref = h5r.create(self.f.id, "grp", h5r.OBJECT)
- deref = h5r.dereference(ref, self.f.id)
- self.assertEqual(deref, self.grp.id)
- #self.assertEqual(h5i.get_name(deref), h5i.get_name(self.grp.id))
- self.assertEqual(h5r.get_obj_type(ref, self.f.id), h5g.GROUP)
-
- def test_regref(self):
- space = self.dset.id.get_space()
- space.select_hyperslab((13,), (42,))
- ref = h5r.create(self.f.id, "ds", h5r.DATASET_REGION, space)
-
- #deref = ref.dereference(self.f.id)
- #self.assertEqual(deref, self.grp.id)
- #self.assertEqual(h5i.get_name(deref), h5i.get_name(self.grp.id))
-
- deref_space = h5r.get_region(ref, self.f.id)
- self.assertEqual(space.shape, deref_space.shape)
- self.assert_(space.get_select_bounds(), deref_space.get_select_bounds())
-
- self.assertEqual(h5r.get_obj_type(ref, self.f.id), h5g.DATASET)
-
-
-
-
-
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git
More information about the debian-science-commits
mailing list