[h5py] 357/455: Reorganize test suite
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:50 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 32b67839cc95278605fe31d7d46e9796d217d447
Author: andrewcollette <andrew.collette at gmail.com>
Date: Fri Jan 8 05:07:00 2010 +0000
Reorganize test suite
---
h5py/tests/__init__.py | 154 ++++++++++++++++++++------
h5py/tests/common.py | 190 --------------------------------
h5py/tests/{ => data}/testfiles.py | 0
h5py/tests/{ => high}/test_dataset.py | 0
h5py/tests/{ => high}/test_filters.py | 0
h5py/tests/{ => high}/test_group.py | 0
h5py/tests/{ => high}/test_highlevel.py | 0
h5py/tests/{ => high}/test_slicing.py | 0
h5py/tests/{ => high}/test_threads.py | 0
h5py/tests/{ => high}/test_vlen.py | 0
h5py/tests/low/__init__.py | 25 +++++
h5py/tests/{ => low}/test_conv.py | 0
h5py/tests/{ => low}/test_h5.py | 0
h5py/tests/{ => low}/test_h5a.py | 17 +--
h5py/tests/{ => low}/test_h5d.py | 7 +-
h5py/tests/{ => low}/test_h5f.py | 10 +-
h5py/tests/{ => low}/test_h5g.py | 7 +-
h5py/tests/{ => low}/test_h5i.py | 7 +-
h5py/tests/{ => low}/test_h5p.py | 2 -
h5py/tests/{ => low}/test_h5r.py | 0
h5py/tests/{ => low}/test_h5s.py | 0
h5py/tests/{ => low}/test_h5t.py | 25 +++--
h5py/tests/{ => low}/test_utils.py | 2 +-
23 files changed, 187 insertions(+), 259 deletions(-)
diff --git a/h5py/tests/__init__.py b/h5py/tests/__init__.py
index 1d7a1b5..73d15e7 100644
--- a/h5py/tests/__init__.py
+++ b/h5py/tests/__init__.py
@@ -10,53 +10,141 @@
#
#-
-import h5py.tests
import unittest
-import common
-
-mnames = [
-'test_dataset',
-'test_group',
-'test_filters',
-'test_h5a',
-'test_h5d',
-'test_h5f',
-'test_h5g',
-'test_h5i',
-'test_h5p',
-'test_h5',
-'test_h5r',
-'test_h5s',
-'test_h5t',
-'test_highlevel',
-'test_slicing',
-'test_threads',
-'test_utils',
-'test_vlen',
-'test_conv']
+import h5py
+config = h5py.h5.get_config()
def runtests():
+ """ Run low and highlevel h5py tests.
- ldr = unittest.TestLoader()
- suite = unittest.TestSuite()
- modules = [__import__('h5py.tests.'+x, fromlist=[h5py.tests]) for x in mnames]
- for m in modules:
- suite.addTests(ldr.loadTestsFromModule(m))
-
+ Result is a 2-tuple of TestResult objects
+ """
+ import low
runner = unittest.TextTestRunner()
- return runner.run(suite)
+ return tuple(runner.run(suite) for suite in (low.getsuite(),))
def autotest():
try:
- if not runtests():
+ if not all(runtests()):
sys.exit(17)
except:
sys.exit(2)
-def testinfo():
- print "%d tests disabled" % common.skipped
+def requires(api=None):
+ """ Decorator to enable/disable tests """
+ def wrap(func):
+ if api == 18 and not config.API_18: return None
+ if api == 16 and not config.API_16: return None
+ return func
+ return wrap
+
+def skip(func):
+ """ Decorator to disable a test """
+ return None
+
+def datapath(name):
+ """ Path to a data file shipped with the test suite """
+ import os.path
+ return os.path.join(os.path.dirname(__file__), 'data', name)
+
+class FIDProxy(object):
+
+ """
+ Proxy object for low-level file IDs
+ """
+
+ def __init__(self, name=None):
+ import tempfile
+ import shutil
+ import os.path as op
+ from h5py import h5f, h5p
+
+ plist = h5py.h5p.create(h5p.FILE_ACCESS)
+ plist.set_fclose_degree(h5f.CLOSE_STRONG)
+
+ targetname = tempfile.mktemp('.hdf5')
+
+ if name is None:
+ fid = h5f.create(targetname, h5f.ACC_TRUNC, fapl=plist)
+ else:
+ name = datapath(name)
+ shutil.copy(name, targetname)
+ fid = h5f.open(targetname, h5f.ACC_RDWR, fapl=plist)
+
+ self.name = targetname
+ self.fid = fid
+
+ def erase(self):
+ """ Ensure the FID is closed and remove the temporary file """
+ import os
+ while self.fid and h5py.h5i.get_ref(self.fid) > 0:
+ h5py.h5i.dec_ref(self.fid)
+ os.unlink(self.name)
+
+class TestCasePlus(unittest.TestCase):
+
+ """
+ Slightly modified subclass of TestCase, which provides the following
+ added functionality:
+
+ 1. assertArrayEqual(), to save us from having to remember to use
+ numpy.all. Also allows reasonable comparison of floating-point
+ data.
+
+ 2. log() method, which allows useful information to be logged
+ without resorting to gyrations with sys.stderr or the logging
+ module.
+ """
+
+ EPSILON = 1e-5
+
+ def log(self, msg):
+ """ Print a message to an internal "log buffer", which is purged
+ when a new test begins.
+ """
+ self._log += msg+'\n'
+
+ def run(self, *args, **kwds):
+ import warnings
+
+ self._log = ""
+ filters = warnings.filters
+ warnings.simplefilter("ignore")
+ try:
+ unittest.TestCase.run(self, *args, **kwds)
+ except Exception, e:
+ if len(e.args) == 1 and isinstance(e.args[0], basestring):
+ e.args = (e.args[0]+'\n'+self._log)
+ elif len(e.args) == 2 and isinstance(e.args[1], basestring):
+ e.args = (e.args[1]+'\n'+self._log)
+ else:
+ e.args += (self._log)
+ raise
+ finally:
+ warnings.filters = filters
+
+ def assertArrayEqual(self, dset, arr, message=None, precision=None):
+ """ Make sure dset and arr have the same shape, dtype and contents, to
+ within the given precision.
+
+ Note that dset may be a NumPy array or an HDF5 dataset.
+ """
+ if precision is None:
+ precision = EPSILON
+ if message is None:
+ message = ''
+ else:
+ message = ' (%s)' % message
+
+ if np.isscalar(dset) or np.isscalar(arr):
+ assert np.isscalar(dset) and np.isscalar(arr), 'Scalar/array mismatch ("%r" vs "%r")%s' % (dset, arr, message)
+ assert dset - arr < precision, "Scalars differ by more than %.3f%s" % (precision, message)
+ return
+ assert dset.shape == arr.shape, "Shape mismatch (%s vs %s)%s" % (dset.shape, arr.shape, message)
+ assert dset.dtype == arr.dtype, "Dtype mismatch (%s vs %s)%s" % (dset.dtype, arr.dtype, message)
+ assert np.all(np.abs(dset[...] - arr[...]) < precision), "Arrays differ by more than %.3f%s" % (precision, message)
diff --git a/h5py/tests/common.py b/h5py/tests/common.py
deleted file mode 100644
index 42483b3..0000000
--- a/h5py/tests/common.py
+++ /dev/null
@@ -1,190 +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 os
-import unittest
-import tempfile
-import os.path as op
-import shutil
-from h5py import h5f, h5p, h5
-import h5py
-
-import numpy as np
-
-DATADIR = op.join(op.dirname(h5py.__file__), 'tests/data')
-
-
-import warnings
-from contextlib import contextmanager
-
- at contextmanager
-def dump_warnings():
- filters = warnings.filters
- warnings.simplefilter("ignore")
- yield
- warnings.filters = filters
-
-class ResourceManager(object):
-
- """
- Implements common operations, including generating filenames,
- files, and cleaning up identifiers. This frees each module from
- having to manually unlink its files, and restores the library to
- a known state.
- """
-
- def __init__(self):
- self.fnames = set()
-
- def get_name(self, suffix=None):
- """ Return a temporary filename, which can be unlinked with clear() """
- if suffix is None:
- suffix = '.hdf5'
- fname = tempfile.mktemp(suffix)
- self.fnames.add(fname)
- return fname
-
- def clear(self):
- """ Wipe out all open identifiers, and unlink all generated files """
- id_list = h5py.h5f.get_obj_ids(types=h5py.h5f.OBJ_ALL^h5py.h5f.OBJ_DATATYPE)
-
- for id_ in id_list:
- while(id_ and h5py.h5i.get_ref(id_) > 0):
- h5py.h5i.dec_ref(id_)
-
- for fname in self.fnames:
- if op.exists(fname):
- os.unlink(fname)
- try:
- fname %= 0
- except TypeError:
- continue
- if op.exists(fname):
- os.unlink(fname)
-
- self.fnames.clear()
-
- def get_data_path(self, name):
- """ Return the full path to a data file (given its basename) """
- return op.abspath(op.join(DATADIR, name))
-
- def get_data_copy(self, name):
- iname = self.get_data_path(name)
- fname = self.get_name()
- shutil.copy(iname, fname)
- return fname
-
-res = ResourceManager()
-
-class TypeManager(object):
-
- ints = [np.dtype(x) for x in ('i', 'i1', '<i2', '>i2', '<i4', '>i4')]
- uints = [np.dtype(x) for x in ('u1', '<u2', '>u2', '<u4', '>u4')]
- floats = [np.dtype(x) for x in ('f', '<f4', '>f4', '<f8', '>f8')]
- complex = [np.dtype(x) for x in ('<c8', '>c8', '<c16', '>c16')]
- strings = [np.dtype(x) for x in ('|S1', '|S2', 'S17', '|S100')]
- voids = [np.dtype(x) for x in ('|V1', '|V4', '|V8', '|V193')]
-
- compounds = [np.dtype(x) for x in \
- ( [('a', 'i'), ('b', 'f')],
- [('a', '=c8'), ('b', [('a', 'i'), ('b', 'f')])] ) ]
-
-types = TypeManager()
-
-FLOATS = ('f', '<f4', '>f4', '<f8', '>f8')
-COMPLEX = ('<c8', '>c8', '<c16', '>c16')
-STRINGS = ('|S1', '|S2', 'S17', '|S100')
-VOIDS = ('|V4', '|V8')
-
-
-def getfullpath(name):
- return op.abspath(op.join(DATADIR, name))
-
-def api_18(func):
- """Decorator to enable 1.8.X-only API functions"""
- if h5.get_config().API_18:
- return func
- return None
-
-def api_16(func):
- """Decorator to run test under HDF5 1.6 only"""
- if not h5.get_config().API_18:
- return func
- return None
-
-skipped = []
-def skip(func):
- skipped.append(func)
- return None
-
-
-EPSILON = 1e-5
-import numpy as np
-
-INTS = ('i', 'i1', '<i2', '>i2', '<i4', '>i4')
-UINTS = ('u1', '<u2', '>u2', '<u4', '>u4')
-FLOATS = ('f', '<f4', '>f4', '<f8', '>f8')
-COMPLEX = ('<c8', '>c8', '<c16', '>c16')
-STRINGS = ('|S1', '|S2', 'S17', '|S100')
-VOIDS = ('|V4', '|V8')
-
-class TestCasePlus(unittest.TestCase):
-
- def setup_fid(self, name):
- self.fname = res.get_data_copy(name)
-
- plist = h5p.create(h5p.FILE_ACCESS)
- plist.set_fclose_degree(h5f.CLOSE_STRONG)
- self.fid = h5f.open(self.fname, h5f.ACC_RDWR, fapl=plist)
-
- def teardown_fid(self):
- self.fid.close()
- os.unlink(self.fname)
-
- def assertRaisesMsg(self, msg, exc, clb, *args, **kwds):
- try:
- clb(*args, **kwds)
- except exc:
- return
- raise AssertionError("%s not raised: %s" % (exc, msg))
-
- def assertArrayEqual(self, dset, arr, message=None, precision=None):
- """ Make sure dset and arr have the same shape, dtype and contents, to
- within the given precision.
-
- Note that dset may be a NumPy array or an HDF5 dataset.
- """
- if precision is None:
- precision = EPSILON
- if message is None:
- message = ''
- else:
- message = ' (%s)' % message
-
- if np.isscalar(dset) or np.isscalar(arr):
- assert np.isscalar(dset) and np.isscalar(arr), 'Scalar/array mismatch ("%r" vs "%r")%s' % (dset, arr, message)
- assert dset - arr < precision, "Scalars differ by more than %.3f%s" % (precision, message)
- return
-
- assert dset.shape == arr.shape, "Shape mismatch (%s vs %s)%s" % (dset.shape, arr.shape, message)
- assert dset.dtype == arr.dtype, "Dtype mismatch (%s vs %s)%s" % (dset.dtype, arr.dtype, message)
- assert np.all(np.abs(dset[...] - arr[...]) < precision), "Arrays differ by more than %.3f%s" % (precision, message)
-
-
-
-
-
-
-
-
-
-
diff --git a/h5py/tests/testfiles.py b/h5py/tests/data/testfiles.py
similarity index 100%
rename from h5py/tests/testfiles.py
rename to h5py/tests/data/testfiles.py
diff --git a/h5py/tests/test_dataset.py b/h5py/tests/high/test_dataset.py
similarity index 100%
rename from h5py/tests/test_dataset.py
rename to h5py/tests/high/test_dataset.py
diff --git a/h5py/tests/test_filters.py b/h5py/tests/high/test_filters.py
similarity index 100%
rename from h5py/tests/test_filters.py
rename to h5py/tests/high/test_filters.py
diff --git a/h5py/tests/test_group.py b/h5py/tests/high/test_group.py
similarity index 100%
rename from h5py/tests/test_group.py
rename to h5py/tests/high/test_group.py
diff --git a/h5py/tests/test_highlevel.py b/h5py/tests/high/test_highlevel.py
similarity index 100%
rename from h5py/tests/test_highlevel.py
rename to h5py/tests/high/test_highlevel.py
diff --git a/h5py/tests/test_slicing.py b/h5py/tests/high/test_slicing.py
similarity index 100%
rename from h5py/tests/test_slicing.py
rename to h5py/tests/high/test_slicing.py
diff --git a/h5py/tests/test_threads.py b/h5py/tests/high/test_threads.py
similarity index 100%
rename from h5py/tests/test_threads.py
rename to h5py/tests/high/test_threads.py
diff --git a/h5py/tests/test_vlen.py b/h5py/tests/high/test_vlen.py
similarity index 100%
rename from h5py/tests/test_vlen.py
rename to h5py/tests/high/test_vlen.py
diff --git a/h5py/tests/low/__init__.py b/h5py/tests/low/__init__.py
new file mode 100644
index 0000000..f697d41
--- /dev/null
+++ b/h5py/tests/low/__init__.py
@@ -0,0 +1,25 @@
+
+"""
+ Package for testing low-level interface to h5py
+"""
+
+import unittest
+
+import test_h5, test_h5a, test_h5d, test_h5f, test_h5g, test_h5i, test_h5p, \
+ test_h5r, test_h5s, test_h5t
+import test_conv, test_utils
+
+modules = [ test_h5, test_h5a, test_h5d, test_h5f,
+ test_h5g, test_h5i, test_h5p, test_h5r,
+ test_h5s, test_h5t,
+ test_conv, test_utils ]
+
+def getsuite():
+ """ Return a test suite containing all low-level tests """
+ ldr = unittest.defaultTestLoader
+ suite = unittest.TestSuite()
+ for module in modules:
+ suite.addTests(ldr.loadTestsFromModule(module))
+ return suite
+
+
diff --git a/h5py/tests/test_conv.py b/h5py/tests/low/test_conv.py
similarity index 100%
rename from h5py/tests/test_conv.py
rename to h5py/tests/low/test_conv.py
diff --git a/h5py/tests/test_h5.py b/h5py/tests/low/test_h5.py
similarity index 100%
rename from h5py/tests/test_h5.py
rename to h5py/tests/low/test_h5.py
diff --git a/h5py/tests/test_h5a.py b/h5py/tests/low/test_h5a.py
similarity index 96%
rename from h5py/tests/test_h5a.py
rename to h5py/tests/low/test_h5a.py
index a2c0718..12eb59c 100644
--- a/h5py/tests/test_h5a.py
+++ b/h5py/tests/low/test_h5a.py
@@ -12,7 +12,7 @@
from numpy import array, ndarray, dtype, all, ones
-from common import TestCasePlus, api_18
+from h5py.tests import TestCasePlus, requires, FIDProxy
from h5py import *
@@ -31,12 +31,13 @@ NEW_ATTRIBUTES = {'New float': ( 3.14, dtype('<f4'), ()) }
class TestH5A(TestCasePlus):
def setUp(self):
- self.setup_fid(HDFNAME)
+ self.fproxy = FIDProxy(HDFNAME)
+ self.fid = self.fproxy.fid
self.obj = h5g.open(self.fid, OBJECTNAME)
def tearDown(self):
self.obj._close()
- self.teardown_fid()
+ self.fproxy.erase()
def is_attr(self, attr):
return (h5i.get_type(attr) == h5i.ATTR)
@@ -65,7 +66,7 @@ class TestH5A(TestCasePlus):
attr.read(arr_val)
self.assert_(all(arr_val == arr_ref))
- @api_18
+ @requires(api=18)
def test_create_18(self):
space = h5s.create(h5s.SCALAR)
@@ -85,13 +86,13 @@ class TestH5A(TestCasePlus):
attr = h5a.open(self.obj, name)
self.assert_(self.is_attr(attr), 'Open: name "%s"' % name)
- @api_18
+ @requires(api=18)
def test_open_name_18(self):
for name in ATTRIBUTES:
attr = h5a.open(self.fid, name, obj_name=OBJECTNAME)
self.assert_(self.is_attr(attr))
- @api_18
+ @requires(api=18)
def test_rename_18(self):
h5a.rename(self.obj, ATTRIBUTES_ORDER[0], "NewName1")
self.assert_(h5a.exists(self.obj, "NewName1"))
@@ -101,7 +102,7 @@ class TestH5A(TestCasePlus):
self.assert_(h5a.exists(self.obj, "NewName2"))
self.assert_(not h5a.exists(self.obj, ATTRIBUTES_ORDER[1]))
- @api_18
+ @requires(api=18)
def test_get_info_18(self):
info = h5a.get_info(self.obj, ATTRIBUTES_ORDER[0])
info.corder_valid
@@ -218,7 +219,7 @@ class TestH5A(TestCasePlus):
self.assert_(h5a.exists(self.obj, ATTRIBUTES_ORDER[0]))
self.assert_(not h5a.exists(self.obj, "Something else"))
- @api_18
+ @requires(api=18)
def test_exists_18(self):
self.assert_(h5a.exists(self.fid, ATTRIBUTES_ORDER[0], obj_name=OBJECTNAME))
diff --git a/h5py/tests/test_h5d.py b/h5py/tests/low/test_h5d.py
similarity index 96%
rename from h5py/tests/test_h5d.py
rename to h5py/tests/low/test_h5d.py
index 31e297c..8ec1ad6 100644
--- a/h5py/tests/test_h5d.py
+++ b/h5py/tests/low/test_h5d.py
@@ -11,7 +11,7 @@
#-
import numpy
-from common import TestCasePlus
+from h5py.tests import TestCasePlus, FIDProxy
from h5py import *
@@ -37,12 +37,13 @@ class TestH5D(TestCasePlus):
def setUp(self):
- self.setup_fid(HDFNAME)
+ self.fproxy = FIDProxy(HDFNAME)
+ self.fid = self.fproxy.fid
self.dset = h5d.open(self.fid, "CompoundChunked")
def tearDown(self):
self.dset._close()
- self.teardown_fid()
+ self.fproxy.erase()
def test_open_close(self):
dset = h5d.open(self.fid, "CompoundChunked")
diff --git a/h5py/tests/test_h5f.py b/h5py/tests/low/test_h5f.py
similarity index 89%
rename from h5py/tests/test_h5f.py
rename to h5py/tests/low/test_h5f.py
index abf4cce..36f460a 100644
--- a/h5py/tests/test_h5f.py
+++ b/h5py/tests/low/test_h5f.py
@@ -13,7 +13,7 @@
import numpy
import os
import tempfile
-from common import TestCasePlus, res
+from h5py.tests import TestCasePlus, datapath, FIDProxy
from h5py import *
@@ -23,13 +23,15 @@ class TestH5F(TestCasePlus):
def setUp(self):
- self.setup_fid(HDFNAME)
+ self.fproxy = FIDProxy(HDFNAME)
+ self.fname = self.fproxy.name
+ self.fid = self.fproxy.fid
def tearDown(self):
- self.teardown_fid()
+ self.fproxy.erase()
def test_open_close(self):
- fid = h5f.open(res.get_data_path('attributes.hdf5'), h5f.ACC_RDONLY)
+ fid = h5f.open(datapath('attributes.hdf5'), h5f.ACC_RDONLY)
self.assertEqual(h5i.get_type(fid), h5i.FILE)
fid.close()
self.assertEqual(h5i.get_type(fid), h5i.BADID)
diff --git a/h5py/tests/test_h5g.py b/h5py/tests/low/test_h5g.py
similarity index 96%
rename from h5py/tests/test_h5g.py
rename to h5py/tests/low/test_h5g.py
index 7b28379..7083655 100644
--- a/h5py/tests/test_h5g.py
+++ b/h5py/tests/low/test_h5g.py
@@ -10,7 +10,7 @@
#
#-
-from common import TestCasePlus
+from h5py.tests import TestCasePlus, FIDProxy
from h5py import *
@@ -23,12 +23,13 @@ class TestH5G(TestCasePlus):
def setUp(self):
- self.setup_fid(HDFNAME)
+ self.fproxy = FIDProxy(HDFNAME)
+ self.fid = self.fproxy.fid
self.obj = h5g.open(self.fid, OBJECTNAME)
def tearDown(self):
self.obj._close()
- self.teardown_fid()
+ self.fproxy.erase()
def is_grp(self, item):
return h5i.get_type(item) == h5i.GROUP
diff --git a/h5py/tests/test_h5i.py b/h5py/tests/low/test_h5i.py
similarity index 88%
rename from h5py/tests/test_h5i.py
rename to h5py/tests/low/test_h5i.py
index 8fbc134..5f7926b 100644
--- a/h5py/tests/test_h5i.py
+++ b/h5py/tests/low/test_h5i.py
@@ -10,7 +10,7 @@
#
#-
-from common import TestCasePlus
+from h5py.tests import TestCasePlus, FIDProxy
from h5py import *
@@ -21,12 +21,13 @@ class TestH5I(TestCasePlus):
def setUp(self):
- self.setup_fid(HDFNAME)
+ self.fproxy = FIDProxy(HDFNAME)
+ self.fid = self.fproxy.fid
self.obj = h5g.open(self.fid, OBJECTNAME)
def tearDown(self):
self.obj._close()
- self.teardown_fid()
+ self.fproxy.erase()
def test_get_type(self):
self.assertEqual(h5i.get_type(self.fid), h5i.FILE)
diff --git a/h5py/tests/test_h5p.py b/h5py/tests/low/test_h5p.py
similarity index 99%
rename from h5py/tests/test_h5p.py
rename to h5py/tests/low/test_h5p.py
index 8de5d41..f39f6e4 100644
--- a/h5py/tests/test_h5p.py
+++ b/h5py/tests/low/test_h5p.py
@@ -15,8 +15,6 @@ import numpy
from h5py import *
-HDFNAME = 'attributes.hdf5'
-
TYPES = {h5p.FILE_CREATE: h5p.PropFCID,
h5p.FILE_ACCESS: h5p.PropFAID,
h5p.DATASET_CREATE: h5p.PropDCID,
diff --git a/h5py/tests/test_h5r.py b/h5py/tests/low/test_h5r.py
similarity index 100%
rename from h5py/tests/test_h5r.py
rename to h5py/tests/low/test_h5r.py
diff --git a/h5py/tests/test_h5s.py b/h5py/tests/low/test_h5s.py
similarity index 100%
rename from h5py/tests/test_h5s.py
rename to h5py/tests/low/test_h5s.py
diff --git a/h5py/tests/test_h5t.py b/h5py/tests/low/test_h5t.py
similarity index 97%
rename from h5py/tests/test_h5t.py
rename to h5py/tests/low/test_h5t.py
index c0e08c0..e8ef534 100644
--- a/h5py/tests/test_h5t.py
+++ b/h5py/tests/low/test_h5t.py
@@ -17,7 +17,7 @@ from numpy import dtype
from h5py import *
from h5py import h5t, h5f
-from common import TestCasePlus, api_18, res
+from h5py.tests import TestCasePlus, requires, FIDProxy
import cPickle
typecode_map = {'i': h5t.INTEGER, 'u': h5t.INTEGER, 'f': h5t.FLOAT,
@@ -42,9 +42,6 @@ class BaseTypeMixin(object):
MUST be a mixin or the stupid unittest loader tries to test it.
"""
- def tearDown(self):
- res.clear()
-
ODDBALL_TYPE = h5t.create(h5t.OPAQUE, 72)
# --- The following attributes and methods MUST be overridden ---
@@ -78,7 +75,7 @@ class BaseTypeMixin(object):
self.assert_(a1 == a2)
self.assert_(not a1 == self.ODDBALL_TYPE)
- @api_18
+ @requires(api=18)
def test_serialize(self):
""" Generic subtype serialization test
"""
@@ -100,13 +97,17 @@ class BaseTypeMixin(object):
def test_commit(self):
""" Generic subtype commit test
"""
- fid = h5f.create(res.get_name())
- htype = self.get_example_type()
- self.assert_(not htype.committed())
- htype.commit(fid, "name")
- self.assert_(htype.committed())
- htype2 = h5t.open(fid, "name")
- self.assertEqual(htype, htype2)
+ fproxy = FIDProxy()
+ try:
+ fid = fproxy.fid
+ htype = self.get_example_type()
+ self.assert_(not htype.committed())
+ htype.commit(fid, "name")
+ self.assert_(htype.committed())
+ htype2 = h5t.open(fid, "name")
+ self.assertEqual(htype, htype2)
+ finally:
+ fproxy.erase()
def test_class(self):
""" Generic subtype class code test
diff --git a/h5py/tests/test_utils.py b/h5py/tests/low/test_utils.py
similarity index 98%
rename from h5py/tests/test_utils.py
rename to h5py/tests/low/test_utils.py
index a5de208..61631fd 100644
--- a/h5py/tests/test_utils.py
+++ b/h5py/tests/low/test_utils.py
@@ -12,7 +12,7 @@
import sys
import numpy
-from common import TestCasePlus, api_18
+from h5py.tests import TestCasePlus
from h5py import *
from h5py import utils
--
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