Commit ba374d0e authored by Manuel Günther's avatar Manuel Günther
Browse files

Added test decorator to test for the availability of a database

parent a36588f5
......@@ -58,6 +58,20 @@ def grid_available(test):
raise SkipTest("Skipping test since gridtk is not available: %s" % e)
return wrapper
def db_available(dbname):
'''Decorator that checks if a given bob.db database is available.
This is a double-indirect decorator, see http://thecodeship.com/patterns/guide-to-python-function-decorators'''
def wrapped_function(test):
@functools.wraps(test)
def wrapper(*args, **kwargs):
try:
__import__('bob.db.%s' % dbname)
return test(*args, **kwargs)
except ImportError as e:
raise SkipTest("Skipping test since the database bob.db.%s seems not to be available: %s" % (dbname,e))
return wrapper
return wrapped_function
atnt_default_directory = os.environ['ATNT_DATABASE_DIRECTORY'] if 'ATNT_DATABASE_DIRECTORY' in os.environ else "/idiap/group/biometric/databases/orl/"
global atnt_downloaded_directory
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment