[h5py] 275/455: Update test framework & debug output
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:41 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 9f467be9347b512b93820ff8a9a81d6a1a287eb1
Author: andrewcollette <andrew.collette at gmail.com>
Date: Fri Jun 12 22:33:19 2009 +0000
Update test framework & debug output
---
h5py/_sync.py | 25 +++++++++++++++++++------
h5py/tests/common.py | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 6 deletions(-)
diff --git a/h5py/_sync.py b/h5py/_sync.py
index 765e690..8be5f8b 100644
--- a/h5py/_sync.py
+++ b/h5py/_sync.py
@@ -20,7 +20,7 @@ from h5py.h5 import get_phil, get_config
phil = get_phil()
config = get_config()
logger = logging.getLogger('h5py.functions')
-
+logging.getLogger('h5py.identifiers').disabled = True
def uw_apply(wrap, func):
# Cython methods don't have a "module" attribute for some reason
@@ -31,29 +31,42 @@ def uw_apply(wrap, func):
def funcname(func):
- if hasattr(func, '__module__') and func.__module__ is not None:
+ if hasattr(func, '__objclass__'):
+ fullname = "%s.%s.%s" % (func.__objclass__.__module__, func.__objclass__.__name__, func.__name__)
+ elif hasattr(func, '__module__') and func.__module__ is not None:
fullname = "%s.%s" % (func.__module__, func.__name__)
elif hasattr(func, '__self__'):
fullname = "%s.%s" % (func.__self__.__class__.__name__, func.__name__)
else:
- fullname = func.__name__
+ print "unknown"
+ fullname = func.__name__
return fullname
if config.DEBUG:
+ indent = 0
+
def nosync(func):
fname = funcname(func)
def wrap(*args, **kwds):
- logger.debug( ("[ Call %s\n%s\n%s" % (fname, args, kwds)).replace("\n", "\n ") )
+ global indent
+ argstr = ", ".join("%r" % (arg,) for arg in args)
+ kwstr = ", ".join("%s=%r" % (x,y) for x, y in kwds.iteritems())
+ logger.debug(" "*indent+"%s(%s%s)" % (fname, argstr, kwstr))
+ indent += 4
try:
retval = func(*args, **kwds)
except BaseException, e:
- logger.debug('! Exception in %s: %s("%s")' % (fname, e.__class__.__name__, e))
+ logger.debug(" "*indent+'! %s("%s")' % (e.__class__.__name__, e))
raise
- logger.debug( ("] Exit %s\n%s" % (fname,retval)).replace("\n", "\n ") )
+ else:
+ if retval is not None:
+ logger.debug(" "*(indent)+"=> %r" % (retval,))
+ finally:
+ indent -= 4
return retval
uw_apply(wrap, func)
return wrap
diff --git a/h5py/tests/common.py b/h5py/tests/common.py
index f3dee94..bebc7ce 100644
--- a/h5py/tests/common.py
+++ b/h5py/tests/common.py
@@ -20,6 +20,44 @@ import h5py
DATADIR = op.join(op.dirname(h5py.__file__), 'tests/data')
+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):
+ """ Return a temporary filename, which can be unlinked with clear() """
+ fname = tempfile.mktemp()
+ 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()
+
+ 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)
+
+ def get_data_path(self, name):
+ """ Return the full path to a data file (given its basename) """
+ return op.abspath(op.join(DATADIR, name))
+
+
+
+res = ResourceManager()
+
def getfullpath(name):
return op.abspath(op.join(DATADIR, name))
--
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